c# - Unable to change array size in Inspector variable in Unity? -
from have read how vector "size" set
public color[] teamacolors = new color[4];
it doesn't seem matter number put [4], size stays 6. not sure 6 number coming have not set number.
i have tried
public color[] teamacolors;
and let array auto populate length, doesn't change 6 either.
it's simply
public color[] teamacolors;
but "6" value "won't go away"?
but you've stumbled on "reset" gotchya in unity!
just try different variable name...
public color[] teste;
see?
there is, working fine. can set size dynamically, long never put size in code.
here secret:
unity "holds on to" serialized values in complicated way.
if set size in code once, unity "remembers" if subsequently change code.
there way reset "inner" value .. famous tiny reset button.
it attached tiny cog symbol.
the critical rule remember this:
never, ever, have default value in code public variables in unity!!
public float x; // public float x=2f; // never
while you're @ it, here's incredibly handy trick. try ...
[header("how this?")] public float x;
here's cooler one! try it!
[range(2f,4f)] public float x;
Comments
Post a Comment