Hi guys! I’ve this image in my scene…
i want to change the alpha in a way like this…
public Image MyImage;
public bool imageBool;
vois Start()
{
alphaImage = MyImage.GetComponent<SpriteRenderer>().color;
}
void Update()
{
if (imageBool == true)
{
alphaImage .a -= 10;
}
}
But it not work for some reason… i have many red point in the ispector… there is a better way ? Thank you 
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class AlphaTest : MonoBehaviour
{
public SpriteRenderer sprite;
public bool hide;
public float alphaSpeed = 1f;
private float _alpha = 1f;
void Update()
{
if (hide)
{
if(_alpha > 0f)
{
_alpha = Mathf.MoveTowards(_alpha, 0f, Time.deltaTime * alphaSpeed);
sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, _alpha);
}
}
else
{
if(_alpha < 1f)
{
_alpha = Mathf.MoveTowards(_alpha, 1f, Time.deltaTime * alphaSpeed);
sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, _alpha);
}
}
}
}