예제 #1
0
    private static void ToggleLabels(bool on, LabelId label)
    {
        toggleLabels = on;

        var list = Selection.gameObjects;

        foreach (var sp in list)
        {
            if (!toggleLabels)
            {
                ClearLabelOrIcon(sp.gameObject);
            }
            else
            {
                // Add label to base object.
                AssignLabel(sp.gameObject, label);
            }
        }

        if (on)
        {
            lastUsedLabel = label;
//			lastUsedIsIcon = false;
        }
    }
예제 #2
0
        public static void DrawFontAssetProperties(ThemeData themeData, int propertyIndex,
                                                   SerializedObject serializedObject, Object[] targets, ThemeTarget target,
                                                   ColorName componentColorName, Color initialGUIColor)
        {
            GUIStyle buttonStyleDisabled = Styles.GetStyle(Styles.StyleName.CheckBoxDisabled);
            GUIStyle buttonStyleEnabled  = Styles.GetStyle(Styles.StyleName.CheckBoxEnabled);

#if dUI_TextMeshPro
            if (themeData.FontAssetLabels.Count != themeData.ActiveVariant.FontAssets.Count)
            {
                foreach (LabelId labelId in themeData.FontAssetLabels.Where(labelId => !themeData.ActiveVariant.ContainsFontAsset(labelId.Id)))
                {
                    themeData.ActiveVariant.AddFontAssetProperty(labelId.Id);
                }
            }
#endif

            for (int i = 0; i < themeData.FontAssetLabels.Count; i++)
            {
                LabelId fontAssetProperty = themeData.FontAssetLabels[i];
                int     index             = i;
                bool    selected          = i == propertyIndex;
                GUILayout.BeginHorizontal();
                {
                    GUI.color = DGUI.Colors.PropertyColor(componentColorName);
                    if (GUILayout.Button(GUIContent.none, selected ? buttonStyleEnabled : buttonStyleDisabled))
                    {
                        if (serializedObject.isEditingMultipleObjects)
                        {
                            DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                            foreach (Object o in targets)
                            {
                                var themeTarget = (ThemeTarget)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }
                                themeTarget.PropertyId = themeData.FontAssetLabels[index].Id;
                                themeTarget.UpdateTarget(themeData);
                            }
                        }
                        else
                        {
                            DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                            target.PropertyId = themeData.FontAssetLabels[index].Id;
                            target.UpdateTarget(themeData);
                        }
                    }

                    GUI.color = initialGUIColor;
                    GUILayout.Space(DGUI.Properties.Space(2));
                    GUI.enabled = selected;
                    DGUI.Label.Draw(fontAssetProperty.Label, selected ? Size.L : Size.M);
                    GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(DGUI.Properties.Space());
            }
        }
예제 #3
0
        public void LabelIdValueInequalityTest1()
        {
            var id1 = Guid.NewGuid();

            var label1 = new LabelId(id1);
            var label2 = new LabelId(Guid.NewGuid());

            label2.Should().NotBe(label1);
            label2.Should().NotBeEquivalentTo(label1);
        }
