public static void OpenWindow(AI ai, int behaviour_id) { _ai = ai; behaviour = behaviour_id; moment = windowMoments.main; gameConfig = Resources.Load("Configs/GeneralConfigs") as SimpleAIConfig; SimpleAIWindow window = (SimpleAIWindow)GetWindow(typeof(SimpleAIWindow)); window.minSize = windowSize; window.Show(); }
private void DrawSecondScreen() { SecondScreen.x = 0; SecondScreen.y = 0; SecondScreen.width = Screen.width; SecondScreen.height = Screen.height; backButton.x = 5; backButton.y = 5; backButton.width = backIconSize; backButton.height = backIconSize; optionsArea.x = 10; optionsArea.y = 70; optionsArea.width = SecondScreen.width - 20; optionsArea.height = SecondScreen.height - optionsArea.y - 35; GUI.DrawTexture(SecondScreen, SecondScreenTexture); GUI.DrawTexture(backButton, SecondScreenIconTexture); //Remover GUI.DrawTexture(optionsArea, SecondScreenIconTexture); GUILayout.BeginArea(SecondScreen); if (GUI.Button(backButton, "", BorderLassButton)) { moment = windowMoments.main; } if (secondScreenMoment == addMoment.condition) { secondScreenConditions(); } else { secondScreenActions(); } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.EndArea(); }
void secondScreenActions() { //TODO: Tradução EditorGUILayout.LabelField("Select action to add", secondScreenLayout.GetStyle("secondHeader")); GUILayout.BeginArea(optionsArea); optionsAreaScroll = GUILayout.BeginScrollView(optionsAreaScroll); EditorGUILayout.BeginVertical(); foreach (var type in SimpleAI_Action.actionsList) { if (GUILayout.Button(type.Key)) { Array.Resize <SimpleAI_Action>(ref _ai.actions[behaviour].actions, _ai.actions[behaviour].actions.Length + 1); _ai.actions[behaviour].actions[_ai.actions[behaviour].actions.Length - 1] = (SimpleAI_Action)type.Value.Clone(); _ai.save(); moment = windowMoments.main; } } EditorGUILayout.EndVertical(); }
void DrawActions() { GUILayout.BeginArea(ActionSection); buildMenuScrollPosition2 = GUILayout.BeginScrollView(buildMenuScrollPosition2); GUILayout.BeginVertical(); if (_ai.actions[behaviour].actions.Length < 1) { //TODO: Tradução EditorGUILayout.HelpBox("No actions!", MessageType.Warning); } else { for (int i = 0; i < _ai.actions[behaviour].actions.Length; i++) { try { if (i % 2 == 0) { EditorGUILayout.BeginVertical("box"); } else { EditorGUILayout.BeginVertical(EditorStyles.helpBox); } _ai.actions[behaviour].actions[i].drawActionHeader(_ai.actions[behaviour].actions[i].getName(), _ai.actions[behaviour].actions[i].BtnIcon(), _ai, behaviour, i); if (!_ai.actions[behaviour].actions[i].open) { EditorGUILayout.EndVertical(); continue; } _ai.actions[behaviour].actions[i].drawGUI(_ai, behaviour, i); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } catch (Exception e) { Debug.Log(e.Message); continue; } } } GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); WindowHelpers.drawLabel("Add action"); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(25))) { secondScreenMoment = addMoment.action; moment = windowMoments.second; } EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
void DrawConditions() { GUILayout.BeginArea(ConditionalSection); conditionsScroll = GUILayout.BeginScrollView(conditionsScroll); GUILayout.BeginVertical(); if (_ai.actions[behaviour].conditions.Length < 1) { //TODO: Tradução EditorGUILayout.HelpBox("No conditions!", MessageType.Warning); } else { for (int i = 0; i < _ai.actions[behaviour].conditions.Length; i++) { try { EditorGUILayout.BeginVertical("box"); _ai.actions[behaviour].conditions[i].drawConditionHeader(_ai.actions[behaviour].conditions[i].getName(), _ai.actions[behaviour].conditions[i].BtnIcon(), _ai, behaviour, i); if (!_ai.actions[behaviour].conditions[i].open) { EditorGUILayout.EndVertical(); continue; } _ai.actions[behaviour].conditions[i].drawGUI(_ai, behaviour, i); EditorGUILayout.EndVertical(); if (_ai.actions[behaviour].conditions.Length > 1 && i + 1 < _ai.actions[behaviour].conditions.Length) { EditorGUILayout.LabelField("-------- " + ((_ai.actions[behaviour].isAndGroup) ? "AND" : "OR") + " --------", secondScreenLayout.GetStyle("conditionDivision"), new GUILayoutOption[] { GUILayout.Height(8) }); } } catch (Exception e) { Debug.Log(e.Message); continue; } } } GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); WindowHelpers.drawLabel("Add condition"); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(25))) { secondScreenMoment = addMoment.condition; moment = windowMoments.second; } EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
//TODO: Aperfeiçoar validação de AI void ValidateSelection() { bool isAAssetObject = false; //TODO: COrrigir edição de arquivo direto dos assets /*var path = ""; * var obj = Selection.activeObject; * if (obj == null) path = "Assets"; * else path = AssetDatabase.GetAssetPath(obj.GetGetSingleton()ID()); * if (path.Length > 0) * { * if (Directory.Exists(path)) * { * Debug.Log("Folder"); * } * else * { * try * { * Debug.Log(obj.GetType()); * //isAAssetObject = true; * * }catch * { * isAAssetObject = false; * } * } * } * else * { * Debug.Log("Not in assets folder"); * }*/ if (!isAAssetObject && Selection.gameObjects.Length < 1) { _ai = null; behaviour = -1; moment = windowMoments.error; return; } else { if (!isAAssetObject) { SimpleAI _simpleAI = Selection.gameObjects[0].GetComponent <SimpleAI>(); if (_simpleAI) { _ai = _simpleAI.ai; } } if (_ai != null) { if (moment != windowMoments.second) { moment = windowMoments.main; } if (_ai.actions.Length > 0 && behaviour < 0) { behaviour = 0; } else if (_ai.actions.Length - 1 < behaviour) { behaviour -= 1; } } else { _ai = null; behaviour = -1; moment = windowMoments.error; } } }