- Home /
cloning of ScriptableObject
My scriptable objects have quite a deep and complicated set of fields and classes and so ideally I want to .Clone() them but when I implement Clone() and ICloneable all I get are references to the original scriptableObject. ScriptableObject.CreateInstance only creates an instance of the class but unfortunaltely doesn't allow an original so as parameter to clone (I am thinking List(original) here).
So how do I clone a SO ?
Recursively copy the values of the FieldInfos ?
Answer by numberkruncher · Sep 01, 2012 at 01:35 AM
I am not sure how correct this is, but it does appear to work:
MyScriptableObject clone = Object.Instantiate(original) as MyScriptableObject;
Edit: Yep, this does appear to be the intended behaviour: http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
Answer by oxium · Jul 01, 2011 at 06:16 AM
Hi !
Have you found a solution to this issue ? Would be really interested to know as I now encounter the same problem ! Merci d'avance ! ;-)