private static List <DoubleCurve> GetSignedDoubleCurveDefaults() { return(new List <DoubleCurve> { new DoubleCurve(new AnimationCurve(CurveEditorWindow.GetConstantKeys(-1f)), new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), true) }); }
void InitCurvePresets() { if (m_CurvePresets == null) { AnimationCurve max = m_CurveEditor.animationCurves[0].curve; AnimationCurve min = m_CurveEditor.animationCurves.Length > 1 ? m_CurveEditor.animationCurves[1].curve : null; // Selection callback for library window System.Action<DoubleCurve> presetSelectedCallback = delegate(DoubleCurve presetCurve) { var doubleCurve = new DoubleCurve(min, max, true); doubleCurve.minCurve.keys = CurveEditorWindow.GetNormalizedKeys(presetCurve.minCurve.keys, m_CurveEditor); doubleCurve.minCurve.postWrapMode = presetCurve.minCurve.postWrapMode; doubleCurve.minCurve.preWrapMode = presetCurve.minCurve.preWrapMode; doubleCurve.maxCurve.keys = CurveEditorWindow.GetNormalizedKeys(presetCurve.maxCurve.keys, m_CurveEditor); doubleCurve.maxCurve.postWrapMode = presetCurve.maxCurve.postWrapMode; doubleCurve.maxCurve.preWrapMode = presetCurve.maxCurve.preWrapMode; m_CurveEditor.SelectNone(); RefreshShownCurves(); SendEvent("CurveChanged", true); }; // We set the curve to save when showing the popup to ensure to scale the current state of the curve m_CurvePresets = new DoubleCurvePresetsContentsForPopupWindow(new DoubleCurve(min, max, true), presetSelectedCallback); m_CurvePresets.InitIfNeeded(); m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib().useRanges = false; } }
private void PresetDropDown(Rect rect) { if (!EditorGUI.ButtonMouseDown(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Native, EditorStyles.inspectorTitlebarText) || this.m_Curve == null) { return; } if (this.m_CurvePresets == null) { Debug.LogError((object)"Curve presets error"); } else { this.ValidateCurveLibraryTypeAndScale(); AnimationCurve animationCurve = new AnimationCurve(); Rect normalizationRect; if (this.GetNormalizationRect(out normalizationRect)) { bool realToNormalized = true; animationCurve.keys = CurveEditorWindow.CopyAndScaleCurveKeys(this.m_Curve.keys, normalizationRect, realToNormalized); } else { animationCurve = new AnimationCurve(this.m_Curve.keys); } animationCurve.postWrapMode = this.m_Curve.postWrapMode; animationCurve.preWrapMode = this.m_Curve.preWrapMode; this.m_CurvePresets.curveToSaveAsPreset = animationCurve; PopupWindow.Show(rect, (PopupWindowContent)this.m_CurvePresets); } }
private void InitCurvePresets() { if (this.m_CurvePresets != null) { return; } this.m_CurvePresets = new CurvePresetsContentsForPopupWindow((AnimationCurve)null, this.curveLibraryType, (System.Action <AnimationCurve>)(presetCurve => { this.ValidateCurveLibraryTypeAndScale(); Rect normalizationRect; if (this.GetNormalizationRect(out normalizationRect)) { bool realToNormalized = false; this.m_Curve.keys = CurveEditorWindow.CopyAndScaleCurveKeys(presetCurve.keys, normalizationRect, realToNormalized); } else { this.m_Curve.keys = presetCurve.keys; } this.m_Curve.postWrapMode = presetCurve.postWrapMode; this.m_Curve.preWrapMode = presetCurve.preWrapMode; this.m_CurveEditor.SelectNone(); this.RefreshShownCurves(); this.SendEvent("CurveChanged", true); })); this.m_CurvePresets.InitIfNeeded(); }
internal static Keyframe[] GetConstantKeys(float value) { Keyframe[] keys = new Keyframe[2] { new Keyframe(0.0f, value, 0.0f, 0.0f), new Keyframe(1f, value, 0.0f, 0.0f) }; CurveEditorWindow.SetSmoothEditable(ref keys); return(keys); }
internal static Keyframe[] GetEaseInOutMirrorKeys() { Keyframe[] keys = new Keyframe[2] { new Keyframe(0.0f, 1f, 0.0f, 0.0f), new Keyframe(1f, 0.0f, 0.0f, 0.0f) }; CurveEditorWindow.SetSmoothEditable(ref keys); return(keys); }
internal static Keyframe[] GetEaseInOutMirrorKeys() { Keyframe[] result = new Keyframe[] { new Keyframe(0f, 1f, 0f, 0f), new Keyframe(1f, 0f, 0f, 0f) }; CurveEditorWindow.SetSmoothEditable(ref result); return(result); }
internal static Keyframe[] GetConstantKeys(float value) { Keyframe[] result = new Keyframe[] { new Keyframe(0f, value, 0f, 0f), new Keyframe(1f, value, 0f, 0f) }; CurveEditorWindow.SetSmoothEditable(ref result); return(result); }
private Keyframe[] NormalizeKeys(Keyframe[] sourceKeys, CurveEditorWindow.NormalizationMode normalization) { Rect rect; if (!this.GetNormalizationRect(out rect)) { normalization = CurveEditorWindow.NormalizationMode.None; } return(CurveEditorWindow.CopyAndScaleCurveKeys(sourceKeys, rect, normalization)); }
private void OnDisable() { this.m_CurveEditor.OnDisable(); if ((UnityEngine.Object)CurveEditorWindow.s_SharedCurveEditor == (UnityEngine.Object) this) { CurveEditorWindow.s_SharedCurveEditor = (CurveEditorWindow)null; } else if (!this.Equals((object)CurveEditorWindow.s_SharedCurveEditor)) { throw new ApplicationException("s_SharedCurveEditor does not equal this"); } }
void OnDisable() { m_CurveEditor.OnDisable(); if (s_SharedCurveEditor == this) { s_SharedCurveEditor = null; } else if (!this.Equals(s_SharedCurveEditor)) { throw new ApplicationException("s_SharedCurveEditor does not equal this"); } }
private static List <DoubleCurve> GetUnsignedSingleCurveDefaults(bool signedRange) => new List <DoubleCurve> { new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetLinearKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetLinearMirrorKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInMirrorKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseOutKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseOutMirrorKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys()), signedRange), new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInOutMirrorKeys()), signedRange) };
static List <DoubleCurve> GetUnsignedSingleCurveDefaults(bool signedRange) { List <DoubleCurve> defaults = new List <DoubleCurve>(); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetLinearKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetLinearMirrorKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInMirrorKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseOutKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseOutMirrorKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys()), signedRange)); defaults.Add(new DoubleCurve(null, new AnimationCurve(CurveEditorWindow.GetEaseInOutMirrorKeys()), signedRange)); return(defaults); }
private void OnDisable() { this.m_CurveEditor.OnDisable(); if (CurveEditorWindow.s_SharedCurveEditor == this) { CurveEditorWindow.s_SharedCurveEditor = null; } else { if (!this.Equals(CurveEditorWindow.s_SharedCurveEditor)) { throw new ApplicationException("s_SharedCurveEditor does not equal this"); } } }
private void AddDefaultPresetsToLibrary(PresetLibrary presetLibrary) { CurvePresetLibrary curvePresetLibrary = presetLibrary as CurvePresetLibrary; if (curvePresetLibrary == null) { Debug.Log("Incorrect preset library, should be a CurvePresetLibrary but was a " + presetLibrary.GetType()); return; } foreach (AnimationCurve current in new List <AnimationCurve> { new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), new AnimationCurve(CurveEditorWindow.GetLinearKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInKeys()), new AnimationCurve(CurveEditorWindow.GetEaseOutKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys()) }) { curvePresetLibrary.Add(current, string.Empty); } }
void AddDefaultPresetsToLibrary(PresetLibrary presetLibrary) { CurvePresetLibrary curveDefaultLib = presetLibrary as CurvePresetLibrary; if (curveDefaultLib == null) { Debug.Log("Incorrect preset library, should be a CurvePresetLibrary but was a " + presetLibrary.GetType()); return; } List <AnimationCurve> defaults = new List <AnimationCurve>(); defaults.Add(new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f))); defaults.Add(new AnimationCurve(CurveEditorWindow.GetLinearKeys())); defaults.Add(new AnimationCurve(CurveEditorWindow.GetEaseInKeys())); defaults.Add(new AnimationCurve(CurveEditorWindow.GetEaseOutKeys())); defaults.Add(new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys())); foreach (AnimationCurve preset in defaults) { curveDefaultLib.Add(preset, ""); } }
private void AddDefaultPresetsToLibrary(PresetLibrary presetLibrary) { CurvePresetLibrary library = presetLibrary as CurvePresetLibrary; if (library == null) { Debug.Log("Incorrect preset library, should be a CurvePresetLibrary but was a " + presetLibrary.GetType()); } else { List <AnimationCurve> list = new List <AnimationCurve> { new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), new AnimationCurve(CurveEditorWindow.GetLinearKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInKeys()), new AnimationCurve(CurveEditorWindow.GetEaseOutKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys()) }; foreach (AnimationCurve curve in list) { library.Add(curve, ""); } } }
private void AddDefaultPresetsToLibrary(PresetLibrary presetLibrary) { CurvePresetLibrary curvePresetLibrary = presetLibrary as CurvePresetLibrary; if ((UnityEngine.Object)curvePresetLibrary == (UnityEngine.Object)null) { Debug.Log((object)("Incorrect preset library, should be a CurvePresetLibrary but was a " + (object)presetLibrary.GetType())); } else { using (List <AnimationCurve> .Enumerator enumerator = new List <AnimationCurve>() { new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), new AnimationCurve(CurveEditorWindow.GetLinearKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInKeys()), new AnimationCurve(CurveEditorWindow.GetEaseOutKeys()), new AnimationCurve(CurveEditorWindow.GetEaseInOutKeys()) }.GetEnumerator()) { while (enumerator.MoveNext()) { AnimationCurve current = enumerator.Current; curvePresetLibrary.Add((object)current, string.Empty); } } } }
private void OnDisable() { this.m_CurveEditor.OnDisable(); if (s_SharedCurveEditor == this) { s_SharedCurveEditor = null; } else if (!this.Equals(s_SharedCurveEditor)) { throw new ApplicationException("s_SharedCurveEditor does not equal this"); } }
private void OnEnable() { CurveEditorWindow.s_SharedCurveEditor = this; this.Init((CurveEditorSettings) null); }
void OnEnable() { s_SharedCurveEditor = this; Init(null); }
private void OnDisable() { this.m_CurveEditor.OnDisable(); if ((UnityEngine.Object) CurveEditorWindow.s_SharedCurveEditor == (UnityEngine.Object) this) CurveEditorWindow.s_SharedCurveEditor = (CurveEditorWindow) null; else if (!this.Equals((object) CurveEditorWindow.s_SharedCurveEditor)) throw new ApplicationException("s_SharedCurveEditor does not equal this"); }
private void OnEnable() { CurveEditorWindow.s_SharedCurveEditor = this; this.Init(null); }
private void OnEnable() { CurveEditorWindow.s_SharedCurveEditor = this; this.Init(null); this.m_CurveEditor.OnEnable(); }
private static List <DoubleCurve> GetUnsignedDoubleCurveDefaults() { return(new List <DoubleCurve>() { new DoubleCurve(new AnimationCurve(CurveEditorWindow.GetConstantKeys(0.0f)), new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), false) }); }
static List <DoubleCurve> GetSignedDoubleCurveDefaults() { List <DoubleCurve> defaults = new List <DoubleCurve>(); defaults.Add(new DoubleCurve(new AnimationCurve(CurveEditorWindow.GetConstantKeys(-1f)), new AnimationCurve(CurveEditorWindow.GetConstantKeys(1f)), true)); return(defaults); }
void DrawPresetSwatchArea() { GUI.Box(new Rect(0, position.height - k_PresetsHeight, position.width, k_PresetsHeight), "", s_Styles.curveSwatchArea); Color curveColor = m_Color; curveColor.a *= 0.6f; float yPos = position.height - k_PresetsHeight + (k_PresetsHeight - k_PresetSwatchHeight) * 0.5f; InitCurvePresets(); var curveLibrary = m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib(); if (curveLibrary != null) { GUIContent guiContent = EditorGUIUtility.TempContent(string.Empty); for (int i = 0; i < curveLibrary.Count(); i++) { Rect swatchRect = new Rect(k_PresetSwatchMargin + (k_PresetSwatchWidth + k_PresetSwatchSeperation) * i, yPos, k_PresetSwatchWidth, k_PresetSwatchHeight); guiContent.tooltip = curveLibrary.GetName(i); if (GUI.Button(swatchRect, guiContent, s_Styles.curveSwatch)) { AnimationCurve max = m_CurveEditor.animationCurves[0].curve; AnimationCurve min = m_CurveEditor.animationCurves.Length > 1 ? m_CurveEditor.animationCurves[1].curve : null; var animCurve = curveLibrary.GetPreset(i) as DoubleCurve; max.keys = CurveEditorWindow.GetDenormalizedKeys(animCurve.maxCurve.keys, m_CurveEditor); max.postWrapMode = animCurve.maxCurve.postWrapMode; max.preWrapMode = animCurve.maxCurve.preWrapMode; if (min != null) { min.keys = CurveEditorWindow.GetDenormalizedKeys(animCurve.minCurve.keys, m_CurveEditor); min.postWrapMode = animCurve.minCurve.postWrapMode; min.preWrapMode = animCurve.minCurve.preWrapMode; } m_CurveEditor.SelectNone(); RefreshShownCurves(); SendEvent("CurveChanged", true); } if (Event.current.type == EventType.Repaint) { curveLibrary.Draw(swatchRect, i); } if (swatchRect.xMax > position.width - 2 * k_PresetSwatchMargin) { break; } } } // Dropdown Rect presetDropDownButtonRect = new Rect(k_PresetSwatchMargin - k_PresetsDropdownButtonSize, yPos + k_PresetSwatchSeperation, k_PresetsDropdownButtonSize, k_PresetsDropdownButtonSize); if (EditorGUI.DropdownButton(presetDropDownButtonRect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { if (m_MaxCurve != null) { AnimationCurve max = m_CurveEditor.animationCurves[0].curve; AnimationCurve maxCopy = new AnimationCurve(CurveEditorWindow.GetNormalizedKeys(max.keys, m_CurveEditor)); maxCopy.postWrapMode = max.postWrapMode; maxCopy.preWrapMode = max.preWrapMode; AnimationCurve minCopy = null; if (m_MinCurve != null) { AnimationCurve min = m_CurveEditor.animationCurves[1].curve; minCopy = new AnimationCurve(CurveEditorWindow.GetNormalizedKeys(min.keys, m_CurveEditor)); minCopy.postWrapMode = min.postWrapMode; minCopy.preWrapMode = min.preWrapMode; } m_CurvePresets.doubleCurveToSave = new DoubleCurve(minCopy, maxCopy, true); PopupWindow.Show(presetDropDownButtonRect, m_CurvePresets); } } }
private void OnEnable() { s_SharedCurveEditor = this; this.Init(null); }