Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Editor for Quaternion - weird problem

$
0
0
Basically all I want to do is make an editor for a rotation, exactly like the one Unity uses for transform.rotation (that is, with x, y, z only, not w). I can get EditorGUILayout.Vector3Field to work fine for normal Vector3 fields, but for some reason I am having a strange problem when I try to convert a Quaternion to a Vector3, create a Vector3Field for it, and then convert the returned value back to a Quaternion. The problem is that when I go to edit a number in this Vector3Field, the value for that number seems to wiggle around for a second or two before returning back to zero. I have no explanation for this. Here is the relevant line from my editor: scriptTarget.startAngle = toQuaternion(EditorGUILayout.Vector3Field("Default Angle", toVector3(scriptTarget.startAngle))); ... and the two utility methods used: public static Vector3 toVector3(Quaternion q) { return new Vector3(q.x, q.y, q.z); } public static Quaternion toQuaternion(Vector3 v) { return Quaternion.Euler(v.x, v.y, v.z); }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>