} // For external access of script void Awake() { if (Ref == null) { Ref = GetComponent <ManFactory>(); } }
public static void Demo() { ManFactory manFactory = new ManFactory(); WomanFactory womanFactory = new WomanFactory(); RobotFactory robotFactory = new RobotFactory(); List <Person> people = new List <Person> { manFactory.CreatePerson(), womanFactory.CreatePerson(), robotFactory.CreatePerson(), robotFactory.CreatePerson(), manFactory.CreatePerson(), }; foreach (Person item in people) { item.doSomethins(); } }