@@ -82,6 +82,10 @@ public void Save(object obj, string filename, string folder = null)
8282 /// <returns>duplicated instance</returns>
8383 public object Copy ( object obj )
8484 {
85+ if ( obj is UnityEngine . Object )
86+ {
87+ throw new ArgumentException ( "UnityEngine.Object and child types not supported by copy method." ) ;
88+ }
8589 var saveLoadMethod = GetSaveLoadMethod ( saveMethod ) ;
8690 return saveLoadMethod . Copy ( obj ) ;
8791 }
@@ -95,6 +99,10 @@ public object Copy(object obj)
9599 /// <returns>duplicated instance</returns>
96100 public T Copy < T > ( T obj )
97101 {
102+ if ( obj is UnityEngine . Object )
103+ {
104+ throw new ArgumentException ( "UnityEngine.Object and child types not supported by copy method." ) ;
105+ }
98106 var saveLoadMethod = GetSaveLoadMethod ( saveMethod ) ;
99107 return ( T ) saveLoadMethod . Copy ( obj ) ;
100108 }
@@ -221,6 +229,17 @@ public bool LoadUnityObjectOverwrite(UnityEngine.Object objectToOverwrite, strin
221229 JsonUtility . FromJsonOverwrite ( savedObj . jsonData , objectToOverwrite ) ;
222230 return true ;
223231 }
232+
233+ /// <summary>
234+ /// Copies the serializable fields from one UnityEngine.Object to another
235+ /// </summary>
236+ /// <param name="toCopy">object which should be copied</param>
237+ /// <param name="toOverwrite">object onto which copied fields should be written</param>
238+ public void CopyUnityObjectOverwrite ( UnityEngine . Object toCopy , UnityEngine . Object toOverwrite )
239+ {
240+ var jsonData = JsonUtility . ToJson ( toCopy ) ;
241+ JsonUtility . FromJsonOverwrite ( jsonData , toOverwrite ) ;
242+ }
224243
225244 /// <summary>
226245 /// JsonSerializedUnityObject
0 commit comments