Search Unity

Custom Inspector in Variants

Discussion in 'Prefabs' started by TobiasNeobird, Mar 19, 2019.

  1. TobiasNeobird

    TobiasNeobird

    Joined:
    Sep 6, 2017
    Posts:
    8
    Hi everyone,

    I tried to change the serialized field of a MonoBehaviour in a custom inspector using a public Accessor.

    This works fine for all my scripts, unless I'm overwriting the value of a prefab within its variant. In this case the change is not saved for the variant, even though the inspector is updated.

    Is there a best practice that I'm missing or is this a bug?

    Best regards
    Tobias

    Code (CSharp):
    1.             if (GUILayout.Button("Find all child objects"))
    2.             {
    3.                 Foo myTarget = (Foo)target;
    4.                 myTarget.SomeList = new List<Bar>(myTarget.GetComponentsInChildren<Bar>());
    5.             }