예제 #1
0
        internal static SelectionRenderState GetSelectionRenderState()
        {
                        #if UNITY_5_3 || UNITY_5_4
            return(SelectionRenderState.Wireframe);
                        #else
            bool wireframe = false, outline = false;

            try {
                wireframe = (bool)ReflectionUtility.GetValue(null, "UnityEditor.AnnotationUtility", "showSelectionWire");
                outline   = (bool)ReflectionUtility.GetValue(null, "UnityEditor.AnnotationUtility", "showSelectionOutline");
            } catch {
                Debug.LogWarning("Looks like Unity changed the AnnotationUtility \"showSelectionOutline\"\nPlease email [email protected] and let Karl know!");
            }

            SelectionRenderState state = SelectionRenderState.None;

            if (wireframe)
            {
                state |= SelectionRenderState.Wireframe;
            }
            if (outline)
            {
                state |= SelectionRenderState.Outline;
            }

            return(state);
                        #endif
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            if (target == null)
            {
                return;
            }

            PreferenceDictionary dic = target as PreferenceDictionary;

            if (dic == null)
            {
                return;
            }

            Dictionary <string, bool>   m_bool   = (Dictionary <string, bool>)ReflectionUtility.GetValue(dic, typeof(PreferenceDictionary), "m_bool");
            Dictionary <string, int>    m_int    = (Dictionary <string, int>)ReflectionUtility.GetValue(dic, typeof(PreferenceDictionary), "m_int");
            Dictionary <string, float>  m_float  = (Dictionary <string, float>)ReflectionUtility.GetValue(dic, typeof(PreferenceDictionary), "m_float");
            Dictionary <string, string> m_string = (Dictionary <string, string>)ReflectionUtility.GetValue(dic, typeof(PreferenceDictionary), "m_string");
            Dictionary <string, Color>  m_Color  = (Dictionary <string, Color>)ReflectionUtility.GetValue(dic, typeof(PreferenceDictionary), "m_Color");

            scroll = EditorGUILayout.BeginScrollView(scroll);

            GUILayout.Label("Bool Values", EditorStyles.boldLabel);

            int i = 0;

            if (showBool)
            {
                foreach (var kvp in m_bool)
                {
                    GUI.backgroundColor = i++ % 2 == 0 ? RowEven : RowOdd;
                    GUILayout.BeginHorizontal(PolyGUI.BackgroundColorStyle);
                    GUILayout.Label(kvp.Key);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(kvp.Value.ToString());
                    GUILayout.EndHorizontal();
                }
                GUI.backgroundColor = Color.white;
            }

            GUILayout.Label("Int Values", EditorStyles.boldLabel);

            if (showInt)
            {
                foreach (var kvp in m_int)
                {
                    GUI.backgroundColor = i++ % 2 == 0 ? RowEven : RowOdd;
                    GUILayout.BeginHorizontal(PolyGUI.BackgroundColorStyle);
                    GUILayout.Label(kvp.Key);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(kvp.Value.ToString());
                    GUILayout.EndHorizontal();
                }
                GUI.backgroundColor = Color.white;
            }

            GUILayout.Label("Float Values", EditorStyles.boldLabel);

            if (showFloat)
            {
                foreach (var kvp in m_float)
                {
                    GUI.backgroundColor = i++ % 2 == 0 ? RowEven : RowOdd;
                    GUILayout.BeginHorizontal(PolyGUI.BackgroundColorStyle);
                    GUILayout.Label(kvp.Key);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(kvp.Value.ToString());
                    GUILayout.EndHorizontal();
                }
                GUI.backgroundColor = Color.white;
            }

            GUILayout.Label("String Values", EditorStyles.boldLabel);

            if (showString)
            {
                foreach (var kvp in m_string)
                {
                    GUI.backgroundColor = i++ % 2 == 0 ? RowEven : RowOdd;
                    GUILayout.BeginHorizontal(PolyGUI.BackgroundColorStyle);
                    GUILayout.Label(kvp.Key);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(kvp.Value.ToString());
                    GUILayout.EndHorizontal();
                }
                GUI.backgroundColor = Color.white;
            }

            GUILayout.Label("Color Values", EditorStyles.boldLabel);

            if (showColor)
            {
                foreach (var kvp in m_Color)
                {
                    GUI.backgroundColor = i++ % 2 == 0 ? RowEven : RowOdd;
                    GUILayout.BeginHorizontal(PolyGUI.BackgroundColorStyle);
                    GUILayout.Label(kvp.Key);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(kvp.Value.ToString());
                    GUILayout.EndHorizontal();
                }
                GUI.backgroundColor = Color.white;
            }

            EditorGUILayout.EndScrollView();
        }