예제 #4
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = LabelId != null?LabelId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (LabelName != null ? LabelName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (HexColor != null ? HexColor.GetHashCode() : 0);
                return(hashCode);
            }
        }
        public static void DrawColorProperties(ThemeData themeData, int propertyIndex,
                                               SerializedObject serializedObject, Object[] targets, ThemeTarget target,
                                               Color initialGUIColor)
        {
            GUIStyle colorButtonStyle         = Styles.GetStyle(Styles.StyleName.ColorButton);
            GUIStyle colorButtonSelectedStyle = Styles.GetStyle(Styles.StyleName.ColorButtonSelected);

            for (int i = 0; i < themeData.ColorLabels.Count; i++)
            {
                LabelId colorProperty = themeData.ColorLabels[i];
                int     index         = i;
                bool    selected      = i == propertyIndex;
                GUILayout.BeginHorizontal();
                {
                    if (!selected)
                    {
                        GUILayout.Space((colorButtonSelectedStyle.fixedWidth - colorButtonStyle.fixedWidth) / 2);
                    }
                    GUI.color = themeData.ActiveVariant.Colors[i].Color;
                    {
                        if (GUILayout.Button(GUIContent.none, selected ? colorButtonSelectedStyle : colorButtonStyle))
                        {
                            if (serializedObject.isEditingMultipleObjects)
                            {
                                DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                                foreach (Object o in targets)
                                {
                                    var themeTarget = (ThemeTarget)o;
                                    if (themeTarget == null)
                                    {
                                        continue;
                                    }
                                    themeTarget.PropertyId = themeData.ColorLabels[index].Id;
                                    themeTarget.UpdateTarget(themeData);
                                }
                            }
                            else
                            {
                                DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                                target.PropertyId = themeData.ColorLabels[index].Id;
                                target.UpdateTarget(themeData);
                            }
                        }
                    }
                    GUI.color = initialGUIColor;
                    GUILayout.Space(DGUI.Properties.Space(2));
                    GUI.enabled = selected;
                    DGUI.Label.Draw(colorProperty.Label, selected ? Size.L : Size.M, selected ? colorButtonSelectedStyle.fixedHeight : colorButtonStyle.fixedHeight);
                    GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(DGUI.Properties.Space());
            }
        }
예제 #6
0
        internal void ToXml(XmlWriter writer, string element)
        {
            writer.WriteStartElement(element);
            writer.WriteAttributeString("date", LastModifiedDate.ToString("s"));
            writer.WriteAttributeString("name", Name);

            if (!String.IsNullOrEmpty(OwnerName))
            {
                writer.WriteAttributeString("owner", OwnerName);
            }
            if (!String.IsNullOrEmpty(Scope))
            {
                writer.WriteAttributeString("scope", Scope);
            }

            writer.WriteAttributeString("lid", LabelId.ToString());
            writer.WriteEndElement();
        }
예제 #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (UserId != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (ClockId != 0)
            {
                hash ^= ClockId.GetHashCode();
            }
            if (Hour != 0)
            {
                hash ^= Hour.GetHashCode();
            }
            if (Minute != 0)
            {
                hash ^= Minute.GetHashCode();
            }
            if (LabelId != 0)
            {
                hash ^= LabelId.GetHashCode();
            }
            if (SetTime != 0L)
            {
                hash ^= SetTime.GetHashCode();
            }
            if (OpenState != 0)
            {
                hash ^= OpenState.GetHashCode();
            }
            if (TipState != 0)
            {
                hash ^= TipState.GetHashCode();
            }
            return(hash);
        }
예제 #8
0
        private void DrawViewThemesViewProperties(ThemeData themeData, int selectedThemeTabIndex)
        {
#if !dUI_TextMeshPro
            if (selectedThemeTabIndex == FONT_ASSET_TAB_INDEX)
            {
                selectedThemeTabIndex = COLOR_TAB_INDEX;
                return;
            }
#endif

            Guid           deleteGuid              = Guid.Empty;
            List <LabelId> propertyList            = new List <LabelId>();
            string         addPropertyButtonName   = "+";
            Action         addPropertyButtonAction = () => { };

            switch (selectedThemeTabIndex)
            {
            case COLOR_TAB_INDEX:
                propertyList            = themeData.ColorLabels;
                addPropertyButtonName   = UILabels.NewColor;
                addPropertyButtonAction = () => { themeData.AddColorProperty(true); };
                break;

            case SPRITE_TAB_INDEX:
                propertyList            = themeData.SpriteLabels;
                addPropertyButtonName   = UILabels.NewSprite;
                addPropertyButtonAction = () => { themeData.AddSpriteProperty(true); };
                break;

            case TEXTURE_TAB_INDEX:
                propertyList            = themeData.TextureLabels;
                addPropertyButtonName   = UILabels.NewTexture;
                addPropertyButtonAction = () => { themeData.AddTextureProperty(true); };
                break;

            case FONT_TAB_INDEX:
                propertyList            = themeData.FontLabels;
                addPropertyButtonName   = UILabels.NewFont;
                addPropertyButtonAction = () => { themeData.AddFontProperty(true); };
                break;

#if dUI_TextMeshPro
            case FONT_ASSET_TAB_INDEX:
                propertyList            = themeData.FontAssetLabels;
                addPropertyButtonName   = UILabels.NewFontAsset;
                addPropertyButtonAction = () => { themeData.AddFontAssetProperty(true); };
                break;
#endif
            }


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

            for (int propertyIndex = 0; propertyIndex < propertyList.Count; propertyIndex++)
            {
                GUILayout.BeginVertical(GUILayout.Height(GetThemePropertyRowHeight(selectedThemeTabIndex)));
                {
                    GUILayout.FlexibleSpace();

                    GUILayout.BeginHorizontal(GUILayout.Width(m_themePropertyColumnWidth));
                    {
                        if (EditMode.faded > 0.01f)
                        {
                            GUILayout.Space(DGUI.Properties.Space(1 - EditMode.faded));

                            if (DGUI.Button.IconButton.Minus())
                            {
                                deleteGuid = propertyList[propertyIndex].Id;
                            }

                            GUILayout.Space(DGUI.Properties.Space(2 * (1 - EditMode.faded)));

                            EditorGUI.BeginChangeCheck();
                            string label = EditorGUILayout.TextField(propertyList[propertyIndex].Label,
                                                                     GUILayout.Width(m_themePropertyColumnWidth - DGUI.Properties.Space(4) - DGUI.Sizes.ICON_BUTTON_SIZE));
                            if (EditorGUI.EndChangeCheck())
                            {
                                themeData.UndoRecord(UILabels.UpdateValue);
                                propertyList[propertyIndex] = new LabelId(propertyList[propertyIndex].Id, label);
                                themeData.SetDirty(false);
                            }
                        }
                        else
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(m_themePropertyColumnWidth));
                            {
                                GUILayout.Space(DGUI.Properties.Space(2));
                                DGUI.Label.Draw(propertyList[propertyIndex].Label, Size.L, TextAlign.Left, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2));
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.FlexibleSpace();
                    GUILayout.Space(DGUI.Properties.Space());
                    DrawHorizontalDivider();
                    GUILayout.Space(DGUI.Properties.Space());
                }
                GUILayout.EndVertical();
            }

            DrawAddPropertyButton(addPropertyButtonName, addPropertyButtonAction);

            if (deleteGuid == Guid.Empty)
            {
                return;
            }
            switch (selectedThemeTabIndex)
            {
            case COLOR_TAB_INDEX:
                themeData.RemoveColorProperty(deleteGuid, true, false);
                break;

            case SPRITE_TAB_INDEX:
                themeData.RemoveSpriteProperty(deleteGuid, true, false);
                break;

            case TEXTURE_TAB_INDEX:
                themeData.RemoveTextureProperty(deleteGuid, true, false);
                break;

            case FONT_TAB_INDEX:
                themeData.RemoveFontProperty(deleteGuid, true, false);
                break;

#if dUI_TextMeshPro
            case FONT_ASSET_TAB_INDEX:
                themeData.RemoveFontAssetProperty(deleteGuid, true, false);
                break;
#endif
            }
        }
