// 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; using System.Collections.Generic; using Doozy.Editor.EditorUI; using Doozy.Editor.Reactor.Internal; using Doozy.Editor.Reactor.Ticker; using Doozy.Runtime.Reactor.Easings; using Doozy.Runtime.Reactor.Internal; using Doozy.Runtime.Reactor.Reactions; using Doozy.Runtime.Reactor.Ticker; using Doozy.Runtime.UIElements.Extensions; using UnityEditor; using UnityEngine; using UnityEngine.Events; using UnityEngine.UIElements; // ReSharper disable MemberCanBePrivate.Global namespace Doozy.Editor.Reactor.Components { public class TickerVisualizer : VisualElement, IDisposable { public enum TickerType { Editor, Runtime } private TickerType m_TickerType = TickerType.Runtime; private TemplateContainer templateContainer { get; } public VisualElement layoutContainer { get; } public VisualElement reactorIconContainer { get; } public Image reactorIconImage { get; } public VisualElement heartIconContainer { get; } public Image heartIconImage { get; } public VisualElement labelsContainer { get; } public Label tickerNameLabel { get; } public Label stateLabel { get; } public Texture2DReaction reactorIconReaction { get; } public Texture2DReaction heartIconReaction { get; } private List heartIconTextures { get; set; } public static Color backgroundNormalColor => EditorColors.Default.WindowHeaderBackground; public static Color backgroundHoverColor => EditorGUIUtility.isProSkin ? backgroundNormalColor * reactorColor : backgroundNormalColor + reactorColor * 0.3f; public static Color reactorColor => EditorColors.Reactor.Red; public static Color disabledIconColor => EditorColors.Default.Placeholder; public static Color tickerNameTextColor => EditorColors.Default.TextTitle; public static Color stateTextColor => EditorColors.Default.TextSubtitle; public static Font tickerNameFont => EditorFonts.Ubuntu.Regular; public static Font stateFont => EditorFonts.Ubuntu.Medium; public UnityAction OnClick; private TickService service { get; set; } private bool isConnected => service != null; private bool isActive => m_TickerType == TickerType.Editor || EditorApplication.isPlaying; private IVisualElementScheduledItem m_Refresher; public TickerVisualizer(TickerType tickerType, UnityAction onClick) { this.SetStyleFlexGrow(1); Add(templateContainer = EditorLayouts.Reactor.TickerVisualizer.CloneTree()); templateContainer .SetStyleFlexGrow(1) .AddStyle(EditorUI.EditorStyles.Reactor.TickerVisualizer); layoutContainer = templateContainer.Q("LayoutContainer"); reactorIconContainer = layoutContainer.Q("ReactorIconContainer"); reactorIconImage = reactorIconContainer.Q("ReactorIcon"); heartIconContainer = layoutContainer.Q("HeartIconContainer"); heartIconImage = heartIconContainer.Q("HeartIcon"); labelsContainer = layoutContainer.Q("LabelsContainer"); tickerNameLabel = labelsContainer.Q