How can I do this? Any Ideas?
I want to have a gameObject that has a public variable called Value:
The shape's size is defined by the value, and it has more "layers" the more value it has, kinda like an onion
Anyone have any ideas on how I can do this??
Answer by antiquote · Jun 17, 2016 at 07:55 PM
@Coetzer FIrst thought that comes to mind is using an Array/List in order to keep track of all your layers, and using your "value" as the index for your Array/List. Anytime you want a new layer you just instantiate it, add it to the Array/List and use this "value" to mathemetically change whatever values you need in reference to the base. In your case it would be your Color Value (How vibrant your color is) and your scale if that makes sense. Here is a idea in code for general implementation that is used for reference, not functionality:
GameObject[] shape;
void Update() {
for(int value = 0; value < shape.Length; value++)
{
shape[value].transform.scale = shape[0].transform.scale * value * scaleMultiplier;
shape[value].GetComponent<SpriteRenderer>().color = shape[0].GetComponent<SpriteRenderer>().color / (value * colorMultiplier);
}
}
void CreateShape
{
//Create Shape and add to array.
}
}
Good thinking, I'll try it tonight and see if it works, and let you know... Thanks!