static void Awake() { stateQueues.Clear(); foreach (var fi in typeof(StateBus).GetFields()) { if (typeof(IStateQueue).IsAssignableFrom(fi.FieldType)) { IStateQueue stateQueue = fi.GetValue(null) as IStateQueue; //create StateQueue object, if not created if (stateQueue == null) { stateQueue = Activator.CreateInstance(fi.FieldType) as IStateQueue; fi.SetValue(null, stateQueue); } //save to queues list stateQueues.Add(stateQueue); } } OnAwake(); }
static void Awake() { stateQueues.Clear(); foreach (var fi in typeof(StateBus).GetFields()) { if (typeof(IStateQueue).IsAssignableFrom(fi.FieldType)) { #pragma warning disable IDE0019 // Используйте сопоставление шаблонов IStateQueue stateQueue = fi.GetValue(null) as IStateQueue; #pragma warning restore IDE0019 // Используйте сопоставление шаблонов //create StateQueue object, if not created if (stateQueue == null) { stateQueue = Activator.CreateInstance(fi.FieldType) as IStateQueue; fi.SetValue(null, stateQueue); } //save to queues list stateQueues.Add(stateQueue); } } OnAwake(); }