当前位置:网站首页>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();
}
}
参考:
边栏推荐
- [how is the network connected] Chapter 6 requests arrive at the server and respond to the client (end)
- 我的创作纪念日
- Huimang micro IO MCU ft60f010a-urt
- [comment le réseau se connecte] chapitre 6: demande d'accès au serveur et réponse au client (terminé)
- 应广单片机003烧录器自定义封装使用技巧
- 义隆EM78P153K DIP14单片机 MCU
- 应广单片机PMS150/PMC150/PMS150C消费类单片机
- Wechat applet - arrows floating up and down
- uva1169
- POJ - 1458 Common Subsequence(最长公共子序列)
猜你喜欢
My creation anniversary
Laravel文档阅读笔记-Custom Authentication Login And Registration Using Laravel 8
Navigateur Chrome pour un accès rapide au stackoverflow
[how is the network connected] Chapter 6 requests arrive at the server and respond to the client (end)
透过华为军团看科技之变(六):智慧公路
2 juillet: BitTorrent est sorti; L'acquisition du système commercial linspire; Sony Deployment PlayStation now
[nonlinear control theory]8_ Comparison of three robust controllers
每日一题——倒置字符串
Chrome browser quick access stackoverflow
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
随机推荐
嵌入式开发板 ~ 说明
详解Kubernetes网络模型
【網絡是怎樣連接的】第六章 請求到達服務器以及響應給客戶端(完結)
Ssm+ wechat applet to realize property management system
[how is the network connected] Chapter 6 requests arrive at the server and respond to the client (end)
Yingguang pmc131 SOP16 16pin eight bit MCU
Songhan sn8p2511 sop8 single chip microcomputer can be used for burning, providing single chip microcomputer scheme development and single chip microcomputer decryption
Atcoder beginer contest 237 VP supplement
Easyswoole3.2 restart failed
Solution pour arrêter automatiquement les paquets Jar en cours d'exécution en éteignant le serveur de connexion xshell
EdgeNeXt打出了一套混合拳:集CNN与Transformer于一体的轻量级架构
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
567.字符串中的排列
台湾飞凌FM8PB513B单片机提供单片机方案开发 产品设计
finally详解
What is the experience of maintaining Wanxing open source vector database
基数排序的简单理解
如何下载微信支付证书(API证书)
POJ - 1458 Common Subsequence(最长公共子序列)
MySQL --- 数据库的基本概念