lundi 11 septembre 2017

Write data in inspector using reflection doesn't notify editor about the change

I am writing a custom inspector to solve the problems I have with Unity's default inspector. My system uses reflection and attributes to draw customizable inspectors. Modifying instances without entering playmode works fine. The problem is, that the editor doesn't seem to see the changes I make to my objects. This can be observed the usual way:

  • Instances reset on play.
  • Instances reset on editor reopen.

My editor takes about a second to save a scene and the cursor changes during that time. This can be triggered by saving the scene after changing some values in a Unity MonoBehaviour (f.e. RigidBody).

Using my own inspector and modifying values followed by saving the scene won't trigger the actual saving process (no visual clues). As if Unity believes there were no changes.

The GameObject I'd like to serialize:

[EnableIR]
public class CustomerSpawn : MonoBehaviour
{
    [Inspect(InspectionKind.DropableObject)]
    public GameObject CustomerPrefab; // This field resets to null on play.
}

I use PropertyInfo.SetValue or FieldInfo.SetValue to modify values and references using Reflection. Is there some method we need to call to notify Unity about changes?

Links:





Aucun commentaire:

Enregistrer un commentaire