- Home /
Question by
ArIaNFury008 · Jun 14, 2020 at 04:23 PM ·
alphaproblem during runtime
alpha problem it mix alpha
Hi everyone , i have problem with alpha i want change color my Grounds and stores alpha this is my code :
public List Colliders = new List(); public List GetColliders() { return Colliders; }
public Color GroundColor = Color.red;
Color AlhpaStore;
public Color BackColor = Color.cyan;
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("G"))
{
if (!Colliders.Contains(other))
{
Colliders.Add(other);
other.GetComponent<SpriteRenderer>().enabled = true;
AlhpaStorge.a = other.GetComponent<SpriteRenderer>().color.a;
GroundColor.a = AlhpaStorge.a;
other.GetComponent<SpriteRenderer>().color = GroundColor;
}
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.CompareTag("G"))
{
Colliders.Remove(other);
other.GetComponent<SpriteRenderer>().enabled = false;
BackColor.a = AlhpaStorge.a;
other.GetComponent<SpriteRenderer>().color = BackColor;
}
}
this code work good but my code somtimes It mixes alpha
Orginal : 
It mixes alpha : 
if anyone have suggestion please help thanks .
orginal.png
(38.9 kB)
mix-alpha.png
(56.7 kB)
Comment
I'd better explain i have 3 area 1- 100% Alpha 2-70% Alpha 3- 50% Alpha but my code mix 3 with 1
Your answer
Follow this Question
Related Questions
How do I use Movie Texture with alpha channel? 4 Answers
Acces the secondary colors in the shaders. 1 Answer
Stenciling on Unity iPhone 1 Answer
Non rectangular GUI Mask / Matte? 2 Answers
Gui alpha change 0 Answers