Tracking kills PredicatePropertyDrawer addition

Hi @Brian_Trotter and the greater community.

I was reading over the Tracking kills for Quests? thread and I am trying to implement it into my game. Can someone link the added code to the PredicatePropertyDrawer to get the kill count to work? I did give it a go but I am not quite sure how to complete it.

I first added to the OnGUI method:

            if(selectedPredicate == EPredicate.HasKilled)
            {
                position.y += propHeight;
                DrawCount(position, parameterZero);
                position.y += propHeight;
                DrawIntSlider(position, "Amount to Kill", parameterOne, 1,100);
            }

Then as far as I have gotten for the DrawCount method is

        private void DrawCount(Rect position, SerializedProperty element)
        {
            EditorGUI.BeginProperty(position, new GUIContent("Trait"), element);

            EditorGUI.EndProperty();
        }

I am really unsure how to finish this off, and if there is anything else not mentioned in the original thread that I need to do?

Cheers

Actually, you won’t be doing a DrawCount for the first parameter in this case, you’ll be drawing a string (i.e. TextField).


The Predicate is HasKilled, which is in the Enum
parameterZero is the name of the creature to track.
At this point, we haven’t really set up a way to make a drop down of creatures you can search for, so for now we’ll just have to make a TextField

if(selectedPredicate == EPredicate.HasKilled)
{
    position.y+=propHeight;
    DrawString(position, "Name", parameterZero);
    position.y+=propHeight;
    DrawIntSlider(position, "Amount To Kill", parameterOne, 1,100);
}
    
private void DrawString(Rect position, string title, SerializedProperty element)
{
    EditorGUI.BeginProperty(position, new GUIContent(title), element);
    EditorGUI.BeginChangeCheck();
    string newString  = EditorGUI.TextField(position, new GUIContent(title), element.stringValue);
    if(EditorGUI.EndChangeCheck()
    {
         element.stringValue = newString;
    }
    EditorGUI.EndProperty();
}

Privacy & Terms