示例#1
0
        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();
        }
示例#2
0
        public static void Remove(Guid guid)
        {
            if (_instance == null)
            {
                _instance = new GuidManager();
            }

            _instance.InternalRemove(guid);
        }
示例#3
0
        public static bool Add(Guid guid, int instanceId)
        {
            if (_instance == null)
            {
                _instance = new GuidManager();
            }

            return(_instance.InternalAdd(guid, instanceId));
        }
示例#4
0
 private void OnDestroy()
 {
     GuidManager.Remove(_guid);
 }