当前位置:网站首页>Editor编辑器扩展在Scene View添加按钮和logo
Editor编辑器扩展在Scene View添加按钮和logo
2022-07-02 16:00:00 【avi9111】
最近发现一个不得了的lego项目,
可以很简单的做出,马里奥64位那样的横版3D过关游戏
其实这个项目也在unity官方模板出现很久了,只是一直在深山修炼,孤陋寡闻
看了这个项目的logo很是喜欢

那么我们今天就来做一个
1)首先就是继承Editor Window
2)然后这样。。。。。。。。是不行的

3)原来要Editor。OnSceneUI,但我们还是直接用更内核的。 SceneView
void OnEnable()
{
SceneView.duringSceneGui += SceneGUI;
}
void OnDisable()
{
SceneView.duringSceneGui -= SceneGUI;
}4,一开始scenView 不好用,后来发现小哥的文章获得答案(下面参考链接)
一开始小哥也是用错的,各种Canvas GUIContent方案尝试,后来他成功了
void SceneGUI(SceneView view)
{
//错的
if (GUILayout.Button("fdsafadsf"))
{
}
//还是错的
GUI.Button(new Rect(10,10,100,100),"11111111");
}5)
// 绑定duringSceneGui等代码略,详见github工程
private void SceneGUI(SceneView view)
{
Handles.BeginGUI();6) 哦,对了,后来用回,继承Editor,的OnSceneGUI,根本没成功。。。。。
不知道是不是新版本Unity2020 的问题
7)最终完整代码
SceneView 的GUI,只是和普通 OnGui()略有不同,GUILayout, EditorGUILayout这些帮助类,只能少用了
// copyright (c) by [email protected]
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class LolToolsWindows : EditorWindow
{
[MenuItem("Tools/Lol/Animation Window")]
public static void ShowWnd()
{
GetWindow<LolToolsWindows>().Show();
}
void OnEnable()
{
SceneView.duringSceneGui += SceneGUI;
}
private void OnGUI()
{
if (GUILayout.Button(("创建 Animation in Scene")))
{
var go = GameObject.Find("LolSceneView");
if (go == null)
{
go = new GameObject("LolSceneView");
}
if (go.GetComponent<LolSceneMono>() == false)
{
go.AddComponent<LolSceneMono>();
}
Selection.activeObject = go;
}
}
void OnDisable()
{
SceneView.duringSceneGui -= SceneGUI;
}
void SceneGUI(SceneView view)
{
//c参考:https://zhuanlan.zhihu.com/p/124269658
Handles.BeginGUI();
GUILayout.BeginArea(view.position); // 规定显示区域为屏幕大小
if (GUILayout.Button("fdsafadsf"))
{
}
GUI.Button(new Rect(10,10,100,100),"11111111");
GUILayout.EndArea();
Handles.EndGUI();
}
}
参考:
边栏推荐
猜你喜欢

【目标跟踪】|SiamFC

USB interface powered Bluetooth color light strip controller

【网络是怎么连接的】第四章 探索接入网和网络运营商
![List summation [dummy+ tail interpolation + function processing list reference common pit]](/img/08/30e8ca2376104d648a82dca8a72c42.png)
List summation [dummy+ tail interpolation + function processing list reference common pit]

pytorch支持32位吗?

RK1126平台项目总结

【Zuul】com. netflix. zuul. exception. ZuulException: Hystrix Readed time out

Outsourcing for five years, abandoned

【Golang | gRPC】使用openssl生成证书

每日一题——“水仙花数”
随机推荐
MySQL --- 数据库的基本概念
Modbus protocol communication exception
Pms150c Yingguang MCU development case
Keras' deep learning practice -- gender classification based on vgg19 model
Troubleshooting ideas that can solve 80% of faults
977.有序数组的平方
[how is the network connected] Chapter 4 explores access networks and network operators
MySQL --- 数据库的基本操作
Solution pour arrêter automatiquement les paquets Jar en cours d'exécution en éteignant le serveur de connexion xshell
维护万星开源向量数据库是什么体验
What is the experience of maintaining Wanxing open source vector database
嵌入式开发板 ~ 说明
【历史上的今天】7 月 2 日:BitTorrent 问世;商业系统 Linspire 被收购;索尼部署 PlayStation Now
USB interface powered Bluetooth color light strip controller
easyAI笔记——深度学习
开发一个禁止删除namespace的控制器
【Golang | gRPC】使用openssl生成证书
uva1169
[非线性控制理论]7_High gain and High Frequency
辉芒微IO单片机FT60F010A-URT