Runtime Transform Gizmos Shu functions to achieve

 

table of Contents

I. Introduction:

Second, the basic configuration:

Third, expand functionality

1, achieved by pressing a button, select certain objects

Method 1 (recommended):

Method 2:

2, turn off the grid lines


 

I. Introduction:

Runtime Transform Gizmos has been introduced very detailed blog. This chapter describes the basic functions therefore no longer a. In turn achieve expansion capabilities.

 

 

Second, the basic configuration:

Reference blog: Reprinted link

 

 

Third, expand functionality

1, achieved by pressing a button, select certain objects

effect:

Method 1 (recommended):

EditorObjectSelection script add the following code:

        public void Skode_Press()
        {
            _selectedObjects.Clear();

            _selectedObjects.Add(GameObject.Find("Cube"));
            _selectedObjects.Add(GameObject.Find("Cube (1)"));
            _selectedObjects.Add(GameObject.Find("Cube (2)"));

            FindObjectOfType<EditorGizmoSystem>().GetComponent<EditorGizmoSystem>().ChangeActiveGizmo(GizmoType.Translation);
        }

 

Method 2:

The findings support the windows platform does not support WebGL when the test method. The reason is that WebGL does not support dynamic link libraries .

 Code:
EditorObjectSelection script add the following code :( untiy button key table )

        [DllImport("user32.dll", EntryPoint = "keybd_event")]
        public static extern void Keybd_event(
          byte bvk,//虚拟键值 ESC键对应的是27
          byte bScan,//0
          int dwFlags,//0为按下,1按住,2释放
          int dwExtraInfo//0
          );

        public void Skode_Press()
        {
            _selectedObjects.Clear();

            _selectedObjects.Add(GameObject.Find("Cube"));
            _selectedObjects.Add(GameObject.Find("Cube (1)"));
            _selectedObjects.Add(GameObject.Find("Cube (2)"));

            //模拟W键按下、松开。
            Keybd_event(87, 0, 0, 0);
            Keybd_event(87, 0, 2, 0);
        }

 

2, turn off the grid lines

Game display gridlines in the view, pack out of the game.

Opening and closing method:

Published 320 original articles · won praise 77 · views 170 000 +

Guess you like

Origin blog.csdn.net/weixin_38239050/article/details/103641693