/// <summary> /// Find a custom component with the given type /// </summary> /// <param name="type">The type to find</param> /// <param name="component">The component returned if one is found. Otherwise this will be null</param> /// <returns>Returns a boolean based on if a component was found</returns> public bool FindCustomComponentFromType(Type type, out CustomComponentType component) { for (int i = 0; i < customComponents.Count; i++) { CustomComponentType customComponent = customComponents[i]; if (customComponent.script == null || customComponent.type == null) { customComponent.UpdateScriptType(); } if (customComponent.script == null) { continue; } // Not a good work around if (customComponent.type == type) { component = customComponent; return(true); } } component = null; return(false); }
// GUI private void DrawMonobehaviour(Rect rect, Component component, CustomComponentType componentType, Settings settings) { Type type = component.GetType(); if (!settings.globalData.showAllComponents) { if (componentType.script == null) { return; } if (!componentType.shown) { return; } } string path = AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(component as MonoBehaviour)); GUIContent content = new GUIContent(AssetDatabase.GetCachedIcon(path)); componentTypes.Add(type); DrawComponentIcon(rect, content, type); }