예제 #1
0
        public void Awake()
        {
            if (_current != null && _current != this)
            {
                var existing = _current;

                /* We intentionally use Current rather than _current here, as _current may contain a reference to a manager in another scene,
                 * but Current only returns the Manager for the active scene. */
                if (Current != null)
                {
                    existing.Merge(this);
                    if (gameObject.name.Contains("Easy Save 3 Manager"))
                    {
                        Destroy(this.gameObject);
                    }
                    else
                    {
                        Destroy(this);
                    }
                    _current = existing; // Undo the call to Current, which may have set it to NULL.
                }
            }
            else
            {
                _current = this;
            }
        }
예제 #2
0
 // Merges two managers, not allowing any clashes of IDs
 public void Merge(ES3ReferenceMgrBase otherMgr)
 {
     foreach (var kvp in otherMgr.idRef)
     {
         Add(kvp.Value, kvp.Key);
     }
 }
예제 #3
0
        public long GetOrAdd(UnityEngine.Object obj)
        {
            var id = Get(obj);

            // Only add items to global references when it's not playing.
            if (!Application.isPlaying && id == -1 && UnityEditor.AssetDatabase.Contains(obj) && ES3ReferenceMgr.CanBeSaved(obj))
            {
                id = ES3ReferenceMgrBase.GetNewRefID();
                refId.Add(obj, id);

                UnityEditor.EditorUtility.SetDirty(this);
            }

            return(id);
        }
예제 #4
0
 // Merges two managers, not allowing any clashes of IDs
 public void Merge(ES3ReferenceMgrBase otherMgr)
 {
     foreach (var kvp in otherMgr.idRef)
     {
         // Check for duplicate keys with different values.
         UnityEngine.Object value;
         if (idRef.TryGetValue(kvp.Key, out value))
         {
             if (value != kvp.Value)
             {
                 throw new ArgumentException("Attempting to merge two ES3 Reference Managers, but they contain duplicate IDs. If you've made a copy of a scene and you're trying to load it additively into another scene, generate new reference IDs by going to Assets > Easy Save 3 > Generate New Reference IDs for Scene. Alternatively, remove the Easy Save 3 Manager from the scene if you do not intend on deleting any data from it.");
             }
         }
         else
         {
             idRef.Add(kvp.Key, kvp.Value);
         }
     }
 }
예제 #5
0
 public void Awake()
 {
     if (_current != null && _current != this)
     {
         _current.Merge(this);
         if (gameObject.name.Contains("Easy Save 3 Manager"))
         {
             Destroy(this.gameObject);
         }
         else
         {
             Destroy(this);
         }
     }
     else
     {
         _current = this;
     }
 }
예제 #6
0
        public long GetOrAdd(UnityEngine.Object obj)
        {
            if (Application.isPlaying)
            {
                ES3Debug.LogError("GetOrAdd can only be called in the Editor, not during runtime");
                return(-1);
            }

            var id = Get(obj);

            if (id == -1 && UnityEditor.AssetDatabase.Contains(obj) && ES3ReferenceMgr.CanBeSaved(obj))
            {
                id = ES3ReferenceMgrBase.GetNewRefID();
                refId.Add(obj, id);

                UnityEditor.EditorUtility.SetDirty(this);
            }

            return(id);
        }
예제 #7
0
 public void Awake()
 {
     /* We intentionally use Current and _current here, as _current may contain a reference to a manager in another scene,
      * but Current only returns the Manager for the active scene. */
     if (_current != null && _current != this && Current != null)
     {
         _current.Merge(this);
         if (gameObject.name.Contains("Easy Save 3 Manager"))
         {
             Destroy(this.gameObject);
         }
         else
         {
             Destroy(this);
         }
     }
     else
     {
         _current = this;
     }
 }
예제 #8
0
 public static long GetNewRefID()
 {
     return(ES3ReferenceMgrBase.GetNewRefID());
 }