Unity3D localscale issue

三世轮回 提交于 2019-12-24 00:50:08

问题


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);

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 just assume that since these things are happening right after each other, the scale should be updated. Or does that happen after a frame has completed?

Any help is appreciated.


回答1:


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



来源:https://stackoverflow.com/questions/21539119/unity3d-localscale-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!