예제 #9
0
        private void DrawColorProperties(ThemeData themeData, int propertyIndex, SelectionState selectionState)
        {
            GUIStyle colorButtonStyle         = Styles.GetStyle(Styles.StyleName.ColorButton);
            GUIStyle colorButtonSelectedStyle = Styles.GetStyle(Styles.StyleName.ColorButtonSelected);

            if (themeData.ColorLabels.Count != themeData.ActiveVariant.Colors.Count)
            {
                foreach (LabelId labelId in themeData.ColorLabels.Where(labelId => !themeData.ActiveVariant.ContainsColor(labelId.Id)))
                {
                    themeData.ActiveVariant.AddColorProperty(labelId.Id);
                }
            }

            for (int i = 0; i < themeData.ColorLabels.Count; i++)
            {
                LabelId colorProperty = themeData.ColorLabels[i];
                int     index         = i;
                bool    selected      = i == propertyIndex;
                GUILayout.BeginHorizontal();
                {
                    if (!selected)
                    {
                        GUILayout.Space((colorButtonSelectedStyle.fixedWidth - colorButtonStyle.fixedWidth) / 2);
                    }
                    GUI.color = themeData.ActiveVariant.Colors[i].Color;
                    {
                        if (GUILayout.Button(GUIContent.none, selected ? colorButtonSelectedStyle : colorButtonStyle))
                        {
                            if (serializedObject.isEditingMultipleObjects)
                            {
                                DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                                foreach (Object o in targets)
                                {
                                    var themeTarget = (ColorTargetSelectable)o;
                                    if (themeTarget == null)
                                    {
                                        continue;
                                    }
                                    switch (selectionState)
                                    {
                                    case SelectionState.Normal:
                                        themeTarget.NormalColorPropertyId = themeData.ColorLabels[index].Id;
                                        break;

                                    case SelectionState.Highlighted:
                                        themeTarget.HighlightedColorPropertyId = themeData.ColorLabels[index].Id;
                                        break;

                                    case SelectionState.Pressed:
                                        themeTarget.PressedColorPropertyId = themeData.ColorLabels[index].Id;
                                        break;

#if UNITY_2019_1_OR_NEWER
                                    case SelectionState.Selected:
                                        themeTarget.SelectedColorPropertyId = themeData.ColorLabels[index].Id;
                                        break;
#endif
                                    case SelectionState.Disabled:
                                        themeTarget.DisabledColorPropertyId = themeData.ColorLabels[index].Id;
                                        break;
                                    }

                                    themeTarget.UpdateTarget(themeData);
                                }
                            }
                            else
                            {
                                DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                                switch (selectionState)
                                {
                                case SelectionState.Normal:
                                    Target.NormalColorPropertyId = themeData.ColorLabels[index].Id;
                                    break;

                                case SelectionState.Highlighted:
                                    Target.HighlightedColorPropertyId = themeData.ColorLabels[index].Id;
                                    break;

                                case SelectionState.Pressed:
                                    Target.PressedColorPropertyId = themeData.ColorLabels[index].Id;
                                    break;

#if UNITY_2019_1_OR_NEWER
                                case SelectionState.Selected:
                                    Target.SelectedColorPropertyId = themeData.ColorLabels[index].Id;
                                    break;
#endif
                                case SelectionState.Disabled:
                                    Target.DisabledColorPropertyId = themeData.ColorLabels[index].Id;
                                    break;
                                }

                                Target.UpdateTarget(themeData);
                            }
                        }
                    }
                    GUI.color = InitialGUIColor;
                    GUILayout.Space(DGUI.Properties.Space(2));
                    GUI.enabled = selected;
                    DGUI.Label.Draw(colorProperty.Label, selected ? Size.L : Size.M,
                                    selected ? colorButtonSelectedStyle.fixedHeight : colorButtonStyle.fixedHeight);
                    GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(DGUI.Properties.Space());
            }
        }
예제 #10
0
 public static void AssignLabel(GameObject g, LabelId id)
 {
     AssignLabel(g, (int)id);
 }
        private void DrawSpriteProperties(ThemeData themeData, int propertyIndex, ThemeTargetEditorUtils.SelectionState selectionState)
        {
            GUIStyle buttonStyleDisabled = Styles.GetStyle(Styles.StyleName.CheckBoxDisabled);
            GUIStyle buttonStyleEnabled  = Styles.GetStyle(Styles.StyleName.CheckBoxEnabled);

            for (var i = 0; i < themeData.SpriteLabels.Count; i++)
            {
                LabelId spriteProperty = themeData.SpriteLabels[i];
                int     index          = i;
                bool    selected       = i == propertyIndex;
                GUILayout.BeginHorizontal();
                {
                    GUI.color = DGUI.Colors.PropertyColor(ComponentColorName);
                    if (GUILayout.Button(GUIContent.none, selected ? buttonStyleEnabled : buttonStyleDisabled))
                    {
                        if (serializedObject.isEditingMultipleObjects)
                        {
                            DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                            foreach (Object o in targets)
                            {
                                var themeTarget = (SpriteTargetSelectable)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }
                                switch (selectionState)
                                {
                                case ThemeTargetEditorUtils.SelectionState.Highlighted:
                                    themeTarget.HighlightedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                    break;

                                case ThemeTargetEditorUtils.SelectionState.Pressed:
                                    themeTarget.PressedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                    break;

#if UNITY_2019_3_OR_NEWER
                                case ThemeTargetEditorUtils.SelectionState.Selected:
                                    themeTarget.SelectedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                    break;
#endif
                                case ThemeTargetEditorUtils.SelectionState.Disabled:
                                    themeTarget.DisabledSpritePropertyId = themeData.SpriteLabels[index].Id;
                                    break;
                                }

                                themeTarget.UpdateTarget(themeData);
                            }
                        }
                        else
                        {
                            DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                            switch (selectionState)
                            {
                            case ThemeTargetEditorUtils.SelectionState.Highlighted:
                                Target.HighlightedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                break;

                            case ThemeTargetEditorUtils.SelectionState.Pressed:
                                Target.PressedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                break;

#if UNITY_2019_3_OR_NEWER
                            case ThemeTargetEditorUtils.SelectionState.Selected:
                                Target.SelectedSpritePropertyId = themeData.SpriteLabels[index].Id;
                                break;
#endif
                            case ThemeTargetEditorUtils.SelectionState.Disabled:
                                Target.DisabledSpritePropertyId = themeData.SpriteLabels[index].Id;
                                break;
                            }

                            Target.UpdateTarget(themeData);
                        }
                    }

                    GUI.color = InitialGUIColor;
                    GUILayout.Space(DGUI.Properties.Space(2));
                    GUI.enabled = selected;
                    DGUI.Label.Draw(spriteProperty.Label, selected ? Size.L : Size.M);
                    GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(DGUI.Properties.Space());
            }
        }