This is the OnGUI call:
I REMOVED alot of the other āif selected predicateā to limit the size of this post.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
SerializedProperty predicate = property.FindPropertyRelative("predicate");
SerializedProperty parameters = property.FindPropertyRelative("parameters");
SerializedProperty negate = property.FindPropertyRelative("negate");
float propHeight = EditorGUI.GetPropertyHeight(predicate);
position.height = propHeight;
EditorGUI.PropertyField(position, predicate);
position.y += propHeight;
EditorGUI.PropertyField(position, negate);
if (selectedPredicate == PredicateType.HasKilled)
{
position.y += propHeight;
DrawInputString(position, parameterZero);
position.y += propHeight;
DrawIntSlider(position, "Kill Amount", parameterOne, 1, 100);
}
}
This is the draw input function:
void DrawInputString(Rect position, SerializedProperty element)
{
EditorGUI.BeginProperty(position, new GUIContent("Name"), element);
element.stringValue = EditorGUI.TextField(position, "Name", element.stringValue);
EditorGUI.EndProperty();
}
This sets up the property height correctly: Notce has killed requires *4f.
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
SerializedProperty predicate = property.FindPropertyRelative("predicate");
float propHeight = EditorGUI.GetPropertyHeight(predicate);
PredicateType selectedPredicate = (PredicateType) predicate.enumValueIndex;
switch (selectedPredicate)
{
case PredicateType.Select: //No parameters, we only want the bare enum.
return propHeight;
case PredicateType.HasLevel: //All of these take 1 parameter
case PredicateType.HasCompletedQuest:
case PredicateType.HasQuest:
case PredicateType.HasItem:
case PredicateType.HasItemEquipped:
return propHeight * 3.0f; //Predicate + one parameter + negate
case PredicateType.HasCompletedObjective: //All of these take 2 parameters
case PredicateType.HasItems:
case PredicateType.MinimumTrait:
case PredicateType.HasKilled:
return propHeight * 4.0f; //Predicate + 2 parameters + negate;
}
Let me know if that helps fix the issue for your inspector.