#if UNITY_2019_1_OR_NEWER using System; using System.Linq; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; namespace UnityAtoms.Editor { public class GeneratorEditor : EditorWindow { private Generator generator; [MenuItem("Tools/Unity Atoms/Generator")] static void Init() { var window = GetWindow(false, "Generator"); window.position = new Rect(Screen.width / 2, Screen.height / 2, 400, 280); window.Show(); } public static readonly string ACTION = "Action"; public static readonly string CONSTANT = "Constant"; public static readonly string EVENT = "Event"; public static readonly string EVENT_X2 = "Event x 2"; public static readonly string LIST = "List"; public static readonly string LISTENER = "Listener"; public static readonly string REFERENCE = "Reference"; public static readonly string SET_VARIABLE_VALUE = "Set Variable Value (Action)"; public static readonly string UNITY_EVENT = "Unity Event"; public static readonly string VARIABLE = "Variable"; private string _type = ""; private bool _isEquatable = true; private List _atomTypesToGenerate = new List() { AtomTypes.ACTION, AtomTypes.CONSTANT, AtomTypes.EVENT, AtomTypes.EVENT_X2, AtomTypes.LIST, AtomTypes.LISTENER, AtomTypes.REFERENCE, AtomTypes.SET_VARIABLE_VALUE, AtomTypes.UNITY_EVENT, AtomTypes.VARIABLE }; private Dictionary _typeVEDict = new Dictionary(); private VisualElement _typesToGenerateInfoRow; private Dictionary> _dependencies = new Dictionary>() { { AtomTypes.LIST, new List() { AtomTypes.EVENT } }, { AtomTypes.LISTENER, new List() { AtomTypes.ACTION, AtomTypes.EVENT, AtomTypes.UNITY_EVENT } }, { AtomTypes.REFERENCE, new List() { AtomTypes.VARIABLE } }, { AtomTypes.SET_VARIABLE_VALUE, new List() { AtomTypes.VARIABLE, AtomTypes.REFERENCE, AtomTypes.EVENT, AtomTypes.EVENT_X2 } }, { AtomTypes.VARIABLE, new List() { AtomTypes.EVENT, AtomTypes.EVENT_X2 } } }; private void AddAtomTypeToGenerate(AtomType atomType) { _atomTypesToGenerate.Add(atomType); foreach (KeyValuePair> entry in _dependencies) { if (entry.Value.All((atom) => _atomTypesToGenerate.Contains(atom))) { _typeVEDict[entry.Key].SetEnabled(true); } } _typesToGenerateInfoRow.Query