using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class appear : MonoBehaviour {
Color color;
// // Use this for initialization
void Start () {
SpriteRenderer spr = GetComponent<SpriteRenderer>();
color.a = 0;
spr.color = color;
}
// // Update is called once per frame
void Update () {
SpriteRenderer spr = GetComponent<SpriteRenderer>();
color.a += 0.02f;
spr.color = color;
}
}
This is how I tried to increase the transparency of the sprite gradually, but when I ran it, it kept transparent. When I checked the inspector window, the value of A in the image is clearly increasing, but it is still transparent on the screen.
unity
From Update
spr.color = new Color(spg.color.red, spg.color.green, spg.color.blue, spg.color.red + 0.02f);
I think we can do it
© 2024 OneMinuteCode. All rights reserved.