Skip to content

Instantly share code, notes, and snippets.

@JoseMiguelPizarro
JoseMiguelPizarro / LevelMeshEditor.cs
Created August 31, 2019 12:41
Initializing select button
[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);
@JoseMiguelPizarro
JoseMiguelPizarro / LevelMeshEditor.cs
Created August 31, 2019 12:54
toolsButton GUIContent[]
[CustomEditor(typeof(LevelMesh))]
public class LevelMeshEditor : Editor
{
private GUIContent selectButton;
private string selectButtonIconPath = "Assets/Resources/Icons/select.png";
private GUIContent[] toolsButton;
private void OnEnable()
{
@JoseMiguelPizarro
JoseMiguelPizarro / LevelMeshEditor.cs
Last active August 31, 2019 13:01
Rendering tool bar
private int toolBarWidth = 50;
private int selectedTool;
private void OnSceneGUI()
{
DrawToolBar(SceneView.lastActiveSceneView);
}
public void DrawToolBar(SceneView view)
{
private void OnSceneGUI()
{
DrawToolBar(SceneView.lastActiveSceneView);
DoAction();
}
private void DoAction()
{
switch (selectedTool)
{
[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";
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; }
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)
{
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)
{
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();
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))