public override T GetSlotBehaviour <T> () { if (CurrentSlot != null && CurrentSlot.Behaviours != null) { for (int i = 0; i < CurrentSlot.Behaviours.Length; i++) { ItemSlotBehaviour behaviour = CurrentSlot.Behaviours[i]; if (behaviour.GetType() == typeof(T)) { return((T)behaviour); } } } if (Behaviours != null) { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; if (behaviour.GetType() == typeof(T)) { return((T)behaviour); } } } return(null); }
public virtual T GetSlotBehaviour<T> () where T : ItemSlotBehaviour { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; if (behaviour.GetType () == typeof (T)) { return (T)behaviour; } } return null; }