示例#1
0
 /// <summary>
 /// Generates new Guid. Be careful with this method. It should be called only in specific cases.
 /// </summary>
 public void RegenerateGuid()
 {
     GuidManagerSingleton.Remove(guid);
     serializedGuid   = null;
     guid             = Guid.Empty;
     cachedStringGuid = null;
     CreateGuid();
 }
示例#2
0
        /// <summary>
        /// Sets guid. Be careful with this method. It should be called only in specific cases.
        /// </summary>
        /// <param name="value">New guid</param>
        public void SetGuid(Guid value)
        {
            cachedStringGuid = null;
            Guid?oldGuid = null;

            if (IsGuidAssigned())
            {
                oldGuid = guid;
                GuidManagerSingleton.Remove(guid);
            }

            guid = value;
            if (!GuidManagerSingleton.Add(guid, gameObject))
            {
                Debug.LogError($"Trying to set invalid guid: {value}. Previous guid restored.");
                if (oldGuid.HasValue)
                {
                    guid = oldGuid.Value;
                    GuidManagerSingleton.Add(guid, gameObject);
                }
            }
        }
示例#3
0
 // let the manager know we are gone, so other objects no longer find this
 public void OnDestroy()
 {
     GuidManagerSingleton.Remove(guid);
 }