当前位置:网站首页>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();
}
}
参考:
边栏推荐
- Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service
- Chrome browser quick access stackoverflow
- Pms150c Yingguang MCU development case
- Pms132b single chip microcomputer TWS digital tube Bluetooth charging chamber program development
- 嵌入式开发板 ~ 说明
- 【Golang | gRPC】使用openssl生成证书
- The price is only 40 yuan. Pico development board of raspberry pie is added with WiFi module, and it is out of stock as soon as it comes into the market
- Longest non repeating subarray
- Platform management background and business menu resource management: business permissions and menu resource management design
- 能解决 80% 故障的排查思路
猜你喜欢

Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer

Redisson 高性能 Redis 分布式锁源码分析

PFC232-SOP8/14/16应广一级可带烧录程序编带

VirtualLab基础实验教程-7.偏振(1)

Daily question - "number of daffodils"

aloam 代码阅读与总结

嵌入式 ~ 介绍

The price is only 40 yuan. Pico development board of raspberry pie is added with WiFi module, and it is out of stock as soon as it comes into the market

Modbus protocol communication exception

Two pieces of nature a day! Duan Fengfeng, an alumnus of the University of science and technology of China, was the third Chinese winner of the belby medal
随机推荐
VirtualLab基础实验教程-7.偏振(1)
Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service
POJ - 1458 common subsequence (longest common subsequence)
Solution pour arrêter automatiquement les paquets Jar en cours d'exécution en éteignant le serveur de connexion xshell
HBuilderX运行到手机或模拟器提示没有找到设备
wps插入图片后使图片完整显示
售价仅40元,树莓派Pico开发板加入WiFi模块,刚上市就脱销
Easyai notes - machine learning
【网络是怎样连接的】第六章 请求到达服务器以及响应给客户端(完结)
wait_for_gap -- 从主库归档备库恢复归档
Virtual lab basic experiment tutorial -7 Polarization (2)
What should we pay attention to in the development process of Yingguang single chip microcomputer?
Daily question - "number of daffodils"
Easyswoole3.2 restart failed
ORA-19838 -- 恢复控制文件到备库
Two pieces of nature a day! Duan Fengfeng, an alumnus of the University of science and technology of China, was the third Chinese winner of the belby medal
嵌入式开发板 ~ 说明
php获取两个时间戳之间相隔多少天多少小时多少分多少秒
Experience Alibaba cloud character recognition OCR
外包干了五年,废了...