greetings , i hope this is the correct fourm to post this if not then please guide me to the correct one .
im making a game puzzle one actually .
to make it short
in each level there is a switch if you trigger it
lets say we have 2 groups of objects
group a is active and group b is inactive
once you hit the switch all objects in group A sprites should fade out and all objects in group b should fade in .
and again if i hit switch it should go back to normal .
i need to achive this in the best approach withowt the need to hard code .
thank you
Just make two arrays of objects (or your class) and when the switch switches, fire some code that affects all of the sprites in each array to be on or off.
You’ll have to drag-n-drop your objects from the scene to the inspector fields, but thats not a big deal.
thats what i did it works great
i had to use for each method .
but i cant seem to use color lerp to fade in the sprites .
public gameobject[ ] groupA
i used this function in update if(bool == true)
turnoff()
void turnoff(){
groupA[ ].getcomponent().color = color.lerp(…etc )
}
its not working even if i used foreach loop method it wont lerp the sprites for each item in the arry .