Hey, I know a similar topic is floating around in Answers, but it’s some years old and doesn’t work, at least for me…
So I want to copy a scriptableObject WITH its references…
CopySerialized doesn’t work as well as Instantiate… does not…
What am I doing wrong?
internal static PersonalObject Personalise(this PersonalObject pObject, Object owner)
{
string newPath = CreateAssetDirectory(pObject.GetType(), owner);
newPath = AssetDatabase.GenerateUniqueAssetPath(newPath + "/" + pObject.GetType().Name + ".asset");
PersonalObject newObject = ScriptableObject.Instantiate(pObject) as PersonalObject;
AssetDatabase.CreateAsset(newObject, newPath);
EditorUtility.CopySerialized(pObject, newObject);
newObject.isPersonalised = true;
newObject.ownerID = owner.GetInstanceID();
return newObject;
}
I shuffled order in any way I could imagine, also used AssetDatabase.CopyAsset, nothing works. Is CopySerialized supposed to use the SerializedObject?
Thanks…