I am learning via youtube and reading, I know there is a c# line that goes right in here to set the transparency when i am changing the color, but I can find no examples or explanations via google and forums. This is the snippet of code that is all in all working properly, but i want to change the transparency as I am changing colors.
its for a turn based game so the tile colors change every turn based on what unit you have highlighted. Ill try this tho and see if it works thank you!!
In that case you should not use the update method. Instead you should send a message when the player clicks on hte object. I don’t want to confuse you too much if you just began but it never hurts to get the right direction.
I assume that at some point you assign the current variable for example if hte player clicks on it. This might be another script. Then you can do this:
//Put this on top of oyur manager class:
[SerializeField] Color NormalColor;
[SerializeField] Color CurrentColor;
[SerializeField] Color selectableColor;
[SerializeField] Color TargetColor;
//Wherever you assign states:
//Instead of
tile.current = true;
//Use this:
tile.SetColor(CurrentColor);
//Instead of
tile.target = true;
//Use this:
tile.SetColor(TargetColor);
//Instead of
tile.selectable = true;
//Use this:
tile.SetColor(SelectableColor);
//Make sure to deselect the old objects:
//Instead of
tile.current = false;
//Use this:
tile.SetColor(NormalColor);
YOu then need a method in your tile class called SetColor:
public void SetColor(Color color)
{
renderer.material.color = color;
}
He had some boolean in there, I just took a piece of the code to show how to do the things necessary. That’s kind of a problem with using code tags because it looks like it should be replacement code, but wasn’t meant for that purpose. It was just an example on how to show transparency.