public static pb_TypeInspectorAttribute GetAttributeValue(pb_TypeInspector ti) { var att = ti.GetType().GetCustomAttribute(typeof(pb_TypeInspectorAttribute), true) as pb_TypeInspectorAttribute; if (att != null && att is pb_TypeInspectorAttribute) { return(att); } return(null); }
private static void InitializeLookup() { inspectorPool = new Dictionary <Type, GameObject>(); inspectorLookup = new Dictionary <IEnumerable <pb_TypeInspectorAttribute>, GameObject>(); foreach (GameObject go in Resources.LoadAll(TYPE_INSPECTOR_PATH, typeof(GameObject))) { pb_TypeInspector typeInspector = go.GetComponent <pb_TypeInspector>(); if (typeInspector == null) { continue; } IEnumerable <Attribute> typeAttribs = (IEnumerable <Attribute>)typeInspector.GetType().GetCustomAttributes(true); inspectorLookup.Add(typeAttribs.Where(x => x != null && x is pb_TypeInspectorAttribute).Cast <pb_TypeInspectorAttribute>(), go); } }