Esempio n. 1
0
        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 AddDefaultPresetsToLibrary(PresetLibrary presetLibrary)
        {
            DoubleCurvePresetLibrary doubleCurvePresetLibrary = presetLibrary as DoubleCurvePresetLibrary;

            if (doubleCurvePresetLibrary == null)
            {
                Debug.Log("Incorrect preset library, should be a DoubleCurvePresetLibrary but was a " + presetLibrary.GetType());
                return;
            }
            bool signedRange        = this.m_DoubleCurve.signedRange;
            List <DoubleCurve> list = new List <DoubleCurve>();

            if (this.IsSingleCurve(this.m_DoubleCurve))
            {
                list = DoubleCurvePresetsContentsForPopupWindow.GetUnsignedSingleCurveDefaults(signedRange);
            }
            else
            {
                if (signedRange)
                {
                    list = DoubleCurvePresetsContentsForPopupWindow.GetSignedDoubleCurveDefaults();
                }
                else
                {
                    list = DoubleCurvePresetsContentsForPopupWindow.GetUnsignedDoubleCurveDefaults();
                }
            }
            foreach (DoubleCurve current in list)
            {
                doubleCurvePresetLibrary.Add(current, string.Empty);
            }
        }
 private void InitDoubleCurvePresets()
 {
     int num;
     if (this.m_CurveEditor.GetTopMostCurveID(out num) && ((this.m_DoubleCurvePresets == null) || (this.m_LastTopMostCurveID != num)))
     {
         this.m_LastTopMostCurveID = num;
         Action<DoubleCurve> presetSelectedCallback = delegate (DoubleCurve presetDoubleCurve) {
             this.SetTopMostCurve(presetDoubleCurve);
             InternalEditorUtility.RepaintAllViews();
         };
         DoubleCurve doubleCurveToSave = this.CreateDoubleCurveFromTopMostCurve();
         this.m_DoubleCurvePresets = new DoubleCurvePresetsContentsForPopupWindow(doubleCurveToSave, presetSelectedCallback);
         this.m_DoubleCurvePresets.InitIfNeeded();
     }
 }
        private void AddDefaultPresetsToLibrary(PresetLibrary presetLibrary)
        {
            DoubleCurvePresetLibrary curvePresetLibrary = presetLibrary as DoubleCurvePresetLibrary;

            if ((UnityEngine.Object)curvePresetLibrary == (UnityEngine.Object)null)
            {
                Debug.Log((object)("Incorrect preset library, should be a DoubleCurvePresetLibrary but was a " + (object)presetLibrary.GetType()));
            }
            else
            {
                bool signedRange = this.m_DoubleCurve.signedRange;
                List <DoubleCurve> doubleCurveList = new List <DoubleCurve>();
                using (List <DoubleCurve> .Enumerator enumerator = (!this.IsSingleCurve(this.m_DoubleCurve) ? (!signedRange ? DoubleCurvePresetsContentsForPopupWindow.GetUnsignedDoubleCurveDefaults() : DoubleCurvePresetsContentsForPopupWindow.GetSignedDoubleCurveDefaults()) : DoubleCurvePresetsContentsForPopupWindow.GetUnsignedSingleCurveDefaults(signedRange)).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DoubleCurve current = enumerator.Current;
                        curvePresetLibrary.Add((object)current, string.Empty);
                    }
                }
            }
        }
 private void InitDoubleCurvePresets()
 {
   int curveID;
   if (!this.m_CurveEditor.GetTopMostCurveID(out curveID) || this.m_DoubleCurvePresets != null && this.m_LastTopMostCurveID == curveID)
     return;
   this.m_LastTopMostCurveID = curveID;
   this.m_DoubleCurvePresets = new DoubleCurvePresetsContentsForPopupWindow(this.CreateDoubleCurveFromTopMostCurve(), (System.Action<DoubleCurve>) (presetDoubleCurve =>
   {
     this.SetTopMostCurve(presetDoubleCurve);
     InternalEditorUtility.RepaintAllViews();
   }));
   this.m_DoubleCurvePresets.InitIfNeeded();
 }