private void InteractableGUI()
    {
        serializedObject.Update();

        float width = EditorGUIUtility.currentViewWidth / 3f;

        EditorGUILayout.BeginHorizontal();

        int conditionIndex = AllConditionsEditor.TryGetConditionIndex(condition);

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

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

        descriptionProperty.stringValue = globalCondition != null ? globalCondition.description : blankDescription;

        hashProperty.intValue = Animator.StringToHash(descriptionProperty.stringValue);

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

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

        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #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();
    }
    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);
    }
    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();
    }
    // 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);
    }
Beispiel #7
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);
    }