private void InteractableGUI()
    {
        serializedObject.Update();
        float width = EditorGUIUtility.currentViewWidth / 3f;

        EditorGUILayout.BeginHorizontal();

        int conditionIndex = AllConditionsEditor.GetConditionIndex(condition);

        if (conditionIndex == -1)
        {
            conditionIndex = 0;
        }

        conditionIndex = EditorGUILayout.Popup(conditionIndex, AllConditionsEditor.AllConditionDescriptions,
                                               GUILayout.Width(width));

        Condition globalCondition = AllConditionsEditor.GetConditionAt(conditionIndex);

        descriptionProperty.stringValue = globalCondition != null ? globalCondition.description : blankDescription;
        hashProperty.intValue           = Animator.StringToHash(descriptionProperty.stringValue);

        //satisfaction toggle
        EditorGUILayout.PropertyField(satisfiedProperty, GUIContent.none, GUILayout.Width(width + toggleOffset));

        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            conditionsProperty.RemoveFromObjectArray(condition);
        }
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }
Example #2
0
    private void InteractableGUI()
    {
        // Pull the information from the target into the serializedObject.
        serializedObject.Update();

        // The width for the Popup, Toggle and remove Button.
        float popupWidth = EditorGUIUtility.currentViewWidth / 2f;
        float width      = popupWidth / 2;

        EditorGUILayout.BeginHorizontal();

        // Find the index for the target based on the AllConditions array.
        int conditionIndex = AllConditionsEditor.TryGetConditionIndex(condition);


        // If the target can't be found in the AllConditions array use the first condition.
        if (conditionIndex == -1)
        {
            conditionIndex = 0;
        }

        // Info icon with the editor description of the condition as tooltip
        Texture icon = EditorGUIUtility.IconContent("console.infoicon.sml").image;

        EditorGUILayout.LabelField(new GUIContent(icon, condition.editorDescription), GUILayout.Width(20f));

        // Set the index based on the user selection of the condition by the user.
        conditionIndex = EditorGUILayout.Popup(conditionIndex, AllConditionsEditor.AllConditionDescriptions,
                                               GUILayout.Width(popupWidth - toggleOffset * 2.5f));

        // Find the equivalent condition in the AllConditions array.
        Condition globalCondition = ScriptableObjectUtility.TryGetScriptableObjectAt(conditionIndex, AllConditions.Instance.conditions);

        EditorGUILayout.LabelField("", GUILayout.Width(toggleOffset));

        // Set the description based on the globalCondition's description.
        descriptionProperty.stringValue = globalCondition != null ? globalCondition.description : blankDescription;

        // Set the hash based on the description.
        hashProperty.intValue = Animator.StringToHash(descriptionProperty.stringValue);


        // Display the toggle for the satisfied bool.
        EditorGUILayout.PropertyField(satisfiedProperty, GUIContent.none, GUILayout.MaxWidth(width - toggleOffset));


        // Display a button with a '-' that when clicked removes the target from the ConditionCollection's conditions array.
        if (EditorTools.createListButton("-", true, GUILayout.Width(conditionButtonWidth)))
        {
            DestroyImmediate(this);
            requiredConditionsProperty.RemoveFromObjectArray(target);
        }

        EditorGUILayout.EndHorizontal();

        // Push all changes made on the serializedObject back to the target.
        serializedObject.ApplyModifiedProperties();
    }
