Unity Editor Toolbar compiler extension

Source: Internet
Author: User

Http://www.cnblogs.com/zhaoqingqing/p/3812368.html

1, apply to Prefab [apply the changes to Prefab]

if (Guilayout.button ("Apply Collider to Prefab"))            {                Prefabutility.replaceprefab (Simactor.preview, Prefabutility.getprefabparent (Simactor.preview), replaceprefaboptions.connecttoprefab);            }
2, current Sceneview center Position: Get Scene Center coordinates
For example, each time the New actor appears in the middle of the scene view

   Sceneview.onsceneguidelegate-= Oncustomscenegui;    void Oncustomscenegui (Sceneview sceneview)    {        sceneviewpos = Sceneview.pivot;    }
Create actor    void Createmapactor ()
   {        Gameobject gamelogic = Gameobject.find ("maplogic");        Gameobject newactor = gameobject.createprimitive (primitivetype.sphere);        "actor-" + UnityEngine.Random.Range (1, 999999);        Cbasetool.setchild (Newactor.transform, gamelogic.transform);        Selection.activegameobject = Newactor;        Csimactor simactor = newactor.addcomponent<csimactor> ();        NewActor.transform.position = Sceneviewpos;    } 

3. Scene Context menu[scenes view right-click menu]

You can refer to Ngui's uiwidgetcontainereditor. Nguieditortools.showspriteselectionmenu (e.mouseposition); What I've done here has not been dealt with.

Using Unityengine;Using Unityeditor; [Initializeonload] [Executeineditmode]PublicClass myscenecontext:monobehaviour{void Update () {sceneview.onsceneguidelegate = Scenecontext; }void Scenecontext (Sceneview sceneview) { if (selection.activetransform = = null) return; Transform Selecttrans = Selection.activetransform; Vector3 CurPos = selecttrans.position; Event evt = event.current; if (Evt.type = = Eventtype.contextclick) {genericmenu menu = new Genericmenu (); menu. AddItem (new Guicontent ("MenuItem1"), false, CallBack, "Item 1"), menu. AddItem (new Guicontent ("MenuItem2"), false, CallBack, "Item 2"), menu. Showascontext (); Evt. Use (); }} void CallBack (object userData) {}}            
4. Inspector Context Menu

[MenuItem ("Context/transform/mycontext1")]    void Mycontext (MenuCommand command)    {        CBase.Log ("context menu");    }  

See also: http://docs.unity3d.com/ScriptReference/MenuCommand-context.html

Http://answers.unity3d.com/questions/22947/adding-to-the-context-menu-of-the-hierarchy-tab.html

The context/{string} seems to work for components within the Inspector

You can also view Ngui\editor\nguicontextmenu.cs

Asset Store Tool Recommendation: https://www.assetstore.unity3d.com/en/#!/content/10424

Unity Editor Toolbar compiler extension

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.