/// <summary> /// Find every shape tools /// </summary> private void FindShapeEditorTools() { SortedList <int, ShapeEditorTool> tools = new SortedList <int, ShapeEditorTool>(); foreach (Type type in Assembly.GetAssembly(typeof(ShapeEditorTool)).GetTypes().Where(mType => mType.IsClass && !mType.IsAbstract && mType.IsSubclassOf(typeof(ShapeEditorTool)))) { GUIContent content = new GUIContent(); ShapeEditorTool tool = (ShapeEditorTool)Activator.CreateInstance(type, this); int order = 10000; //Get tool identity var toolIdentity = (ShapeToolAttribute)Attribute.GetCustomAttribute(tool.GetType(), typeof(ShapeToolAttribute)); if (toolIdentity != null) { content.text = toolIdentity.Name; content.tooltip = toolIdentity.Tooltip; Texture tex = (Texture)AssetDatabase.LoadAssetAtPath(toolIdentity.IconPath, typeof(Texture)); if (tex != null) { content.image = tex; } order = toolIdentity.Order; } else { content.text = tool.GetType().Name; } tool.SetEditor(this); //Set the owner editor tool.content = content; tools.Add(order, tool); } _shapeTools = new ShapeEditorTool[tools.Count]; for (int i = 0; i < tools.Count; i++) { _shapeTools[i] = tools.ElementAt(i).Value; } if (_shapeTools.Length > 0) { _currentTool = _shapeTools[0]; } }