Exemple #1
0
        private void OnGUI()
        {
            if (_selectedTypeList == null)
            {
                Initialize();
            }

            _selectedTypeList.Render_Basic();

            EditorGUILayout.LabelField("Output", EditorStyles.boldLabel);
            _namespace.Render_Basic();
            _menuPath.Render_Basic();
            GUI.enabled = false;
            string type = EditorGUILayout.TextField(cSelectedTypeTitle, _selectedTypeList.SelectedType?.Name);

            EditorGUILayout.TextField(cEventNameTitle, $"{type?.EnforceFistCharCaptial()}Event");
            EditorGUILayout.TextField(cEventListenerNameTitle, $"{type?.EnforceFistCharCaptial()}EventListener");
            EditorGUILayout.TextField(cUnityEventNameTitle, $"{type?.EnforceFistCharCaptial()}UnityEventListener");
            EditorGUILayout.TextField(cMenuPathTitle, $"{_menuPath.String}/Events");
            GUI.enabled = true;

            if (GUILayout.Button("Save Event"))
            {
                PathString path = new PathString(EditorUtility.SaveFolderPanel("Generation Path", _lastSavePath, type));

                path = path.InsertAtEnd($"{type?.EnforceFistCharCaptial()}.event");
                path.CreateIfNotExistsDirectory();
                _lastSavePath = path.RemoveAtEnd();

                UTEventGeneration.GenerateEventsOfAllTypes(path, type, _namespace.String, $"{_menuPath.String}", _selectedTypeList.SelectedType.Namespace);
                AssetDatabase.Refresh();
            }
        }
        public static void EMGenerateEventsJson(MenuCommand command)
        {
            UnityEngine.Object    obj    = Selection.activeObject;
            TextAsset             asset  = obj as TextAsset;
            EventGenerationTokens tokens = JsonUtility.FromJson <EventGenerationTokens>(asset.text);

            PathString path   = AssetDatabase.GetAssetPath(obj.GetInstanceID());
            PathString folder = path.RemoveAtEnd();

            for (int i = 0; i < tokens.Tokens.Length; i++)
            {
                EventGenerationToken to = tokens.Tokens[i];

                EditorUtility.DisplayProgressBar(
                    "Generating Events",
                    $"Generating {to.Type} Event to {to.Path}",
                    (float)i / tokens.Tokens.Length
                    );

                PathString p = UTECommonFolder.GetFolderPath(ECommonFolder.Assets) + "/" + to.Path;

                UTEventGeneration.GenerateEventsOfAllTypes(
                    UTECommonFolder.GetFolderPath(ECommonFolder.Assets) + "/" + to.Path,
                    to.Type,
                    to.Namespace,
                    to.MenuPath,
                    to.EventTypeNamespace
                    );
            }

            EditorUtility.DisplayProgressBar(
                "Generating Events",
                $"Finalizing and Compiling",
                1f
                );

            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();
        }