Editorwindow and MenuItem

Source: Internet
Author: User

usingUnityengine;usingSystem.Collections;usingUnityeditor; Public classclipeventeditor:editorwindow{/// <summary>    ///The MenuItem property allows you to add menu items to the main menu and the Inspector context menu///The MenuItem property turns any static function into a menu command.    Only static functions can use this MenuItem property. ///You can use the specified character to create a hotkey:% (Ctrl on Windows, CMD on OS x), # (Shift), & (Alt), _ (no modifier key). ///For example, create a menu hotkey for shift-alt-g using gameobject/do Something #&g. ///Create a menu hotkey g and no modifier keys (key combinations), use gameobject/do Something _g. ///The hotkey text must be preceded by an empty characters (Gameobject/do_g will not be interpreted as a hotkey, but gameobject/do _g so, notice that there are spaces in front of _g). ///     ///Note: This is an editor class and if you want to use it you need to put it under the Assets/editor folder in the project directory. ///the editor class is under the Unityeditor namespace.    So when using C # scripts, you need to precede the script with a "using Unityeditor" reference. /// </summary>[MenuItem ("tools/clipeventeditor%1",false)]//shortcut key ctrl+1    Static voidShow () {//static function getwindow.<t> (Utility:bool, Title:string, Focus:bool): T//returns the current First editor window of type T on the screen. //if not, creates and displays a new window and returns an instance of it. //utility is set to true to create a floating window; For dummies, create a standard window. //Title if GetWindow creates a new window, it gets the title. If this value is null, the class title is used. Getwindow<clipeventeditor> (true,"Editor"); }     PublicAnimationclip Clip;  PublicGameobject OBJ; voidOngui () {Guilayout.label ("Animation Event Editor"); //Editorguilayout.objectfield: Make an Object field. Objects can be specified either by dragging objects or by selecting objects from the Object picker. Clip = (animationclip) Editorguilayout.objectfield (clip,typeof(Animationclip),true); OBJ= (gameobject) Editorguilayout.objectfield (OBJ,typeof(Gameobject),true); if(Clip) {varEvents =animationutility.getanimationevents (Clip); if(Guilayout.button ("Show hidden Events"))            {                 for(inti =0; i < events.length; i++)                {                    if(float. Isinfinity (Events[i].time)) {Events[i].time=0; }                }                //TODO ... Save Changes            }        }    }}

Editorwindow and MenuItem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.