// 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 System.Collections.Generic; using Doozy.Editor.Reactor.Internal; using Doozy.Runtime.Common.Extensions; using Doozy.Runtime.Reactor.Extensions; using Doozy.Runtime.Reactor.Internal; using Doozy.Runtime.Reactor.Reactions; using Doozy.Runtime.UIElements.Extensions; using UnityEngine; using UnityEngine.UIElements; // ReSharper disable MemberCanBePrivate.Global namespace Doozy.Editor.EditorUI.Components { public class FluidPlaceholder : PoolableElement { public override void Reset() { this.ResetLayout(); this.SetTooltip(string.Empty); this.SetStyleFlexGrow(0); ClearLabelText(); ResetIcon(); ResetAccentColor(); Show(false); } public override void Dispose() { base.Dispose(); iconReaction?.Recycle(); } private const float ANIMATION_DURATION = 1f; public static Color defaultAccentColor => EditorColors.Default.Placeholder; public static Font defaultFont => EditorFonts.Ubuntu.Light; public static IEnumerable defaultTextures => EditorSpriteSheets.EditorUI.Placeholders.Empty; public Color accentColor { get; private set; } public TemplateContainer templateContainer { get; private set; } public VisualElement layoutContainer { get; private set; } public Image placeholderImage { get; private set; } public Label placeholderLabel { get; private set; } public Texture2DReaction iconReaction { get; private set; } public bool isVisible { get; private set; } public static FluidPlaceholder Get(IEnumerable textures) => Get().SetIcon(textures); public static FluidPlaceholder Get(string labelText, IEnumerable textures) => Get(textures).SetLabelText(labelText); public static FluidPlaceholder Get(string labelText, IEnumerable textures, Color accentColor) => Get(labelText, textures).SetAccentColor(accentColor); public static FluidPlaceholder Get(Texture2D iconTexture2D) => Get().SetIcon(iconTexture2D); public static FluidPlaceholder Get(string labelText, Texture2D iconTexture2D) => Get(iconTexture2D).SetLabelText(labelText); public static FluidPlaceholder Get(string labelText, Texture2D iconTexture2D, Color accentColor) => Get(labelText, iconTexture2D).SetAccentColor(accentColor); public FluidPlaceholder() { // this.SetStyleFlexGrow(1); this.SetStyleFlexShrink(0); this.SetStyleAlignSelf(Align.Center); this.SetStyleJustifyContent(Justify.Center); Add(templateContainer = EditorLayouts.EditorUI.FluidPlaceholder.CloneTree()); templateContainer .AddStyle(EditorStyles.EditorUI.FluidPlaceholder); layoutContainer = templateContainer.Q(nameof(layoutContainer)); placeholderImage = layoutContainer.Q(nameof(placeholderImage)); placeholderLabel = layoutContainer.Q