Menu学习
本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/Unity_Menu.html
using UnityEditor;
using UnityEngine;
public class Menu : MonoBehaviour { // Add a menu item named "Do Something" to MyMenu in the menu bar.
[MenuItem ("MyMenu/Do Something")]
static void DoSomething () {
Debug.Log ("Doing Something...");
} // Validated menu item.
// Add a menu item named "Log Selected Transform Name" to MyMenu in the menu bar.
// We use a second function to validate the menu item
// so it will only be enabled if we have a transform selected.
[MenuItem ("MyMenu/Log Selected Transform Name")]
static void LogSelectedTransformName ()
{
Debug.Log ("Selected Transform is on " + Selection.activeTransform.gameObject.name + ".");
} // Validate the menu item defined by the function above.
// The menu item will be disabled if this function returns false.
[MenuItem ("MyMenu/Log Selected Transform Name", true)]
static bool ValidateLogSelectedTransformName () {
// Return false if no transform is selected.
return Selection.activeTransform != null;
} // Add a menu item named "Do Something with a Shortcut Key" to MyMenu in the menu bar
// and give it a shortcut (ctrl-g on Windows, cmd-g on OS X).
[MenuItem ("MyMenu/Do Something with a Shortcut Key %g")]
static void DoSomethingWithAShortcutKey () {
Debug.Log ("Doing something with a Shortcut Key...");
} // Add a menu item called "Double Mass" to a Rigidbody's context menu.
[MenuItem ("CONTEXT/Rigidbody/Double Mass")]
static void DoubleMass (MenuCommand command) {
Rigidbody body = (Rigidbody)command.context;
body.mass = body.mass * ;
Debug.Log ("Doubled Rigidbody's Mass to " + body.mass + " from Context Menu.");
} // Add a menu item to create custom GameObjects.
// Priority 1 ensures it is grouped with the other menu items of the same kind
// and propagated to the hierarchy dropdown and hierarch context menus.
[MenuItem("GameObject/MyCategory/Custom Game Object", false, )]
static void CreateCustomGameObject(MenuCommand menuCommand) {
// Create a custom game object
GameObject go = new GameObject("Custom Game Object");
// Ensure it gets reparented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
}

Menu学习的更多相关文章
- 【转】 Pro Android学习笔记(三三):Menu(4):Alternative菜单
目录(?)[-] 什么是Alternative menu替代菜单 小例子说明 Alternative menu代码 关于Category和规范代码写法 关于flags 多个匹配的itemId等参数 什 ...
- 值得 Web 开发人员学习的20个 jQuery 实例教程
这篇文章挑选了20个优秀的 jQuery 实例教程,这些 jQuery 教程将帮助你把你的网站提升到一个更高的水平.其中,既有网站中常用功能的的解决方案,也有极具吸引力的亮点功能的实现方法,相信通过对 ...
- Android -- Options Menu,Context Menu,Popup Menu
Options Menu 创建选项菜单的步骤: 1. ...
- [转载-仅为个人学习所用]Stack Menu
http://code4app.com/ios/51fa7d7e6803fa2710000006 我有个很牛的同学朋友同事舍友···他技术牛人,写的博客都是原创,粉丝无数,说实话我真的挺妒嫉的,试过为 ...
- Editor Scripting学习笔记之Menu Item
主要用到: MenuItem属性 MenuCommand参数 可能用到: EditorApplication类 Selection类 GameObjectUtility类 FileUtil类 Undo ...
- Android学习笔记——Menu(三)
知识点 今天继续昨天没有讲完的Menu的学习,主要是Popup Menu的学习. Popup Menu(弹出式菜单) 弹出式菜单是一种固定在View上的菜单模型.主要用于以下三种情况: 为特定的内容提 ...
- Android学习笔记——Menu(二)
知识点: 这次将继续上一篇文章没有讲完的Menu的学习,上下文菜单(Context menu)和弹出菜单(Popup menu). 上下文菜单 上下文菜单提供对UI界面上的特定项或上下文框架的操作,就 ...
- 【转】 Pro Android学习笔记(三四):Menu(5):动态菜单
目录(?)[-] OptionsMenu的创建方式 如何再次创建OptionsMenu 每次访问都重新填充菜单项 OptionsMenu的创建方式 OptionMenu在第一次访问该菜单时调用,只调用 ...
- 【转】 Pro Android学习笔记(三五):Menu(6):XML方式 & PopUp菜单
目录(?)[-] 利用XML创建菜单 XML的有关属性 onClick事件 Pop-up菜单 利用XML创建菜单 在代码中对每个菜单项进行设置,繁琐且修改不灵活,不能适配多国语言的要求,可以利用资源进 ...
随机推荐
- Solr4.8.0源码分析(6)之非排序查询
Solr4.8.0源码分析(6)之非排序查询 上篇文章简单介绍了Solr的查询流程,本文开始将详细介绍下查询的细节.查询主要分为排序查询和非排序查询,由于两者走的是两个分支,所以本文先介绍下非排序的查 ...
- Stockbroker Grapevine
http://poj.org/problem?id=1125 #include<cstdio> #include<cstring> #include<cmath> ...
- 海园帮忙写的JQUERY功能,实现了我们想要的,我觉得有点屌哟~~
需求就是为了可以在WEB在线更新代码期间,如果执行时间较长的话, 就在提交按钮之后,按钮变为灰色. 同时,一个DIV里每隔两秒刷新输出. 当更新完成之后(检测文档中的关键字串),按钮变为可提交状态~~ ...
- Spring Boot + Elasticsearch
spring data elasticsearch elasticsearch 2.0.0.RELEASE 2.2.0 1.4.0.M1 1.7.3 1.3.0.RELEASE 1.5.2 1.2.0 ...
- 多线程同步、异步(BeginInvoke)
一.线程的基础知识 1 System.Threading.Thread类 System.Threading.Thread是用于控制线程的基础类,通过Thread可以控制当前应用程序域中线程的创建.挂起 ...
- Posix-linux_route
route命令显示或者修改本地IP路由表. 语法: [plain] route [-CFvnee] route [-v] [-A family] add [-net|-host] ...
- Magician - hdu 5316 (区间查询合并)
题意:有一个区间,然后有两种操作 1. 把a处的值改为b 0,查询区间ab的子序列的最大和,这个比较特殊,子序列里面相邻的数要有不同的奇偶性 ***************************** ...
- iOS音频处理
ios音频处理 1. iOS底层音频处理技术(带源代码) http://www.cocoachina.com/ios/20111122/3563.html 2.ios 音频入门 http://blog ...
- 什么是券商PB业务
PB业务(Prime Broker,主经纪商业务).所谓PB业务就是指向对冲基金等高端机构客户提供集中托管清算.后台运营.研究支持.杠杆融资.证券拆借.资金募集等一站式综合金融服务的统称.而该业务的基 ...
- MVC4 Razor视图下使用iframe加载RDLC报表
MVC视图下默认是不支持服务器端控件的,所以,为了能够通过report viewer控件加载报表,需要在MVC视图添加嵌入的页面. 起初在stackoverflow上找到一个解决方案,见这里.不过这里 ...