Example #3
0
    public static Condition CreateCondition()
    {
        Condition newCondition     = CreateInstance <Condition>();
        string    blankDescription = "No conditions set.";
        Condition globalCondition  = AllConditionsEditor.TryGetConditionAt(0);

        newCondition.description = globalCondition != null ? globalCondition.description : blankDescription;
        SetHash(newCondition);
        return(newCondition);
    }
    protected override void DrawReaction()
    {
        if (conditionProperty.objectReferenceValue == null)
        {
            conditionProperty.objectReferenceValue = AllConditionsEditor.TryGetConditionAt(0);
        }

        int index = AllConditionsEditor.TryGetConditionIndex((Condition)conditionProperty.objectReferenceValue);

        index = EditorGUILayout.Popup(index, AllConditionsEditor.AllConditionDescriptions);
        conditionProperty.objectReferenceValue = AllConditionsEditor.TryGetConditionAt(index);

        EditorGUILayout.PropertyField(satisfiedProperty);
    }
    /**
     * TODO: Dodać  edit parametru satisfied w AllConditions
     */
    private void AllConditionsAssetGUI()
    {
        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        EditorGUI.indentLevel++;

        EditorGUILayout.LabelField(condition.description);
        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            AllConditionsEditor.RemoveCondition(condition);
        }

        EditorGUI.indentLevel--;
        EditorGUILayout.EndHorizontal();
    }
Example #6
0
    private void AllConditionsAssetGUI()
    {
        EditorGUILayout.BeginHorizontal(GUI.skin.box);

        EditorGUILayout.LabelField(condition.description);
        EditorGUILayout.PropertyField(satisfiedProperty);

        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            AllConditionsEditor.RemoveCondition(condition);
        }


        EditorGUILayout.EndHorizontal();
    }
