当前位置:网站首页>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();
}
}
参考:
边栏推荐
- Larvel document reading notes custom authentication login and registration using larvel 8
- Experience Alibaba cloud character recognition OCR
- 第十五章 字符串本地化和消息字典(一)
- chrome瀏覽器快速訪問stackoverflow
- 松翰SN8P2511 SOP8单片机 可代烧录 提供单片机方案开发 单片机解密
- Modbus协议通信异常
- ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
- 每日一题——“水仙花数”
- 嵌入式开发板 ~ 说明
- Yingguang single chip microcomputer pms150/pmc150/pms150c consumer single chip microcomputer
猜你喜欢
Taiwan Feiling fm8pb513b MCU provides MCU program development product design
智能水电表能耗监测云平台
Keras' deep learning practice -- gender classification based on vgg19 model
Daily question - "number of daffodils"
Platform management background and merchant menu resource management: merchant role management design
【历史上的今天】7 月 2 日:BitTorrent 问世;商业系统 Linspire 被收购;索尼部署 PlayStation Now
MySQL --- 数据库的基本操作
MySQL进阶-事务及索引
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
随机推荐
ORA-19838 -- 恢复控制文件到备库
[非线性控制理论]8_三种鲁棒控制器的比较
[target tracking] |siamfc
【网络是怎样连接的】第六章 请求到达服务器以及响应给客户端(完结)
[how to connect the network] Chapter 5 explore the server
蓝牙技术|物联网的可穿戴设备新工作模式,蓝牙BLE助力新工作模式
PMS132B单片机TWS数码管蓝牙充电仓方案开发
深入理解ThreadLocal
外包干了五年,废了...
VirtualLab基础实验教程-7.偏振(1)
松翰SN8P2511 SOP8单片机 可代烧录 提供单片机方案开发 单片机解密
使用Zadig从0到1搭建持续交付平台
easyAI笔记——机器学习
【网络是怎样连接的】第五章 探索服务器
HDU - 1114 Piggy Bank (full backpack)
台湾飞凌FM8PB513B单片机提供单片机方案开发 产品设计
977.有序数组的平方
【历史上的今天】7 月 2 日:BitTorrent 问世;商业系统 Linspire 被收购;索尼部署 PlayStation Now
Daily question - inverted string
Experience Alibaba cloud character recognition OCR