// 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.Common.Extensions; using Doozy.Editor.EditorUI; using Doozy.Editor.EditorUI.Components; using Doozy.Editor.EditorUI.Utils; using Doozy.Editor.Reactor.Internal; using Doozy.Runtime.Colors; using Doozy.Runtime.Common.Extensions; using Doozy.Runtime.Reactor.Extensions; using Doozy.Runtime.Reactor.Reactions; using Doozy.Runtime.UIElements.Extensions; using UnityEditor; using UnityEngine; using UnityEngine.Events; using UnityEngine.UIElements; using EditorStyles = Doozy.Editor.EditorUI.EditorStyles; using Object = UnityEngine.Object; // ReSharper disable MemberCanBePrivate.Global namespace Doozy.Editor.Reactor.Components { /// Texture2D Animation Info VisualElement public class Texture2DAnimationInfo : VisualElement, IDisposable { public TemplateContainer templateContainer { get; } public VisualElement layoutContainer { get; } public VisualElement content { get; } public Image previewImageContainer { get; } public Image previewImage { get; } public VisualElement detailsContainer { get; } public Label animationName { get; } public Label numberOfFrames { get; } public Label textureSize { get; } public VisualElement playerContainer { get; } public Label pathLabel { get; } public Texture2DReaction reaction { get; private set; } public FluidButton playForwardButton { get; private set; } public FluidButton playReversedButton { get; private set; } public FluidButton setTextureButton { get; private set; } public Slider playerSlider { get; private set; } public SerializedProperty arrayProperty { get; } public Texture2D spriteSheet { get; set; } public int frameCount => arrayProperty?.arraySize ?? 0; public Texture2D firstTexture { get { if (frameCount <= 0) return null; Object objectReferenceValue = arrayProperty.GetArrayElementAtIndex(0).objectReferenceValue; return (Texture2D)objectReferenceValue; } } private const float PLAYER_SPACING = DesignUtils.k_Spacing * 0.5f; public UnityAction textureSetter { get; set; } public void Dispose() { reaction?.Recycle(); playForwardButton?.Recycle(); playReversedButton?.Recycle(); setTextureButton?.Recycle(); } public Texture2DAnimationInfo(SerializedProperty arrayProperty, Texture2D spriteSheet) { this.arrayProperty = arrayProperty; this.spriteSheet = spriteSheet; Add(templateContainer = EditorLayouts.Reactor.AnimationInfo.CloneTree()); templateContainer .AddStyle(EditorStyles.Reactor.AnimationInfo); layoutContainer = templateContainer.Q(nameof(layoutContainer)); content = layoutContainer.Q(nameof(content)); previewImageContainer = content.Q(nameof(previewImageContainer)); previewImage = previewImageContainer.Q(nameof(previewImage)); detailsContainer = content.Q(nameof(detailsContainer)); animationName = detailsContainer.Q