public virtual void OnDoubleClickItem(string test, Rect r)
 {
     if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2 && r.Contains(Event.current.mousePosition))
     {
         AIEditorWindow.Init((AIController)target);
     }
 }
예제 #2
0
 public override void OnInspectorGUI()
 {
     if (GUILayout.Button("Open A.I. Editor"))
     {
         AIEditorWindow.Init();
     }
 }
예제 #3
0
        internal static void ShowBlankCanvasMenu(Vector2 mousePos)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("New AI"), false, () => AIEditorWindow.NewInActive());
            menu.AddItem(new GUIContent("Load AI"), false, () => AIEditorWindow.LoadInActive(mousePos));

            menu.ShowAsContext();
        }
예제 #4
0
	public static void Init (AIController controller)
	{
		editor = (AIEditorWindow)EditorWindow.GetWindow (typeof(AIEditorWindow));
		editor.controller = controller;
		editor.title = controller.name;
		State state = editor.controller.states.Find (x => x.GetType() == typeof(AnyState));
		if (state == null) {
			editor.OnCreateStateCallback(new object[]{typeof(AnyState),new Vector2(editor.position.center.x-Node.kNodeWidth*0.5f,editor.position.center.y)});
		}
		editor.selectedState = editor.controller.states.Find (x => x.GetType() == typeof(AnyState));
	}
    public static void Init(AIController controller)
    {
        editor            = (AIEditorWindow)EditorWindow.GetWindow(typeof(AIEditorWindow));
        editor.controller = controller;
        editor.title      = controller.name;
        State state = editor.controller.states.Find(x => x.GetType() == typeof(AnyState));

        if (state == null)
        {
            editor.OnCreateStateCallback(new object[] { typeof(AnyState), new Vector2(editor.position.center.x - Node.kNodeWidth * 0.5f, editor.position.center.y) });
        }
        editor.selectedState = editor.controller.states.Find(x => x.GetType() == typeof(AnyState));
    }
예제 #6
0
        public override void OnInspectorGUI()
        {
            var ai = (AIStorage)this.target;

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Apex AI: " + ai.name);

            this.serializedObject.Update();
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(_description);
            this.serializedObject.ApplyModifiedProperties();

            if (GUILayout.Button("Open"))
            {
                AIEditorWindow.Open(ai.aiId);
            }

            EditorGUILayout.Separator();
            _debug = EditorGUILayout.ToggleLeft("Show debug options", _debug);
            if (_debug)
            {
                if (GUILayout.Button("Copy AI Configuration to clipboard"))
                {
                    try
                    {
                        var json    = new StringBuilder();
                        var aiData  = SerializationMaster.Deserialize(ai.configuration);
                        var guiData = SerializationMaster.Deserialize(ai.editorConfiguration);
                        json.AppendLine(SerializationMaster.Serialize(aiData, true));
                        json.AppendLine(SerializationMaster.Serialize(guiData, true));
                        EditorGUIUtility.systemCopyBuffer = json.ToString();
                    }
                    catch
                    {
                        EditorUtility.DisplayDialog("Error", "Copying failed, unable to read AI Configuration.", "OK");
                    }
                }
            }
        }
예제 #7
0
 public static void init()
 {
     AIEditorWindow window = (AIEditorWindow)EditorWindow.GetWindow(typeof(AIEditorWindow));
 }
예제 #8
0
 public static void OpenEditor()
 {
     AIEditorWindow.Open();
 }
