Created
December 7, 2014 17:43
-
-
Save DomDomHaas/74b337f8c061fa096185 to your computer and use it in GitHub Desktop.
Unity SaveHook to save all persistencyIds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using JSONPersistency; | |
using UnityEditor.Callbacks; | |
public class SaveSceneHook : AssetModificationProcessor | |
{ | |
static string[] OnWillSaveAssets (string[] paths) | |
{ | |
Object[] objs = Component.FindObjectsOfType (typeof(JSONPersistent)); | |
//Debug.Log ("OnWillSaveAssets " + objs.Length); | |
foreach (Object obj in objs) { | |
JSONPersistent persist = (JSONPersistent)obj; | |
if (!persist.persistentIDisSet ()) { | |
persist.loadPersistentID (); | |
//Debug.Log (persist.name + " loaded! persistID: " + persist.getPersistentID ()); | |
} else { | |
//Debug.Log (persist.name + " persistID: " + persist.getPersistentID ()); | |
} | |
} | |
return paths; | |
} | |
} |
Correct, in Unity 5 that doesn't same to work anymore. More here:
https://forum.unity3d.com/threads/how-to-get-the-local-identifier-in-file-for-scene-objects.265686/#post-1901969
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is not work with prefabs in Unity5, because the value LocalIdentfierInFile is 0.