Example #7
0
 private void drawAllconditionsTab()
 {
     if (!AllConditions.Instance)
     {
         EditorTools.drawMessage("AllConditions has not been created yet.", MessageType.Info);
         if (EditorTools.createListButton("Create AllConditions Object", false))
         {
             AllConditionsEditor.CreateAllConditionsAsset();
         }
     }
     else
     {
         AllConditionsEditor.CreateEditor(AllConditions.Instance).OnInspectorGUI();
     }
 }
    // Function to Create a NewCondition (Static: it can be Called without an Editor being Instanced)
    public static Condition CreateCondition()
    {
        // Create a new Instance of Condition
        Condition newCondition = CreateInstance <Condition> ();
        // Default Description of Condition
        string blankDescription = "No conditions set.";
        // Set newConditions Description to First in AllConditions Array
        Condition globalCondition = AllConditionsEditor.TryGetConditionAt(0);

        // Set the Description of newCondition (based on if Description exists in Global)
        newCondition.description = globalCondition != null ? globalCondition.description : blackDescription;
        // Set the Hash based on newConditions Description
        SetHash(newCondition);
        // Return the newCondition
        return(newCondition);
    }
    // This function is static such that it can be called without an editor being instanced.
    public static Condition CreateCondition()
    {
        // Create a new instance of Condition.
        Condition newCondition = CreateInstance <Condition>();

        string blankDescription = "No conditions set.";

        // Try and set the new condition's description to the first condition in the AllConditions array.
        Condition globalCondition = AllConditionsEditor.TryGetConditionAt(0);

        newCondition.description = globalCondition != null ? globalCondition.description : blankDescription;

        // Set the hash based on this description.
        SetHash(newCondition);
        return(newCondition);
    }
    private void InteractableGUI()
    {
        // Pull the information from the target into the serializedObject.
        serializedObject.Update();

        // The width for the Popup, Toggle and remove Button.
        float width = EditorGUIUtility.currentViewWidth / 3f;

        EditorGUILayout.BeginHorizontal();

        // Find the index for the target based on the AllConditions array.
        int conditionIndex = AllConditionsEditor.TryGetConditionIndex(condition);

        // If the target can't be found in the AllConditions array use the first condition.
        if (conditionIndex == -1)
        {
            conditionIndex = 0;
        }

        // Set the index based on the user selection of the condition by the user.
        conditionIndex = EditorGUILayout.Popup(conditionIndex, AllConditionsEditor.AllConditionDescriptions,
                                               GUILayout.Width(width));

        // Find the equivalent condition in the AllConditions array.
        Condition globalCondition = AllConditionsEditor.TryGetConditionAt(conditionIndex);

        // Set the description based on the globalCondition's description.
        descriptionProperty.stringValue = globalCondition != null ? globalCondition.description : blankDescription;

        // Set the hash based on the description.
        hashProperty.intValue = Animator.StringToHash(descriptionProperty.stringValue);

        // Display the toggle for the satisfied bool.
        EditorGUILayout.PropertyField(satisfiedProperty, GUIContent.none, GUILayout.Width(width + toggleOffset));

        // Display a button with a '-' that when clicked removes the target from the ConditionCollection's conditions array.
        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            conditionsProperty.RemoveFromObjectArray(condition);
        }

        EditorGUILayout.EndHorizontal();

        // Push all changes made on the serializedObject back to the target.
        serializedObject.ApplyModifiedProperties();
    }
    // This is displayed for each Condition when the AllConditions asset is selected.
    private void AllConditionsAssetGUI()
    {
        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        EditorGUI.indentLevel++;

        // Display the description of the Condition.
        EditorGUILayout.LabelField(condition.description);

        // Display a button showing a '-' that if clicked removes this Condition from the AllConditions asset.
        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            AllConditionsEditor.RemoveCondition(condition);
        }

        EditorGUI.indentLevel--;
        EditorGUILayout.EndHorizontal();
    }
    // Display InteractableAsset
    private void InteractableGUI()
    {
        // Update the Serialize Object Properties
        serializedObject.Update();

        //Width of PopUp, Toggle and Remove Button.
        float width = EditorGUIUtility.currentViewWidth / 3f;

        // Begin HorizontalBox for Interactable
        EditorGUILayout.BeginHorizontal();

        // Find Index for Target based on AllConditions Array
        int conditionIndex = AllConditionsEditor.TryGetConditionIndex(condition);

        // if ConditionIndex was not Found
        if (conditionIndex == -1)
        {
            // Set Index to First in Array
            conditionIndex = 0;
        }

        // Set Index based on User Selection of the Condition (by the user)
        conditionIndex = EditorGUILayout.Popup(conditionIndex, AllConditionsEditor.AllConditionDescriptions, GUILayout.Width(width));
        // Find Condition in AllCondition Array
        Condition globalCondition = AllConditionsEditor.TryGetConditionAt(conditionIndex);

        // Set Description based on GlobalConditions Description
        descriptionProperty.stringValue = globalCondition != null ? globalCondition.description : blackDescription;
        // Set Hash based on Description
        hashProperty.intValue = Animator.StringToHash(descriptionProperty.stringValue);
        // Display Toggle Satisfied Bool
        EditorGUILayout.PropertyField(satisfiedProperty, GUIContent.none, GUILayout.Width(width + toggleOffset));

        // Create Button to Remove Condition from ConditionCollections Array
        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            // Remove Condition from ConditionCollection
            conditionsProperty.RemoveFromObjectArray(condition);
        }

        // End Horizontal IntactableBox
        EditorGUILayout.EndHorizontal();
        // Apply Update Properties to SerializedObject
        serializedObject.ApplyModifiedProperties();
    }
    protected override void DrawReaction()
    {
        // If no Condition Found
        if (conditionProperty.objectReferenceValue == null)
        {
            // Set to First Condition of AllConditions Array
            conditionProperty.objectReferenceValue = AllConditionsEditor.TryGetConditionAt(0);
        }

        // Get Index of Condition in AllCondition Array
        int index = AllConditionsEditor.TryGetConditionIndex((Condition)conditionProperty.objectReferenceValue);

        // Use and Set Index based on PopUp of AllConditions Descriptions
        index = EditorGUILayout.Popup(index, AllConditionsEditor.AllConditionDescriptions);
        // Set Condition based on new Index from AllConditions Array
        conditionProperty.objectReferenceValue = AllConditionsEditor.TryGetConditionAt(index);
        // Use default Toggle GUI for Satisfied Field
        EditorGUILayout.PropertyField(satisfiedProperty);
    }
