private void DrawInShow() { GUILayout.BeginHorizontal(); //Edit button, swap between edit and show state(hide on play) if (!Application.isPlaying) { if (GUILayout.Button(new GUIContent("O", "Change variable editor to edit mode"), GUILayout.Width(20), GUILayout.Height(20))) { //Change UI mode _UI_mode = EditorUIMode.EDIT_STATE; //Set input focus to null GUI.FocusControl("null"); //Set new name string new_name = _target_variable.name; //Generate bind options //Generate variables paths and display paths //Get all the properties in the agent gameobject PropertyInfo[] _properties_info = ProTools.FindConcretePropertiesInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type); //Get all fields in th agent gameobject FieldInfo[] _fields_info = ProTools.FindConcreteFieldsInGameObject(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type); //Allocate strings arrays _variable_dropdown_data.paths = new string[_properties_info.Length + _fields_info.Length]; _variable_dropdown_data.display_paths = new string[_properties_info.Length + _fields_info.Length]; //Generate properties paths for (int k = 0; k < _properties_info.Length; k++) { _variable_dropdown_data.paths[k] = string.Format("{0}.{1}", _properties_info[k].ReflectedType.FullName, _properties_info[k].Name); _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/'); } //Generate fields paths for (int k = _properties_info.Length, fields_k = 0; k < _properties_info.Length + _fields_info.Length; k++, fields_k++) { _variable_dropdown_data.paths[k] = string.Format("{0}.{1}", _fields_info[fields_k].ReflectedType.FullName, _fields_info[fields_k].Name); _variable_dropdown_data.display_paths[k] = _variable_dropdown_data.paths[k].Replace('.', '/'); } //Get dropdown slot if (_variable_dropdown_data.dropdown_slot == -2) { _variable_dropdown_data.dropdown_slot = ProTools.GetDropdownSlot(); } //Generate methods paths and display paths //Get all the methods in the agent gameobject KeyValuePair <MethodInfo, object>[] gameobject_data = ProTools.FindConcreteGameObjectMethods(NodeEditor_GS.Instance.selected_agent.gameObject, _target_variable.system_type); //Get all the methods in the agent logic(actions, behaviour) KeyValuePair <MethodInfo, object>[] agent_data = ProTools.FindConcreteAgentMethods(NodeEditor_GS.Instance.selected_agent, _target_variable.system_type); //Allocate strings arrays _method_dropdown_data.paths = new string[gameobject_data.Length + agent_data.Length]; _method_dropdown_data.display_paths = new string[gameobject_data.Length + agent_data.Length]; //Generate gameobject methods for (int k = 0; k < gameobject_data.Length; k++) { _method_dropdown_data.paths[k] = string.Format("{0}.{1}.{2}", "GameObject", gameobject_data[k].Key.ReflectedType.FullName, gameobject_data[k].Key.Name); _method_dropdown_data.display_paths[k] = _method_dropdown_data.paths[k].Replace('.', '/'); } //Generate agent methods for (int k = gameobject_data.Length, agent_k = 0; k < gameobject_data.Length + agent_data.Length; k++, agent_k++) { _method_dropdown_data.paths[k] = string.Format("{0}.{1}.{2}", "Agent", agent_data[agent_k].Key.ReflectedType.FullName, agent_data[agent_k].Key.Name); _method_dropdown_data.display_paths[k] = _method_dropdown_data.paths[k].Replace('.', '/'); } //Get dropdown slot if (_method_dropdown_data.dropdown_slot == -2) { _method_dropdown_data.dropdown_slot = ProTools.GetDropdownSlot(); } } } //Show variable type GUILayout.Label(_target_variable.type.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(60.0f)); //Show variable name GUILayout.Label(_target_variable.name, GUILayout.MaxWidth(110.0f)); //Show variable value //Non binded variable case if (_target_variable.is_field_binded) { //If the variables is field binded we show the field inheritance path GUILayout.Label(_target_variable.binded_field_short_path, GUILayout.MaxWidth(90.0f)); } else if (_target_variable.is_method_binded) { if (_has_method_parameters) { //If the variables is method binded we show the field inheritance path if (GUILayout.Button(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f))) { Vector2 mousePos = Event.current.mousePosition; PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new MethodSelectMenu_GS(_target_variable)); } } else { GUILayout.Label(_target_variable.binded_method_short_path, GUILayout.MaxWidth(90.0f)); } } //Binded variable case else { //Get variable value object value = _target_variable.object_value; //Generate UI field from type ProTools.ValueFieldByVariableType(_target_variable.type, ref value); //If value is different we update the variable value if (value.Equals(_target_variable.object_value) == false) { _target_variable.value = value; } ; } //Variable planning value GUILayout.Label("Pv", GUILayout.MaxWidth(20)); _target_variable.planning_value = EditorGUILayout.FloatField((float)_target_variable.planning_value, GUILayout.MaxWidth(20.0f)); //Remove button if (!Application.isPlaying) { if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(20))) { bool global = _target_blackboard.target_agent == null; //Add remove the current var method to accept menu delegates callback SecurityAcceptMenu_GS.on_accept_delegate += () => _target_blackboard.RemoveVariable(_target_variable.name, global); //Add remove current var editor from blackboard editor to accept menu delegates calback if (_target_blackboard == GlobalBlackboard_GS.blackboard) { SecurityAcceptMenu_GS.on_accept_delegate += () => GlobalBlackboard_GS_Editor.blackboard_editor.RemoveVariableEditor(_target_variable.name, global); } else { SecurityAcceptMenu_GS.on_accept_delegate += () => NodeEditor_GS.Instance.blackboard_editor.RemoveVariableEditor(_target_variable.name, global); } //Get mouse current position Vector2 mousePos = Event.current.mousePosition; //Open security accept menu on mouse position PopupWindow.Show(new Rect(mousePos.x, mousePos.y, 0, 0), new SecurityAcceptMenu_GS()); } } GUILayout.EndHorizontal(); }