本文介绍了Unity3D localscale问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码:
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);
产生以下输出:
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?
感谢您的帮助.
推荐答案
localScale是一个属性,因此它返回真实localScale的副本(Vector3是一个结构)尝试cell.transform.localScale = new Vector3 (scaleFactor, scaleFactor, scaleFactor);
或cell.transform.localScale = Vector3.one * scaleFactor;
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;
这篇关于Unity3D localscale问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!