Beispiel #1
0
        private void UpdateIds()
        {
            if (!Database.Contains(Target.ThemeId))
            {
                Target.ThemeId = Database.Themes[0].Id;
            }
            m_theme = Database.GetThemeData(Target.ThemeId);

            //NormalColorPropertyId
            if (!m_theme.ContainsColorProperty(Target.NormalColorPropertyId))
            {
                Target.NormalColorPropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }

            //HighlightedColorPropertyId
            if (!m_theme.ContainsColorProperty(Target.HighlightedColorPropertyId))
            {
                Target.HighlightedColorPropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }

            //PressedColorPropertyId
            if (!m_theme.ContainsColorProperty(Target.PressedColorPropertyId))
            {
                Target.PressedColorPropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }

#if UNITY_2019_1_OR_NEWER
            //SelectedColorPropertyId
            if (!m_theme.ContainsColorProperty(Target.SelectedColorPropertyId))
            {
                Target.SelectedColorPropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }
#endif

            //DisabledColorPropertyId
            if (!m_theme.ContainsColorProperty(Target.DisabledColorPropertyId))
            {
                Target.DisabledColorPropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }
        }
Beispiel #2
0
        private void UpdateIds()
        {
            if (!Database.Contains(Target.ThemeId))
            {
                Target.ThemeId = Database.Themes[0].Id;
            }
            m_theme = Database.GetThemeData(Target.ThemeId);

            if (!m_theme.ContainsColorProperty(Target.PropertyId))
            {
                Target.PropertyId = m_theme.ColorLabels.Count > 0
                                        ? m_theme.ColorLabels[0].Id
                                        : Guid.Empty;
            }
        }
        public static void DrawThemePopup(ThemesDatabase database, ThemeData themeData, string[] themeNames, int themeIndex,
                                          ColorName componentColorName, SerializedObject serializedObject, Object[] targets, ThemeTarget target, Color initialGUIColor,
                                          Action updateIds, Action updateLists)
        {
            GUILayout.BeginHorizontal();
            {
                DGUI.Line.Draw(false, componentColorName, true,
                               () =>
                {
                    GUILayout.Space(DGUI.Properties.Space(2));
                    DGUI.Label.Draw(UILabels.SelectedTheme, Size.S, componentColorName, DGUI.Properties.SingleLineHeight);
                    GUILayout.Space(DGUI.Properties.Space());
                    GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight));
                    {
                        GUILayout.Space(0);
                        GUI.color = DGUI.Colors.PropertyColor(componentColorName);
                        EditorGUI.BeginChangeCheck();
                        themeIndex = EditorGUILayout.Popup(GUIContent.none, themeIndex, themeNames);
                        GUI.color  = initialGUIColor;
                    }
                    GUILayout.EndVertical();
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (serializedObject.isEditingMultipleObjects)
                        {
                            DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                            themeData = database.Themes[themeIndex];
                            foreach (Object o in targets)
                            {
                                var themeTarget = (ThemeTarget)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }
                                themeTarget.ThemeId = themeData.Id;
                            }

                            updateIds.Invoke();
                            updateLists.Invoke();

                            foreach (Object o in targets)
                            {
                                var themeTarget = (ThemeTarget)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }

                                if (!themeData.ContainsColorProperty(themeTarget.PropertyId))
                                {
                                    themeTarget.PropertyId = themeData.ColorLabels.Count > 0
                                                                                ? themeData.ColorLabels[0].Id
                                                                                : Guid.Empty;
                                }

                                themeTarget.UpdateTarget(themeData);
                            }
                        }
                        else
                        {
                            DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                            themeData      = database.Themes[themeIndex];
                            target.ThemeId = themeData.Id;
                            updateIds.Invoke();
                            updateLists.Invoke();
                            target.UpdateTarget(themeData);
                        }
                    }
                });

                GUILayout.Space(DGUI.Properties.Space());

                ThemeTargetEditorUtils.DrawButtonTheme(themeData, componentColorName);
            }
            GUILayout.EndHorizontal();
        }