Unity3d quickly captures the pivot point of a scene object by name

Source: Internet
Author: User

Using unityengine;using system.collections;using unityeditor; ///<summary>///quickly captures scene object pivot points by name///</ Summary>public class quickgetpivot:editorwindow{ ///<summary> ///defining variables  ///</summary >  private string objectnamestring = "";  private gameobject Mygameobject;                //Storage scenario Gameobject  private int[] Intarray = new int[] {0 , 1, 2, 3, 4};  //top effects  private int headint = 0; private int bottomfootstepsint = 0; private int Hipchestint = 0; private int handfootint = 0; private int weaponint = 0; private int NormalSpecialInt = 0;& Nbsp; private string[] head_string = new string[] {"Choose A Effect", "Head_c_effectpoint", "Head_t_effectpoint"};& Nbsp;private string[] bottomfootsteps_string = new string[] {"Choose A Effect", "Bottom_effectpoint", "FOOTSTEPS_EFFECTP Oint "}; private string[] hipchest_string = new string[] {" Choose A Effect "," Hip_effectpoint "," Chest_effectpoint "}; private string[] handfoot_string = new string[] {" Choose a Eff ECT "," Hand_l_effectpoint "," Hand_r_effectpoint "," Foot_l_effectpoint "," Foot_r_effectpoint "}; private string[ ] weapon_string = new string[] {"Choose A Effect", "Weapon01_effectpoint", "Weapon02_effectpoint", "Weapon03_effectpoint "}; private string[] normalspecial_string = new string[] {" Choose A Effect "," Normal_hurtpoint "," Special_hurtpoint "};  ///<summary>im ///Create, display form  ///</summary> [@MenuItem (" Custom/Effect/ Quickgetpivot ")]  private static void Init ()  {  quickgetpivot window = (quickgetpivot) GetWindow ( typeof (Quickgetpivot), True, "Quickgetpivot");   window. Show (); }     ///<summary> ///Display the contents of the form  ///</summary>  private void Ongui ()  {  //effectpopup  headint = editorguilayout.intpopup ("Top Effect", Headint, Head_string, intarray);  bottomfootstepsint = Editorguilayout.intpopup ("Bottom effect", Bottomfootstepsint, BottomFootsteps_ String, intarray);  hipchestint = Editorguilayout.intpopup ("Bone Effects", Hipchestint, Hipchest_string, IntArray);   Handfootint = Editorguilayout.intpopup ("hands and feet effects", Handfootint, Handfoot_string, intarray);  WeaponInt = Editorguilayout.intpopup ("Weapon effects", Weaponint, Weapon_string, intarray);  normalspecialint = Editorguilayout.intpopup ("Hit Effects", Normalspecialint, Normalspecial_string, Intarray);    if ( Guilayout.button ("Get Object Pivot"))   {   getsceneobjectpivot (); } }   // /<summary> ///Get object pivot point  ///</summary> /// private void Getsceneobjectpivot () in scene  {     //Console output objectnamestring    switch (headint)   {   case 1:     objectnamestring = "Head_c_effectpoint";    break;   case 2:    Objectnamestring = "Head_t_effectpoint";    break; }    switch (bottomfootstepsint)   {   Case 1:   objectnamestring = ' bottom_effectpoint ';   break;  case 2:    objectnamestring = "Footsteps_effectpoint";   break; }   switch (hipchestint)   {  Case 1:   objectnamestring = "Hip_effectpoint";   break;  case 2:    objectnamestring = "Chest_effectpoint";   break; }    switch (handfootint)   {   Case 1:   objectnamestring = ' hand_l_effectpoint ';   break;  case 2:    objectnamestring = "Hand_r_effectpoint";   break;  case 3:   objectnamestring = "Foot_l_ Effectpoint ";   break;  case 4:   objectnamestring =" Foot_r_effectpoint ";   break ; }    switch (weaponint)   {  case 1:   objectnamestring = "Weapon01_effectpoint ";   break;  case 2:   objectnamestring =" Weapon02_effectpoint ";   break;  case 3:   objectnamestring = "Weapon03_effectpoint";   break; }    Switch (normalspecialint)   {  case 1:   objectnamestring = "Normal_hurtpoint";    break;  case 2:   objectnamestring = "Special_hurtpoint";   break; }    if (""! = objectnamestring)   {    mygameobject = Gameobject.find (objectnamestring);   &NBSP;IF (null! = Mygameobject)    {    Selection.activetransform = mygameobject.transform;  & nbsp;}    else   {    debug.logwarning ("No Such Object in scene!");     Selection.activetransform = null;   }    headint = 0;    Bottomfootstepsint = 0;   hipchestint = 0;   handfootint = 0;   WeaponINT = 0;   normalspecialint = 0;    objectnamestring = "";    Debug.Log ( objectnamestring); }  else  {   debug.logwarning ("Choose A Effect first!");  } }}

Unity3d quickly captures the pivot point of a scene object by name

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.