Unity3D基础-菜单栏详解

Unity3D基础-菜单栏详解,第1张

1、虽然Unity支持中文项目路径,但我还是建议使用英文路径,以免出现BUG。

2、Create project :为创建项目。

3、项目模板的选择,可汪洞以在项目中随时更改为3D或者2D。

场景视图(Scene View):用于设置场景以及放置游戏对象,是构造游戏场景的地方。

游戏视图(Game View):由场景中相机所渲染的游戏画面,是游戏发布后玩家所能看到歼陵则的内容。

层级视图(Hierarchy):用于显示当前场景中所有游戏对象的层级关系。

项目视图(Project):整个工程中的所有可用的资源,比如脚本,材质等等。

检视视图(Inspector):用于显示当前所选择游戏对象的相关属性与信息。

帮助菜单有Unity的相关资源链接,也可以对软件的授权许可进行相应的管理。

About Unity:用来检查 正在运行的是哪个Unity版本.

Manage License:用于将免费版的或者是试用版的更新到完整版Unity.

Unity Manual: 学习Unity所有功能的资源.

Reference Manual:学习所有可以连接到GameObject的可用组件的指南.

Scrioting Reference :使用Unity API编写游戏玩法脚本的文档

Unity Forunm:Unity的文档之外解决问题的资源氏棚.

Unity Answers :寻找难题答案的社区

Unity Feedback :给Unity Technologies提供反馈,并请求在以后的版本中加入额外的工能.

Check for Updates :用于检查Unity的更新版本.

using UnityEngine

using UnityEditor

using System.Collections

// This example shows how to create a context menu inside a custom EditorWindow.

// context-click the green area to show the menu

public class GenericMenuExample : EditorWindow

{

[MenuItem("Example/Open Window")]

static void Init()

{

var window = GetWindow<GenericMenuExample>()

window.position = new Rect(50, 50, 250, 60)

window.Show()

}

void Callback(object obj)

{

Debug.Log("Selected: " + obj)

}

void OnGUI()

{

Event currentEvent = Event.current

Rect contextRect = new Rect(10, 10, 100, 100)

EditorGUI.DrawRect(contextRect, Color.green)

if (currentEvent.type == EventType.ContextClick)

{

Vector2 mousePos = currentEvent.mousePosition

if (contextRect.Contains(mousePos))

{

// Now create the menu, add items and show it

GenericMenu menu = new GenericMenu()

menu.AddItem(new GUIContent("MenuItem1"), false, Callback, "item 1")

menu.AddItem(new GUIContent("MenuItem2"), false, Callback, "item 2")

menu.AddSeparator("")

menu.AddItem(new GUIContent("SubMenu/MenuItem3"), false, Callback, "item 3")

menu.ShowAsContext()

currentEvent.Use()

}

}

}

}

using UnityEngine

using UnityEditor

using System.Collections

// This example shows how to create a context menu inside a custom EditorWindow.

// context-click the green area to show the menu

public class GenericMenuExample : EditorWindow

{

[MenuItem("Example/Open Window")]

static void Init()

{

var window = GetWindow<GenericMenuExample>()

window.position = new Rect(50, 50, 250, 60)

window.Show()

}

void Callback(object obj)

{

Debug.Log("Selected: " + obj)

}

void OnGUI()

{

Event currentEvent = Event.current

RectcontextRect = new Rect(10, 10, 100, 100)

EditorGUI.DrawRect(contextRect, Color.green)

if (currentEvent.type == EventType.ContextClick)

{

Vector2mousePos = currentEvent.mousePosition

if (contextRect.Contains(mousePos))

{

// Now create the menu, add items and show it

GenericMenumenu = new GenericMenu()

menu.AddItem(new GUIContent("MenuItem1"), false, Callback, "item 1")

menu.AddItem(new GUIContent("MenuItem2"), false, Callback, "item 2")

menu.AddSeparator("")

menu.AddItem(new GUIContent("SubMenu/MenuItem3"), false, Callback, "item 3")

menu.ShowAsContext()

currentEvent.Use()

}

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11988408.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存