Esempio n. 1
0
        /// <summary> get parent Cc class</summary>
        public static Type GetParentClass(Type ccType)
        {
            //gather required
            var requiredList = BGReflectionAdapter.GetCustomAttributes(ccType, typeof(RequireComponent), true);

            if (requiredList.Length == 0)
            {
                return(null);
            }

            var result = new List <Type>();

            foreach (var item  in requiredList)
            {
                var requiredComponent = (RequireComponent)item;
                CheckRequired(requiredComponent.m_Type0, result);
                CheckRequired(requiredComponent.m_Type1, result);
                CheckRequired(requiredComponent.m_Type2, result);
            }

            if (result.Count == 0)
            {
                return(null);
            }
            if (result.Count > 1)
            {
                throw new CcException(ccType + " has more than one parent (extended from BGCc class), calculated by RequireComponent attribute");
            }
            return(result[0]);
        }
Esempio n. 2
0
        // get Unity's HelpURLAttribute attrubute
        private static HelpURLAttribute GetHelpUrl(Type type)
        {
            var propertyInfos = BGReflectionAdapter.GetCustomAttributes(type, typeof(HelpURLAttribute), false);

            if (propertyInfos.Length > 0)
            {
                return((HelpURLAttribute)propertyInfos[0]);
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>Retrieves the descriptor from "type"</summary>
        public static CcDescriptor GetDescriptor(Type type)
        {
            var propertyInfos = BGReflectionAdapter.GetCustomAttributes(type, typeof(CcDescriptor), false);

            if (propertyInfos.Length > 0)
            {
                return((CcDescriptor)propertyInfos[0]);
            }
            return(null);
        }
Esempio n. 4
0
 /// <summary> Check standard Unity's DisallowMultipleComponent attribute </summary>
 public static bool IsSingle(Type ccType)
 {
     return(BGReflectionAdapter.GetCustomAttributes(ccType, typeof(DisallowMultipleComponent), true).Length > 0);
 }