UnityEditor.CurvePresetsContentsForPopupWindow.InitIfNeeded C# (CSharp) Method

InitIfNeeded() public method

public InitIfNeeded ( ) : void
return void
        public void InitIfNeeded()
        {
            if (this.m_CurveLibraryEditorState == null)
            {
                this.m_CurveLibraryEditorState = new PresetLibraryEditorState(GetBasePrefText(this.m_CurveLibraryType));
                this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
            }
            if (this.m_CurveLibraryEditor == null)
            {
                ScriptableObjectSaveLoadHelper<CurvePresetLibrary> helper = new ScriptableObjectSaveLoadHelper<CurvePresetLibrary>(GetExtension(this.m_CurveLibraryType), SaveType.Text);
                this.m_CurveLibraryEditor = new PresetLibraryEditor<CurvePresetLibrary>(helper, this.m_CurveLibraryEditorState, new Action<int, object>(this, (IntPtr) this.ItemClickedCallback));
                this.m_CurveLibraryEditor.addDefaultPresets = (Action<PresetLibrary>) Delegate.Combine(this.m_CurveLibraryEditor.addDefaultPresets, new Action<PresetLibrary>(this.AddDefaultPresetsToLibrary));
                this.m_CurveLibraryEditor.presetsWasReordered = (Action) Delegate.Combine(this.m_CurveLibraryEditor.presetsWasReordered, new Action(this, (IntPtr) this.OnPresetsWasReordered));
                this.m_CurveLibraryEditor.previewAspect = 4f;
                this.m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
                this.m_CurveLibraryEditor.showHeader = true;
            }
        }

Usage Example

Ejemplo n.º 1
0
        void InitCurvePresets()
        {
            if (m_CurvePresets == null)
            {
                // Selection callback for library window
                Action <AnimationCurve> presetSelectedCallback = delegate(AnimationCurve presetCurve)
                {
                    ValidateCurveLibraryTypeAndScale();

                    // Scale curve up using ranges
                    m_Curve.keys         = GetDenormalizedKeys(presetCurve.keys);
                    m_Curve.postWrapMode = presetCurve.postWrapMode;
                    m_Curve.preWrapMode  = presetCurve.preWrapMode;

                    m_CurveEditor.SelectNone();
                    RefreshShownCurves();
                    SendEvent(CurveChangedCommand, true);
                };

                // We set the curve to save when showing the popup to ensure to scale the current state of the curve
                AnimationCurve curveToSaveAsPreset = null;
                m_CurvePresets = new CurvePresetsContentsForPopupWindow(curveToSaveAsPreset, curveLibraryType, presetSelectedCallback);
                m_CurvePresets.InitIfNeeded();
            }
        }