// 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.UIElements; using Doozy.Runtime.Mody; using Doozy.Runtime.UIElements.Extensions; using UnityEditor; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements; using EditorStyles = Doozy.Editor.EditorUI.EditorStyles; namespace Doozy.Editor.Mody.Drawers { [CustomPropertyDrawer(typeof(ModyActionRunner), true)] public class ModyActionRunnerDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {} public override VisualElement CreatePropertyGUI(SerializedProperty property) { var modyActionRunner = property.GetTargetObjectOfProperty() as ModyActionRunner; SerializedProperty moduleProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Module)); SerializedProperty actionNameProperty = property.FindPropertyRelative(nameof(ModyActionRunner.ActionName)); SerializedProperty runProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Run)); SerializedProperty ignoreCooldownProperty = property.FindPropertyRelative(nameof(ModyActionRunner.IgnoreCooldown)); SerializedProperty boolValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.BoolValue)); SerializedProperty colorValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.ColorValue)); SerializedProperty doubleValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.DoubleValue)); SerializedProperty floatValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.FloatValue)); SerializedProperty gameObjectValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.GameObjectValue)); SerializedProperty genericValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.GenericValue)); SerializedProperty intValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.IntValue)); SerializedProperty longValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.LongValue)); SerializedProperty monoBehaviourValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.MonoBehaviourValue)); SerializedProperty scriptableObjectValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.ScriptableObjectValue)); SerializedProperty spriteValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.SpriteValue)); SerializedProperty stringValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.StringValue)); SerializedProperty texture2DValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Texture2DValue)); SerializedProperty textureValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.TextureValue)); SerializedProperty vector2ValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Vector2Value)); SerializedProperty vector3ValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Vector3Value)); SerializedProperty vector4ValueProperty = property.FindPropertyRelative(nameof(ModyActionRunner.Vector4Value)); VisualElement layoutContainer; Label moduleNameLabel; ObjectField moduleObjectField; VisualElement actionRow; Label actionNameLabel; VisualElement actionNameContainer; PopupField actionNamesPopupField; VisualElement valueColumn; Label valueLabel; VisualElement valueContainer; Label runLabel; EnumField runEnumField; Label ignoreCooldownLabel; VisualElement ignoreCooldownContainer; ModyAction selectedAction = null; TemplateContainer templateContainer = EditorLayouts.Mody.ModyActionRunner.CloneTree(); layoutContainer = templateContainer.Q(nameof(layoutContainer)); moduleNameLabel = layoutContainer.Q