コード例 #1
0
 public override void OnClose()
 {
     //Free dropdown slots
     ProTools.FreeDropdownSlot(_A_key_dropdown_slot);
     ProTools.FreeDropdownSlot(_operator_dropdown_slot);
     ProTools.FreeDropdownSlot(_B_key_dropdown_slot);
 }
コード例 #2
0
        private void DrawInEditMode()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state
            if (GUILayout.Button("-", GUILayout.Width(20), GUILayout.Height(20)) || Application.isPlaying)
            {
                //Change state
                _UI_mode = EditorUIMode.SET_STATE;
                //Set input focus to null
                GUI.FocusControl("null");
                //Check name change
                if (string.Compare(new_name, _target_variable.name) != 0)
                {
                    //Repeated name case
                    if (_target_blackboard.variables.ContainsKey(new_name))
                    {
                        Debug.LogWarning("The name '" + new_name + "' already exists!");
                    }
                    //New name case
                    else
                    {
                        //Change key in the dictionary, the variable is now stored with the new key
                        _target_blackboard.variables.RenameKey(_target_variable.name, new_name);
                        //Change variable name
                        _target_variable.name = new_name;
                    }
                }
                //Free dropdown slots
                ProTools.FreeDropdownSlot(_variable_dropdown_data.dropdown_slot);
                ProTools.FreeDropdownSlot(_method_dropdown_data.dropdown_slot);

                return;
            }

            //Show variable type
            GUILayout.Label(_target_variable.type.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(60.0f));

            //Edit variable name
            new_name = EditorGUILayout.TextField(new_name, GUILayout.MaxWidth(80.0f));

            //Show variable value
            //Non binded variable case
            if (!_target_variable.is_field_binded && !_target_variable.is_method_binded)
            {
                //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;
                }
            }

            ShowBindOptions();

            GUILayout.EndHorizontal();
        }
コード例 #3
0
 public override void OnClose()
 {
     //Free dropdown slots
     ProTools.FreeDropdownSlot(_variable_dropdown_data.dropdown_slot);
 }
コード例 #4
0
        private void DrawInEdit()
        {
            GUILayout.BeginHorizontal();

            //Edit button, swap between edit and show state
            if (GUILayout.Button("-", GUILayout.Width(30), GUILayout.Height(20), GUILayout.ExpandWidth(false)) || Application.isPlaying)
            {
                //Change UI mode
                _UI_mode = EditorUIMode.SET_STATE;
                //Set input focus to null
                GUI.FocusControl("null");
                //Free dropdown slots
                ProTools.FreeDropdownSlot(_operator_dropdown.dropdown_slot);
                ProTools.FreeDropdownSlot(_B_variable_dropdown.dropdown_slot);
                _operator_dropdown   = null;
                _B_variable_dropdown = null;
                //Check B key
                if (edit_value)
                {
                    //If property B key is not ser property will use value
                    _target_property.B_key = null;
                    //If value is different we update the variable value
                    if (value != _target_property.value)
                    {
                        _target_property.value = value;
                    }
                    ;
                }
                return;
            }

            //A key label
            GUILayout.Label(_target_property.A_key, UIConfig_GS.center_normal_style, GUILayout.MaxWidth(200.0f), GUILayout.ExpandWidth(true));

            //Operator dropdown
            ProTools.GenerateButtonDropdownMenu(ref _operator_dropdown.selected_index, _operator_dropdown.paths, _operator_dropdown.paths[_operator_dropdown.selected_index], true, 30.0f, _operator_dropdown.dropdown_slot);
            //Check operator change
            if (_operator_dropdown.selected_index != -1 && _valid_operators[_operator_dropdown.selected_index] != _target_property.operator_type)
            {
                _target_property.operator_type = _valid_operators[_operator_dropdown.selected_index];
            }

            //Value area
            //First check if the target property uses a value or a variable
            if (edit_value)
            {
                //Generate UI field from type
                ProTools.ValueFieldByVariableType(_target_property.variable_type, ref value);

                //Change to variable button
                if (GUILayout.Button(new GUIContent(" ", "Change to variable"), GUILayout.MaxWidth(10.0f)))
                {
                    edit_value = false;
                }
            }
            else
            {
                //Generate enumerator popup with the avaliable B keys
                ProTools.GenerateButtonDropdownMenu(ref _B_variable_dropdown.selected_index, _B_variable_dropdown.paths, "Not Set", _B_variable_dropdown.selected_index != -1, 80.0f, _B_variable_dropdown.dropdown_slot);
                //Check B key change
                if (_B_variable_dropdown.selected_index != -1 && string.Compare(_target_property.B_key, _B_variable_dropdown.paths[_B_variable_dropdown.selected_index]) != 0)
                {
                    //Update B key on change
                    _target_property.B_key = _B_variable_dropdown.paths[_B_variable_dropdown.selected_index];
                    //Set value as B variable
                    string[] B_key_info = _target_property.B_key.Split('/');
                    if (string.Compare(B_key_info[0], "Global") == 0)
                    {
                        _target_property.value = GlobalBlackboard_GS.blackboard.GetObjectVariable(B_key_info[1]);
                    }
                    else
                    {
                        _target_property.value = NodeEditor_GS.Instance.selected_agent.blackboard.GetObjectVariable(B_key_info[1]);
                    }
                }

                //Change to value button
                if (GUILayout.Button(new GUIContent(" ", "Change to value"), GUILayout.MaxWidth(10.0f)))
                {
                    edit_value             = true;
                    _target_property.B_key = null;
                    ProTools.AllocateFromVariableType(_target_property.variable_type, ref value);
                }
            }
            GUILayout.EndHorizontal();
        }
