UnityEditor.ColorPicker.InitIfNeeded C# (CSharp) Method

InitIfNeeded() private method

private InitIfNeeded ( ) : void
return void
        private void InitIfNeeded()
        {
            if (styles == null)
            {
                styles = new Styles();
            }
            if (this.m_ColorLibraryEditorState == null)
            {
                this.m_ColorLibraryEditorState = new PresetLibraryEditorState(presetsEditorPrefID);
                this.m_ColorLibraryEditorState.TransferEditorPrefsState(true);
            }
            if (this.m_ColorLibraryEditor == null)
            {
                ScriptableObjectSaveLoadHelper<ColorPresetLibrary> helper = new ScriptableObjectSaveLoadHelper<ColorPresetLibrary>("colors", SaveType.Text);
                this.m_ColorLibraryEditor = new PresetLibraryEditor<ColorPresetLibrary>(helper, this.m_ColorLibraryEditorState, new Action<int, object>(this.PresetClickedCallback));
                this.m_ColorLibraryEditor.previewAspect = 1f;
                this.m_ColorLibraryEditor.minMaxPreviewHeight = new Vector2(14f, 14f);
                this.m_ColorLibraryEditor.settingsMenuRightMargin = 2f;
                this.m_ColorLibraryEditor.useOnePixelOverlappedGrid = true;
                this.m_ColorLibraryEditor.alwaysShowScrollAreaHorizontalLines = false;
                this.m_ColorLibraryEditor.marginsForGrid = new RectOffset(0, 0, 0, 0);
                this.m_ColorLibraryEditor.marginsForList = new RectOffset(0, 5, 2, 2);
                this.m_ColorLibraryEditor.InitializeGrid(233f - (styles.background.padding.left + styles.background.padding.right));
            }
        }

Usage Example

示例#1
0
 public static void Show(GUIView viewToUpdate, Color col, bool showAlpha)
 {
     ColorPicker.get.m_DelegateView = viewToUpdate;
     ColorPicker.color = col;
     ColorPicker.get.m_OriginalColor  = col;
     ColorPicker.get.m_ShowAlpha      = showAlpha;
     ColorPicker.get.m_ModalUndoGroup = Undo.GetCurrentGroup();
     if (ColorPicker.get.m_IsOSColorPicker)
     {
         OSColorPicker.Show(showAlpha);
     }
     else
     {
         ColorPicker get = ColorPicker.get;
         get.title = "Color";
         float y = (float)EditorPrefs.GetInt("CPickerHeight", (int)get.position.height);
         get.minSize = new Vector2(193f, y);
         get.maxSize = new Vector2(193f, y);
         get.InitIfNeeded();
         get.ShowAuxWindow();
     }
 }