UnityEditor.EyeDropper.GetLastPickedColor C# (CSharp) Method

GetLastPickedColor() public static method

public static GetLastPickedColor ( ) : Color
return UnityEngine.Color
        public static Color GetLastPickedColor()
        {
            return s_LastPickedColor;
        }

Usage Example

示例#1
0
        private void OnGUI()
        {
            this.InitIfNeeded();
            if (this.m_resetKeyboardControl)
            {
                GUIUtility.keyboardControl  = 0;
                this.m_resetKeyboardControl = false;
            }
            EventType type = Event.current.type;

            if (type == EventType.ExecuteCommand)
            {
                string commandName = Event.current.commandName;
                switch (commandName)
                {
                case "EyeDropperUpdate":
                    base.Repaint();
                    break;

                case "EyeDropperClicked":
                {
                    Color lastPickedColor = EyeDropper.GetLastPickedColor();
                    this.m_R = lastPickedColor.r;
                    this.m_G = lastPickedColor.g;
                    this.m_B = lastPickedColor.b;
                    this.RGBToHSV();
                    this.m_ColorBoxMode = this.m_OldColorBoxMode;
                    this.m_Color        = new Color(this.m_R, this.m_G, this.m_B, this.m_A);
                    this.SendEvent(true);
                    break;
                }

                case "EyeDropperCancelled":
                    base.Repaint();
                    this.m_ColorBoxMode = this.m_OldColorBoxMode;
                    break;
                }
            }
            EditorGUIUtility.labelWidth = 15f;
            EditorGUIUtility.fieldWidth = 30f;
            Rect rect = EditorGUILayout.BeginVertical(ColorPicker.styles.background, new GUILayoutOption[0]);

            EditorGUI.BeginChangeCheck();
            GUILayout.Space(10f);
            this.DoColorSwatchAndEyedropper();
            GUILayout.Space(10f);
            this.DoColorSpaceGUI();
            GUILayout.Space(10f);
            this.DoColorSliders();
            GUILayout.Space(10f);
            if (EditorGUI.EndChangeCheck())
            {
                this.colorChanged = true;
            }
            this.DoPresetsGUI();
            if (this.colorChanged)
            {
                EditorPrefs.SetInt("CPSliderShow", (!this.m_ShowSliders) ? 0 : 1);
                EditorPrefs.SetInt("CPSliderMode", (int)this.m_SliderMode);
                EditorPrefs.SetInt("CPColorShow", (!this.m_ShowColors) ? 0 : 1);
                EditorPrefs.SetInt("CPColorMode", (int)this.m_ColorBoxMode);
            }
            if (this.colorChanged)
            {
                this.colorChanged = false;
                this.m_Color      = new Color(this.m_R, this.m_G, this.m_B, this.m_A);
                this.SendEvent(true);
            }
            EditorGUILayout.EndVertical();
            if (rect.height > 0f)
            {
                this.SetHeight(rect.height);
            }
            if (Event.current.type == EventType.KeyDown)
            {
                KeyCode keyCode = Event.current.keyCode;
                if (keyCode != KeyCode.Return)
                {
                    if (keyCode == KeyCode.Escape)
                    {
                        Undo.RevertAllDownToGroup(this.m_ModalUndoGroup);
                        this.m_Color = this.m_OriginalColor;
                        this.SendEvent(false);
                        base.Close();
                        GUIUtility.ExitGUI();
                        return;
                    }
                    if (keyCode != KeyCode.KeypadEnter)
                    {
                        return;
                    }
                }
                base.Close();
            }
        }