// Copyright (c) 2015 - 2023 Doozy Entertainment. All Rights Reserved. // This code can only be used under the standard Unity Asset Store End User License Agreement // A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms using Doozy.Editor.EditorUI.Components.Internal; using Doozy.Editor.EditorUI.ScriptableObjects.Colors; using Doozy.Runtime.Colors; using Doozy.Runtime.Common.Extensions; using Doozy.Runtime.Reactor.Internal; using Doozy.Runtime.UIElements.Extensions; using UnityEngine.UIElements; // ReSharper disable MemberCanBePrivate.Global namespace Doozy.Editor.EditorUI.Components { public class FluidToggleSwitch : FluidToggle { public override void Reset() { base.Reset(); SetLabelText(string.Empty); iconReaction.SetTextures(EditorSpriteSheets.EditorUI.Components.Switch); } #region LabelType private ToggleLabelType m_LabelType; public ToggleLabelType labelType { get => m_LabelType; set { m_LabelType = value; leftLabel.SetStyleDisplay(labelType == ToggleLabelType.LeftLabel ? DisplayStyle.Flex : DisplayStyle.None); rightLabel.SetStyleDisplay(labelType == ToggleLabelType.RightLabel ? DisplayStyle.Flex : DisplayStyle.None); } } #endregion public TemplateContainer templateContainer { get; } public VisualElement layoutContainer { get; } public Image iconContainer { get; } public Label leftLabel { get; } public Label rightLabel { get; } public static FluidToggleSwitch Get(string labelText, bool value, EditorSelectableColorInfo accentColor, string tooltip = "") => Get().SetLabelText(labelText).SetToggleAccentColor(accentColor).SetIsOn(value).SetTooltip(tooltip); public static FluidToggleSwitch Get(string labelText) => Get(labelText, false, null, string.Empty); public static FluidToggleSwitch Get(bool value, EditorSelectableColorInfo accentColor = null, string tooltip = "") => Get(string.Empty, value, accentColor, tooltip); public static FluidToggleSwitch Get(EditorSelectableColorInfo accentColor, string tooltip = "") => Get(string.Empty, false, accentColor, tooltip); public FluidToggleSwitch() { this.SetStyleFlexShrink(0); Add(templateContainer = EditorLayouts.EditorUI.FluidToggle.CloneTree()); templateContainer .AddStyle(EditorStyles.EditorUI.LayoutContainer) .AddStyle(EditorStyles.EditorUI.FieldName) .AddStyle(EditorStyles.EditorUI.FluidToggle); layoutContainer = templateContainer.Q(nameof(layoutContainer)); iconContainer = layoutContainer.Q(nameof(iconContainer)); icon = iconContainer.Q(nameof(icon)); leftLabel = layoutContainer.Q