Hi all.
Just as the title says - is there any equivalent to [System.Serializable] on Monobehaviour classes so I could put that into another class and its properties could be still editable in the inspector?
Basically what I am trying to do is to be able to create mission objectives in the Unity inspector that may dynamically change during the game and this functionality could be very useful, but I am not sure if it’s even possible.
So I have this MissionObjectives class (simplified) which derives from MonoBehaviour. I would like to put this class into another MonoBehaviour class and still be able to edit its serializable classes properties in the Unity inspector. Is it possible?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class MissionObjectives: MonoBehaviour
{
[Serializable]
public class Objective
{
[Serializable]
public class EntityToSpawn
{
public Entity entity_pref;
public Transform spawnPosition;
}
public string objectiveDescription;
public List<EntityToSpawn> entitiesToSpawn = new List<EntityToSpawn>();
public List<Entity> entitiesToDestroy = new List<Entity>();
public void StartObjective()
{
}
public void UpdateObjective()
{
}
}
public List<Objective> objectives = new List<Objective>();
void Start()
{
objectives[0].StartObjective ();
}
}