public SpherePointKeyframe(SpherePointKeyframe keyframe) : base(keyframe.time) { spherePoint = new SpherePoint( keyframe.spherePoint.horizontalRotation, keyframe.spherePoint.verticalRotation); interpolationCurve = keyframe.interpolationCurve; interpolationDirection = keyframe.interpolationDirection; }
// GUI for a sphere point selection. public static SpherePoint SpherePointField(SpherePoint spherePoint, bool sceneSelection, string controlId) { bool isActive = IsActiveToken(controlId); SpherePoint selectedSpherePoint = spherePoint; // Horizontal rotation layout. EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); float selectedHorizontalValue = EditorGUILayout.Slider("Horizontal", spherePoint.horizontalRotation, SpherePoint.MinHorizontalRotation, SpherePoint.MaxHorizontalRotation); if (EditorGUI.EndChangeCheck()) { selectedSpherePoint = new SpherePoint(selectedHorizontalValue, spherePoint.verticalRotation); GUI.changed = true; } EditorGUILayout.EndHorizontal(); // Vertical rotation layout. EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); float selectedVerticalValue = EditorGUILayout.Slider("Vertical", spherePoint.verticalRotation, SpherePoint.MinVerticalRotation, SpherePoint.MaxVerticalRotation); if (EditorGUI.EndChangeCheck()) { selectedSpherePoint = new SpherePoint(spherePoint.horizontalRotation, selectedVerticalValue); GUI.changed = true; } EditorGUILayout.EndHorizontal(); if (sceneSelection) { RenderSpherePointSelectionButton(controlId); } EditorGUILayout.EndVertical(); // Check if a selection has completed for this control. if (isActive && m_SelectionResultReady) { selectedSpherePoint = m_SelectedSpherePoint; m_SelectionResultReady = false; m_ActiveReceiver = null; GUI.changed = true; } return(selectedSpherePoint); }
public SpherePointKeyframe(SpherePoint spherePoint, float time) : base(time) { if (spherePoint == null) { Debug.LogError("Passed null sphere point, created empty point"); this.spherePoint = new SpherePoint(0, 0); } else { this.spherePoint = spherePoint; } interpolationDirection = InterpolationDirection.Auto; }
private bool RenderSpherePointPropertyGroup(ProfileGroupDefinition def) { EditorGUILayout.BeginHorizontal(); bool valueChanged = false; SpherePointKeyframeGroup group = m_Profile.GetGroup <SpherePointKeyframeGroup>(def.propertyKey); if (m_Profile.IsManagedByTimeline(def.propertyKey)) { EditorGUILayout.PrefixLabel(new GUIContent(def.groupName, def.tooltip)); RenderManagedOnTimlineMessage(); } else { SpherePointKeyframe frame = group.GetKeyframe(0); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent(group.name, def.tooltip)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel += 1; SpherePoint selectedPoint = SpherePointGUI.SpherePointField( frame.spherePoint, true, frame.id); EditorGUI.indentLevel -= 1; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Profile, "Changed sphere point"); frame.spherePoint = selectedPoint; } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); return(valueChanged); }
private bool RenderSpherePointGUI() { bool didModify = false; SpherePointKeyframe spherePointKeyframe = keyframe as SpherePointKeyframe; if (spherePointKeyframe == null) { return(false); } EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); SpherePoint selectedSpherePoint = SpherePointGUI.SpherePointField(spherePointKeyframe.spherePoint, true, keyframe.id); if (EditorGUI.EndChangeCheck()) { spherePointKeyframe.spherePoint = selectedSpherePoint; didModify = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); GUIStyle style = GUI.skin.button; EditorGUILayout.PrefixLabel( new GUIContent("Normalize Speed", "Adjust all keyframes so that there is a constant speed of animation between them.")); GUILayout.Button(new GUIContent("Reposition All Keyframes..."), style); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(profile, "Normalize keyframe speeds"); didModify = true; SpherePointTimelineRow.RepositionKeyframesForConstantSpeed(group as SpherePointKeyframeGroup); } EditorGUILayout.EndHorizontal(); return(didModify); }
// Handles allowing user to make a selection in the scene view for an sphere point position. public static void RenderSpherePointSceneSelection() { if (m_ActiveReceiver == null || m_SelectionResultReady) { return; } Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); Vector3 worldPoint = ray.GetPoint(.01f); Handles.DrawWireDisc(worldPoint, ray.direction * -1.0f, HandleUtility.GetHandleSize(worldPoint)); if (Event.current.keyCode == KeyCode.Escape) { CancelSpherePointSceneSelection(); return; } // Ignore click if some special key is pressed for navigation reasons. if (Event.current.alt || Event.current.control || Event.current.command) { return; } if (Event.current.type != EventType.MouseDown) { return; } m_SelectedSpherePoint = new SpherePoint(ray.direction); m_SelectionResultReady = true; Event.current.Use(); GUIUtility.hotControl = 0; }
private void AddSpherePointGroup(string propKey, string groupName, SpherePoint point) { SpherePointKeyframeGroup group = new SpherePointKeyframeGroup(groupName, new SpherePointKeyframe(point, 0)); keyframeGroups[propKey] = group; }