예제 #9
0
        private bool DrawAIItem(int idx)
        {
            var result    = false;
            var isPlaying = Application.isPlaying;
            var aiCfg     = _target.aiConfigs[idx];

            // Item Header
            EditorGUILayout.BeginHorizontal(SharedStyles.BuiltIn.listItemHeader);

            var isActive = EditorGUILayout.ToggleLeft(string.Empty, aiCfg.isActive);

            if (isActive != aiCfg.isActive)
            {
                _target.ToggleActive(idx, isActive);
                EditorUtility.SetDirty(_target);

                //We want the visualizer to update
                AIEditorWindow.UpdateVisualizedEntities();
            }

            if (GUILayout.Button(_openAITooltip, EditorStyling.Skinned.viewButtonSmall))
            {
                GUI.changed = false;

                AIEditorWindow.Open(aiCfg.aiId);
                Selection.activeGameObject = _target.gameObject;
            }

            GUILayout.Space(4f);
            if (!isPlaying && GUILayout.Button(SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
            {
                result = true;

                // We do not want the button click itself to count as a change. Since no other changes are expected when a button click is encountered, we can just set it to false.
                GUI.changed = false;
            }

            EditorGUILayout.EndHorizontal();

            // Item fields
            GUI.enabled = !isPlaying;
            DrawAISelector(idx);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(_intervalLabel, GUILayout.Width(80f));
            aiCfg.intervalMin = _target.FloatField(aiCfg.intervalMin, null, GUILayout.Width(40f));
            EditorGUILayout.LabelField("to", GUILayout.Width(20f));
            aiCfg.intervalMax = _target.FloatField(aiCfg.intervalMax, null, GUILayout.Width(40f));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(_delayLabel, GUILayout.Width(80f));
            aiCfg.startDelayMin = _target.FloatField(aiCfg.startDelayMin, null, GUILayout.Width(40f));
            EditorGUILayout.LabelField("to", GUILayout.Width(20f));
            aiCfg.startDelayMax = _target.FloatField(aiCfg.startDelayMax, null, GUILayout.Width(40f));
            EditorGUILayout.EndHorizontal();

            GUI.enabled = true;

            EditorGUILayout.Separator();

            return(result);
        }
예제 #10
0
        private void DrawSummary()
        {
            var summary = new StringBuilder("You can now finalize the repair.");

            if (_utility.customRepairsMade)
            {
                summary.AppendLine();
                summary.AppendLine();
                summary.Append("Custom repairs are ready to be applied.");
            }

            summary.AppendLine();
            summary.AppendLine();
            if (_status.unresolvedTypesCount == 0)
            {
                summary.Append("No unresolved types were detected.");
            }
            else
            {
                summary.AppendFormat("{0}/{1} unresolved types have been resolved.", _status.resolvedTypesCount, _status.unresolvedTypesCount);
            }

            summary.AppendLine();
            summary.AppendLine();
            if (_status.unresolvedMembersCount == 0)
            {
                summary.Append("No unresolved members were detected.");
            }
            else
            {
                summary.AppendFormat("{0}/{1} unresolved members have been resolved.", _status.resolvedMembersCount, _status.unresolvedMembersCount);
            }

            summary.AppendLine();
            summary.AppendLine();
            if (_status.unresolvedMismatchesCount == 0)
            {
                summary.Append("No mismatches were detected.");
            }
            else
            {
                if (_status.resolvableMismatchesCount > 0)
                {
                    summary.AppendFormat("{0}/{1} mismatches have been resolved.", _status.resolvedMismatchesCount, _status.resolvableMismatchesCount);
                }

                if (_status.unresolvedMismatchesCount > _status.resolvableMismatchesCount)
                {
                    if (_status.resolvableMismatchesCount > 0)
                    {
                        summary.Append(" An additional ");
                    }

                    summary.AppendFormat("{0} unresolvable mismatches will be corrected to their default value.", _status.unresolvedMismatchesCount - _status.resolvableMismatchesCount);
                }
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Summary", EditorStyling.Skinned.boldTitle);
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField(summary.ToString(), SharedStyles.BuiltIn.wrappedText);
            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Back"))
            {
                if (_status.unresolvedMismatchesCount > 0)
                {
                    _step = Step.Mismatch;
                }
                else if (_status.unresolvedMembersCount > 0)
                {
                    _step = Step.Members;
                }
                else if (_status.unresolvedTypesCount > 0)
                {
                    _step = Step.Types;
                }
                else
                {
                    ToStart();
                }
            }

            if (GUILayout.Button("Complete"))
            {
                var message = new StringBuilder();
                if (_status.unresolvedTypesCount > _status.resolvedTypesCount)
                {
                    message.AppendLine("There are still unresolved types, these will be removed if you complete the repair.");
                }

                if (_status.unresolvedMembersCount > _status.resolvedMembersCount)
                {
                    message.AppendLine();
                    message.AppendLine("There are still unresolved members, these will be removed if you complete the repair.");
                }

                if (_status.resolvableMismatchesCount > _status.resolvedMismatchesCount)
                {
                    message.AppendLine();
                    message.AppendLine("There are still unresolved mismatches, these will be removed if you complete the repair.");
                }

                message.AppendLine();
                message.AppendLine("Do you wish to apply the repair?");

                if (EditorUtility.DisplayDialog("Confirm Repair", message.ToString(), "Yes", "No"))
                {
                    _working = true;

                    EditorAsync.Execute(
                        _utility.ExecuteRepairs,
                        () =>
                    {
                        _utility.SaveChanges();
                        Debug.Log("Repair Complete.");
                        if (EditorUtility.DisplayDialog("Repair Complete", "The selected AIs were successfully repaired.\n\nDo you wish to load the repaired AIs?", "Yes", "No"))
                        {
                            foreach (var aiId in _utility.repairedAIIds)
                            {
                                AIEditorWindow.Open(aiId);
                            }
                        }

                        this.Close();
                    });
                }
            }

            EditorGUILayout.EndHorizontal();
        }
        private static bool ExecuteCommand(string cmd, int delay)
        {
            var ais = selectedAIs.ToArray();

            if (ais.Length == 0)
            {
                return(false);
            }

            bool consumeEvent = false;

            switch (cmd)
            {
            case "Open":
            {
                _pendingAction = () =>
                {
                    for (int i = 0; i < ais.Length; i++)
                    {
                        AIEditorWindow.Open(ais[i].aiId);
                    }
                };

                consumeEvent = true;
                break;
            }

            case "Delete":
            case "SoftDelete":
            {
                //reload all windows with deleted ais
                var aisBefore = StoredAIs.AIs.ToArray();
                _pendingAction = () =>
                {
                    StoredAIs.Refresh();
                    var aisAfter   = StoredAIs.AIs.ToArray();
                    var deletedIds = aisBefore.Except(aisAfter).Select(ai => ai.aiId).ToArray();

                    AIEditorWindow.Unload(deletedIds);
                };

                break;
            }

            case "Duplicate":
            {
                //identify all additions and re-ID them.
                var aisBefore = StoredAIs.AIs.ToArray();
                _pendingAction = () =>
                {
                    StoredAIs.Refresh();
                    var aisAfter = StoredAIs.AIs.ToArray();
                    var addedAis = aisAfter.Except(aisBefore);
                    foreach (var copiedAI in addedAis)
                    {
                        var ui = AIUI.Load(copiedAI, false);
                        if (ui != null)
                        {
                            ui.ai.RegenerateIds();
                            copiedAI.aiId = ui.ai.id.ToString();
                            ui.Save(null);
                        }
                        else
                        {
                            var path = AssetDatabase.GetAssetPath(copiedAI);
                            AssetDatabase.DeleteAsset(path);
                        }
                    }
                };

                break;
            }
            }

            EditorAsync.ExecuteDelayed(
                () =>
            {
                _pendingAction();
                _pendingAction = null;
            },
                delay);

            return(consumeEvent);
        }