private void CreateGuid() { if (serializedGuid == null || serializedGuid.Length != 16) { _guid = Guid.NewGuid(); #if UNITY_EDITOR if (PrefabUtility.IsPartOfNonAssetPrefabInstance(this)) { PrefabUtility.RecordPrefabInstancePropertyModifications(this); } #endif } else if (_guid == Guid.Empty) { _guid = new Guid(serializedGuid); } var instanceId = GetInstanceID(); while (!GuidManager.Add(_guid, instanceId)) { _guid = Guid.NewGuid(); } serializedGuid = _guid.ToByteArray(); }
public static void Remove(Guid guid) { if (_instance == null) { _instance = new GuidManager(); } _instance.InternalRemove(guid); }
public static bool Add(Guid guid, int instanceId) { if (_instance == null) { _instance = new GuidManager(); } return(_instance.InternalAdd(guid, instanceId)); }
private void OnDestroy() { GuidManager.Remove(_guid); }