I’m trying to write an editor script for one of my objects. I’d like to enforce some constraints for some of the fields but some the values for these constraints live on other objects.
When i query the scene and access that instance they don’t return the correct value. I’m guessing because found object is not the serialized version of itself it does not return its inspector value.
I was wondering if there is a way to do this kind of thing?
Edit:
Maybe there is better way of doing it but I found a way to accomplish what I need. Below code goes into the editor script. I create an editor for the other object and get its inspector value.
var obj = FindObjectOfType<type>();
var objEditor = Editor.CreateEditor(obj);
var constraintValue = objEditor.serializedObject.FindProperty("PropertyToFind").intValue;