Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Make an editor script run on scene loaded or saved?

Discussion in 'Scripting' started by Bluestrike, Dec 1, 2014.

  1. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    http://answers.unity3d.com/question...itor-script-on-scene-load.html#comment-844475

    I have a script in every scene that assigns a unique ID to each gameObject for a save game purpose.
    I must use my own unique ID's because gameobject Instance Id's change if I load a scene and there seems to be no way to get gameobjects Local Indentiefier In File.

    I have my SaveManager that assigns ID's to savable classes run in edit mode,
    but the id's it would set would not save.

    So I made an editor script for this SaveManager that did this check instead and use EditorUtility.SetDirty ( target );
    Now the edited id's in the savable classes will save.

    Problem is that I have to manually do this check every time I want to save.

    How can I make a editor script run right before the scene is saved?
    Or having it run on a scene load would be an acceptable alternative.
    Or can I call EditorUtility.SetDirty from a normal script somehow?
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,385
  3. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    79
unityunity