This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CustomEditor(typeof(LevelMesh))] | |
public class LevelMeshEditor : Editor | |
{ | |
private GUIContent selectButton; | |
private string selectButtonIconPath = "Assets/Resources/Icons/select.png"; | |
private void OnEnable() | |
{ | |
Texture2D selectButtonIcon = AssetDatabase.LoadAssetAtPath<Texture2D>(selectButtonIconPath); | |
selectButton = new GUIContent(selectButtonIcon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CustomEditor(typeof(LevelMesh))] | |
public class LevelMeshEditor : Editor | |
{ | |
private GUIContent selectButton; | |
private string selectButtonIconPath = "Assets/Resources/Icons/select.png"; | |
private GUIContent[] toolsButton; | |
private void OnEnable() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int toolBarWidth = 50; | |
private int selectedTool; | |
private void OnSceneGUI() | |
{ | |
DrawToolBar(SceneView.lastActiveSceneView); | |
} | |
public void DrawToolBar(SceneView view) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnSceneGUI() | |
{ | |
DrawToolBar(SceneView.lastActiveSceneView); | |
DoAction(); | |
} | |
private void DoAction() | |
{ | |
switch (selectedTool) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CustomEditor(typeof(LevelMesh))] | |
public class LevelMeshEditor : Editor | |
{ | |
private int toolBarWidth = 60; | |
private int selectedTool; | |
private GUIContent selectButton; | |
private GUIContent resizeButton; | |
private string selectButtonIconPath = "Assets/Resources/Icons/select.png"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public abstract class LevelMeshTool | |
{ | |
public abstract string IconPath { get; } | |
public abstract string ToolName { get; } | |
public GUIContent Content { get; set; } | |
public Texture2D IconTexture { get; set; } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class SelectTool : LevelMeshTool | |
{ | |
public override string IconPath => "Assets/Resources/Icons/select.png"; | |
public override string ToolName => "Select tool"; | |
public override void Act(LevelMeshEditor editorState, Event current) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ResizeTool : LevelMeshTool | |
{ | |
public override string IconPath => "Assets/Resources/Icons/resize.png"; | |
public override string ToolName => "Resize"; | |
public override void Act(LevelMeshEditor editorState, Event current) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System; | |
public static class LevelMeshToolProvider | |
{ | |
private static IEnumerable<Type> GetAllTypes(AppDomain domain) | |
{ | |
foreach (var assembly in domain.GetAssemblies()) | |
{ | |
Type[] types = assembly.GetTypes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System; | |
public static class LevelMeshToolProvider | |
{ | |
public static List<LevelMeshTool> tools = new List<LevelMeshTool>(); | |
static LevelMeshToolProvider() | |
{ | |
foreach (var type in GetAllTypes(AppDomain.CurrentDomain)) |
OlderNewer