Problem with Unity3D localscale

The following code:

Debug.LogWarning("updating scale fix, scalefactor: "+scaleFactor+" - Current scale is: "+cell.transform.localScale.x);
cell.transform.localScale.Set (scaleFactor,scaleFactor,scaleFactor);
Debug.LogWarning("Scale after fix: " + cell.transform.localScale.x);

It produces the following output:

updating scale fix, scalefactor: 0.9 - Current scale is 0.8921105
UnityEngine.Debug:LogWarning(Object)

Scale after fix: 0.8921105
UnityEngine.Debug:LogWarning(Object)

Any ideas? I would simply suggest that since these things happen immediately after each other, the scale needs to be updated. Or does this happen after the frame is completed?

Any help is appreciated.

+1
source share
1 answer

localScale is a property, so it returns a copy of the real localScale (Vector3 is a structure) Try cell.transform.localScale = new Vector3 (scaleFactor, scaleFactor, scaleFactor); orcell.transform.localScale = Vector3.one * scaleFactor;

+4
source

All Articles