Example #14
0
    protected override void DrawReaction()
    {
        // If there's isn't a Condition yet, set it to the first Condition from the AllConditions array.
        if (conditionProperty.objectReferenceValue == null)
        {
            conditionProperty.objectReferenceValue = ScriptableObjectUtility.TryGetScriptableObjectAt(0, AllConditions.Instance.conditions);
        }

        // Get the index of the Condition in the AllConditions array.
        int index = AllConditionsEditor.TryGetConditionIndex((Condition)conditionProperty.objectReferenceValue);

        // Use and set that index based on a popup of all the descriptions of the Conditions.
        index = EditorGUILayout.Popup(index, AllConditionsEditor.AllConditionDescriptions);

        // Set the Condition based on the new index from the AllConditions array.
        conditionProperty.objectReferenceValue = ScriptableObjectUtility.TryGetScriptableObjectAt(index, AllConditions.Instance.conditions);

        // Use default toggle GUI for the satisfied field.
        EditorGUILayout.PropertyField(satisfiedProperty);
    }
Example #15
0
    private void AllConditionsAssetGUI()
    {
        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        EditorGUI.indentLevel++;

        EditorGUILayout.LabelField(condition.description);

        EditorGUILayout.PropertyField(satisfiedProperty);

        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            AllConditionsEditor.RemoveCondition(condition);
        }
//		//
//		if (GUILayout.Button("+", GUILayout.Width(conditionButtonWidth)))
//			AllConditionsEditor.AddCondition("New condition");
//        //
        EditorGUI.indentLevel--;
        EditorGUILayout.EndHorizontal();
    }
    // Display each Condition when AllConditions Asset is Selected
    private void AllConditionsAssetGUI()
    {
        // Begin Horizontal box for Condition
        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        // Indent ConditionBox
        EditorGUI.indentLevel++;
        // Display Condition DescriptionS
        EditorGUILayout.LabelField(condition.description);

        // Create Button to Remove Condition from AllConditions
        if (GUILayout.Button("-", GUILayout.Width(conditionButtonWidth)))
        {
            // Remove Condition from AllConditions
            AllConditionsEditor.RemoveCondition(condition);
        }

        // Stop ConditionBox indent
        EditorGUI.indentLevel--;
        // End ConditionBox
        EditorGUILayout.EndHorizontal();
    }
Example #17
0
    private void editorGUI(bool removeButton)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
        // Display the description of the Condition.

        string title = "";

        for (int i = 0; i < condition.description.Length && i < 20; i++)
        {
            title += condition.description[i];
        }

        if (condition.description.Length > title.Length)
        {
            title += "...";
        }

        condition.isExpanded = EditorGUILayout.Foldout(condition.isExpanded, new GUIContent(title), true, EditorStyles.foldout);

        EditorGUI.BeginDisabledGroup(true);
        EditorGUI.indentLevel += 7;
        EditorGUILayout.ToggleLeft("is satisfied?", condition.isSatisfied, GUILayout.MinWidth(0));
        EditorGUI.indentLevel -= 7;
        EditorGUI.EndDisabledGroup();

        EditorGUI.BeginDisabledGroup(Application.isPlaying);

        // Display a button showing a '-' that if clicked removes this Condition from the AllConditions asset.
        if (removeButton && EditorTools.createListButton("-", true, GUILayout.Width(conditionButtonWidth)))
        {
            AllConditionsEditor.RemoveCondition(condition);
        }

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();

        if (condition.isExpanded)
        {
            EditorGUI.indentLevel += 1;
            EditorGUILayout.LabelField("Condition Name");
            EditorGUI.indentLevel -= 1;
            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
            condition.description = EditorGUILayout.TextField(condition.description);

            if (GUILayout.Button(" Rename ", GUILayout.ExpandWidth(false)))
            {
                condition = ModifyConditionName(condition);
                // Mark the AllConditions asset as dirty so the editor knows to save changes to it when a project save happens.
                EditorUtility.SetDirty(AllConditions.Instance);
                // Recreate the condition description array with the new added Condition.
                AllConditionsEditor.SetAllConditionDescriptions();
                AssetDatabase.SaveAssets();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
            EditorGUILayout.LabelField("Editor Description");
            condition.editorDescription = EditorGUILayout.TextArea(condition.editorDescription, EditorStyles.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight * 5));
            EditorGUILayout.EndVertical();
            GUILayout.Space(5);
        }

        EditorGUILayout.EndVertical();
    }