当前位置:网站首页>[100 unity stepping pit knowledge points] | draw cube dotted line and sphere dotted line (gizmos auxiliary wireframe) in the editor

[100 unity stepping pit knowledge points] | draw cube dotted line and sphere dotted line (gizmos auxiliary wireframe) in the editor

2022-06-21 12:18:00 Hua Weiyun

 Insert picture description here

Unity Little science popularization

Old rules , Let me introduce you Unity A little knowledge of popular science :

  • Unity yes real time 3D Interactive content creation and operation platform .
  • Include Game development The fine arts Architecture Automobile design Movies All creators including , With the help of Unity Turn ideas into reality .
  • Unity The platform provides a complete set of software solutions , Can be used to create 、 Operate and realize any real-time interactive 2D and 3D Content , Support platforms include mobile phone The tablet PC Game consoles Augmented reality and Virtual reality device .
  • You can also simply put Unity Understood as a The game engine , It can be used for professional production game

Unity Step on the pit to learn a little knowledge

Draw a cube dashed line in the editor 、 Sphere dotted line (Gizmos Auxiliary wireframe )

Use Gizmos Class allows us to Unity An auxiliary wireframe is implemented in , Here are some common wireframes .

added API You can come The official manual is about Gizmos see

Use Gizmos Drawing wireframe is used in the following two functions :

private void OnDrawGizmos(){   Debug.Log(" Keep calling " );}private void OnDrawGizmosSelected(){    Debug.Log("selected, Only when the object is selected, it is called " );}

You can also use Gizmos.color Color change .

Be careful : Under normal circumstances, only in Scene See wireframe in , stay Game To open... In the view Gizmos Before you can see the wireframe
 Insert picture description here

The dashed boxes of cube and sphere are as follows :
 Insert picture description here

    private void OnDrawGizmos()    {        Gizmos.color = Color.green;// Change the color of the wireframe         Gizmos.DrawWireCube(transform.position, new Vector3(3, 3, 3));// Cube dashed box         Gizmos.DrawWireSphere(transform.position, 5f);// Sphere dashed box     }

The cube and sphere wireframes are as follows :
 Insert picture description here

    private void OnDrawGizmos()    {        Gizmos.color = Color.green;// Change the color of the wireframe         Gizmos.DrawCube(transform.position, new Vector3(3, 3, 3));// Cube wireframe         Gizmos.DrawSphere(transform.position, 5f);// Sphere wireframe     }

 Insert picture description here

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211059224443.html