private static Type[] GetRequiredComponents(Type klass) { List <Type> list = null; Type[] result; while (klass != null && klass != typeof(MonoBehaviour)) { RequireComponent[] array = (RequireComponent[])klass.GetCustomAttributes(typeof(RequireComponent), false); Type baseType = klass.BaseType; RequireComponent[] array2 = array; for (int i = 0; i < array2.Length; i++) { RequireComponent requireComponent = array2[i]; if (list == null && array.Length == 1 && baseType == typeof(MonoBehaviour)) { Type[] array3 = new Type[] { requireComponent.m_Type0, requireComponent.m_Type1, requireComponent.m_Type2 }; result = array3; return(result); } if (list == null) { list = new List <Type>(); } if (requireComponent.m_Type0 != null) { list.Add(requireComponent.m_Type0); } if (requireComponent.m_Type1 != null) { list.Add(requireComponent.m_Type1); } if (requireComponent.m_Type2 != null) { list.Add(requireComponent.m_Type2); } } klass = baseType; } if (list == null) { result = null; return(result); } result = list.ToArray(); return(result); }
private static Type[] GetRequiredComponents(Type klass) { List <Type> list = null; while (klass != null && klass != typeof(MonoBehaviour)) { object[] customAttributes = klass.GetCustomAttributes(typeof(RequireComponent), false); for (int i = 0; i < customAttributes.Length; i++) { RequireComponent requireComponent = (RequireComponent)customAttributes[i]; if (list == null && customAttributes.Length == 1 && klass.BaseType == typeof(MonoBehaviour)) { return(new Type[] { requireComponent.m_Type0, requireComponent.m_Type1, requireComponent.m_Type2 }); } if (list == null) { list = new List <Type>(); } if (requireComponent.m_Type0 != null) { list.Add(requireComponent.m_Type0); } if (requireComponent.m_Type1 != null) { list.Add(requireComponent.m_Type1); } if (requireComponent.m_Type2 != null) { list.Add(requireComponent.m_Type2); } } klass = klass.BaseType; } if (list == null) { return(null); } return(list.ToArray()); }