///In SceneGUI, shows a position handle for target vector of target directable (pos handle in provided euler rotation) public static bool DoVectorPositionHandle(IDirectable directable, TransformSpace space, Vector3?euler, ref Vector3 position) { EditorGUI.BeginChangeCheck(); var pos = directable.TransformPosition(position, space); var rot = euler == null ? Quaternion.identity : directable.TransformRotation(euler.Value, space); var newPos = Handles.PositionHandle(pos, rot); Handles.SphereHandleCap(-10, pos, Quaternion.identity, 0.1f, EventType.Repaint); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(directable as Object, "Position Change"); position = directable.InverseTransformPosition(newPos, space); EditorUtility.SetDirty(directable as Object); return(true); } return(false); }
///Returns the final actor position in specified Space (InverseTransform Space) public static Vector3 ActorPositionInSpace(this IDirectable directable, TransformSpace space) { return(directable.actor != null?directable.InverseTransformPosition(directable.actor.transform.position, space) : directable.root.context.transform.position); }