Search Unity

2018.3 Setting active state by code will not be saved in prefab

Discussion in 'Editor & General Support' started by SevenPointRed, Dec 13, 2018.

  1. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    218
    I have an editor script that gets the currently selected object and loops over all its children setting gameObject.SetActive(...) on anything that should be enabled or disabled by default.

    This no longer works as the new prefab system will not detect it as a change, I have to manually change anything in the prefab and back again for it to trigger a save.

    Is there any way to get this working with new prefabs?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,610
  3. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    218
    Yeah, the old system i had used SetDirty and I added:

    PrefabUtility.RecordPrefabInstancePropertyModifications(target.gameObject);

    Neither does anything.