- Home /
Question by
Omberone · Nov 22, 2013 at 04:39 PM ·
instantiateprefabcustomeditor
objectReference is null in prefab
Hello!
I've encountered an issue with my custom editor for my MonoBehaviour class. It seems I cannot instantiate ScriptableObjects (myQuestToEdit) and then assign them to a SerializedProperty (element) during prefab-editing. I've breakpointed the code and it seems like
element.objectReferenceValue
remains null after I assign it with
element.objectReferenceValue = ScriptableObject.CreateInstance();
This code does however work when I edit the object via the scene.
Here's a small sample of where it goes wrong. Any ideas?
myQuestToEdit = ScriptableObject.CreateInstance<MoveToInteractableQuest>();
questList.InsertArrayElementAtIndex(questList.arraySize);
SerializedProperty element = questList.GetArrayElementAtIndex(questList.arraySize-1);
element.objectReferenceValue = ScriptableObject.Instantiate(myQuestToEdit);
Comment
Your answer
Follow this Question
Related Questions
Updating a variable on a script in an instanced object 1 Answer
Instantiate object 1 Answer
Prefab instantiated wrong scale on mobile 0 Answers
autolink to prefab? 0 Answers