[Simple question] Adding a new SerializedProperty to a SerializedObject

Hi!

I’m modifying a plugin I’ve bought, to better suit my game’s needs. It uses CustomEditor for all the scripts, and I need to add a new variable to a script. I want to be able to change this variable from the editor, depending on the prefab, so I need to add this one as a new property.

I have added my new value to the current code, but it seems like I’m missing something. I have this code:

// [OLD - from the plugin] Finding serialized properties...
oldPluginProperty1 = serializedObject.FindProperty("oldPluginPropertyNumberOne");
oldPluginProperty2 = serializedObject.FindProperty("oldPluginPropertyNumberTwo");
...
// MY NEW CODE:
myNewProperty = serializedObject.FindProperty("myNewProperty");

… myNewProperty returns a null value! Obviously I need to declare “myNewProperty” somewhere and add it to serializedObject, but I’ve scoured through the entire plugin and I cannot find where they are added. I’ve never done this before and everybody seems to have it so figured out that nobody talks about it in any thread! NOT EVEN IN THE UNITY DOCS!

How do I add myNewProperty to serializedObject so that FindProperty() doesn’t return null? Is it somewhere within the actual editor? Should I do it by code?

Thanks in advance!

OH BOY AIN’T I A DUMBASS.
You need to have “myNewProperty” declared as a regular variable, too, not just as a serializable property, and it should have the same name as you indicated in the string parameter from “FindProperty()”.
Sorry for that.