- Home /
Question by
FishScrounger · Oct 28, 2015 at 12:53 PM ·
scriptableobjectscriptable objectserializable
Why do my GameObjects (prefabs) disappear from my ScriptableObject when re-opening Unity?
I have the following class
using UnityEngine;
using System; //for serializable
using System.Collections;
using System.Collections.Generic;//for list
[Serializable]
public class Scenario : ScriptableObject
{
[Serializable] //player structure, tells player what to do
public class FootballPlayer
{
public GameObject AIPlayer;
public bool waitForBall;
public bool goToNext;
public bool takeTheShot;
public Vector3 pos;
}
[Serializable] //part structure, contains everything for each part of the scenario
public class Part
{
public List<FootballPlayer> players;
public string playerHint; //used for giving the player instructions
public GameObject playerToSwitch; //the player that has the ball for the next scenario
}
public List<Part> parts; //allows flexibility when choosing number of parts
public GameObject humanPlayer; //which player will the human control
public string objectName = "Scenario"; //used for file name
}
This works perfectly with my custom editor until I close Unity. When the object is created, all the GameObjects (prefabs), strings and bools are fine but when Unity is re-opened, the strings and bools are still there but the GameObjects are all set to empty.
Comment
Your answer
Follow this Question
Related Questions
Make the same serialized class as a ScriptableObject? 1 Answer
Giving a ScriptableObject asset reference to all instances of a MonoBehavior? 0 Answers
Instancing ScriptableObject not saved in assets results in warning message 0 Answers
Why do I need to serialize a struct inside a ScriptableObject to save its data? 1 Answer
Scriptable Object is getting set to null 0 Answers