- Home /
Question by
EthanWZech · Aug 28, 2021 at 06:13 PM ·
c#scripting problemeditorinspectorobjects
Best way to defining scripts within a list inside the editor?
So the Faction Manager script has a list of another script called Faction. Is there any way that I can define the Faction scripts within the Faction Manager script, or is attaching multiple Faction scripts to the same object as the Faction Manager script is attached to like in the image the best way to do this?
unityarrayquestion.png
(54.0 kB)
Comment
Best Answer
Answer by Namey5 · Aug 30, 2021 at 05:00 AM
You can define Faction as just a regular class with the [Serializable] attribute rather than a component (i.e. don't inherit from MonoBehvaiour);
[System.Serializable]
public class Faction
{
public FactionEnum faction;
public Town[] ownedTowns;
public Army[] ownedArmies;
}