I’m aware this problem has been asked like 1000 times. As far as I can tell, though, my setup is fine, and I’ve done this before. I have the usual issue: I edit my object, but it will not keep those values when I reload the scene. Interestingly enough, it appears to sometimes keep the values when I go to play mode, which as I understood before should have meant it was working. Guess not.
Another super weird thing: when I am editing an object that’s in the scene view (selected from the hierarchy window), the editor shows up properly in the inspector and I can do whatever. But when I try to edit the prefab (selected from the project window), the inspector shows absolutely no properties, just the script name that I can tab open or closed (to no effect).
So here’s my (partial) code:
public class CritterView : MonoBehaviour
{
[SerializeField]
protected List<CritterVisualPart> visualParts;
protected Animator animator;
public void Start()
{
//WARNING - before this happens, you should have set the Random.seed to be what you wanted!
if ( visualParts == null )
{
visualParts = new List<CritterVisualPart>();
}
PopulatePartsRandomly();
}
public List<CritterVisualPart> VisualParts
{
get
{
return visualParts;
}
set
{
visualParts = value;
}
}
[System.Serializable]
public class CritterVisualPart
{
[SerializeField]
protected string name;
[SerializeField]
protected string copiedPartName;
[SerializeField]
protected List<CritterVisualOption> options;
[System.Serializable]
public class CritterVisualOption
{
public enum Type
{
Sprite = 0,
Prefab,
Count
};
[SerializeField]
protected GameObject prefab;
[SerializeField]
protected Sprite sprite;
[SerializeField]
protected Type type;
And the editor:
[CustomEditor(typeof(CritterView))]
public class CritterViewEditor : Editor
{
public override void OnInspectorGUI()
{
CritterView critterView = target as CritterView;
List<CritterVisualPart> parts = GetNewParts( critterView );
for ( int partIndex = 0; partIndex < parts.Count; partIndex++ )
{
ShowVisualPartGUI( parts, parts[ partIndex ] );
GUILayout.Space( 16 );
}
critterView.VisualParts = parts;
EditorUtility.SetDirty( critterView );
}
Is it because I’m nesting serialized objects or something? As far as I know that should work.
Also, does anyone know where I can actually go look at the YAML that gets generated for the prefabs? Doesn’t appear to be in the meta file. Seems like that would be a good way to diagnose issues.