コード例 #5
0
        //Loop Methods ================
        public override void OnGUI(Rect rect)
        {
            //Menu title
            GUILayout.BeginHorizontal("Box");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Method Input", UIConfig_GS.Instance.select_menu_title_style, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //Separator
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            GUILayout.BeginVertical();

            //Method name
            GUILayout.Label(_target_method.Name, UIConfig_GS.left_bold_style);

            //Method inputs
            for (int k = 0; k < method_parameters.Length; k++)
            {
                GUILayout.BeginHorizontal();

                //Input type
                GUILayout.Label(method_parameters[k].ParameterType.ToShortString(), UIConfig_GS.left_bold_style, GUILayout.MaxWidth(80), GUILayout.ExpandWidth(true));
                //Not binded input case
                if (string.IsNullOrEmpty(_target_variable.binded_method_input[k].Key))
                {
                    //Input value
                    ProTools.ValueFieldByVariableType(method_parameters[k].ParameterType.ToVariableType(), ref local_values[k]);

                    //Bind dropdown
                    ProTools.GenerateButtonDropdownMenu(ref input_dropdowns[k].selected_index, input_dropdowns[k].display_paths, "Bind", false, 40.0f, input_dropdowns[k].dropdown_slot);

                    //On variable selected we update the method input of the target variable
                    if (input_dropdowns[k].selected_index > -1)
                    {
                        //Generate the new method input with the bind path
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>(input_dropdowns[k].display_paths[input_dropdowns[k].selected_index], null);
                    }
                }
                //Binded input case
                else
                {
                    //Binded input path
                    GUILayout.Label(_target_variable.binded_method_input[k].Key, GUILayout.MaxWidth(80.0f));
                    //Unbind button
                    if (GUILayout.Button("UnBind", GUILayout.MaxWidth(50.0f)))
                    {
                        //Remove method input path string and place tje local correct type value
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>("", local_values[k]);
                        //Reset the dropdown selected index
                        ProTools.SetDropdownIndex(input_dropdowns[k].dropdown_slot, -1);
                    }
                }
                //Binded input case
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();

            //Apply changes button
            if (GUILayout.Button("Apply", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                for (int k = 0; k < method_parameters.Length; k++)
                {
                    if (string.IsNullOrEmpty(_target_variable.binded_method_input[k].Key))
                    {
                        //Local object values are applied to the non binded method input parameters
                        _target_variable.binded_method_input[k] = new KeyValuePair <string, object>("", local_values[k]);
                    }
                }

                //Release the allocated dropdown slots
                for (int k = 0; k < input_dropdowns.Length; k++)
                {
                    ProTools.FreeDropdownSlot(input_dropdowns[k].dropdown_slot);
                }

                //Close popupwindow
                editorWindow.Close();
            }

            //Close button
            if (GUILayout.Button("Close", UIConfig_GS.Instance.node_modify_button_style, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                //Release the allocated dropdown slots
                for (int k = 0; k < input_dropdowns.Length; k++)
                {
                    ProTools.FreeDropdownSlot(input_dropdowns[k].dropdown_slot);
                }

                //Close popupwindow
                editorWindow.Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
コード例 #6
0
 public override void OnClose()
 {
     ProTools.FreeDropdownSlot(_folder_dropdown_slot);
 }
コード例 #7
0
 public override void OnClose()
 {
     ProTools.FreeDropdownSlot(_action_dropdown_slot);
 }