A few tips for getting started with Unity

This article is a little common sense for getting started, mainly for introduction, and does not involve detailed content 


1. Adjust the camera of the scene view

  1. Alt + left click drag: rotate
  2. Alt+Ctrl+left-click drag: parallel movement
  3. Mouse Wheel: Zoom
  4. After selecting the object, move the mouse to the scene , then press F, the camera will move to the object

2. Be sure to terminate the game before editing

Because any changes made while the game is running will be restored to the initial value after the game is stopped

3. Rigidbody component

After adding a Rigidbody component to an object, its motion will be controlled by the Unity physics engine. Even without adding any code, Rigidbody objects are subject to downward gravity and react when they collide with other objects (if the appropriate  Collider  component is also present).

4. The script class name should be the same as the file name

When creating a new script, the class name will automatically keep the same as the file name. However, if you modify the file name later, the class name will not change automatically, so you need to change the class name yourself.

Five, MonoBehaviour

MonoBehaviour is a base class from which all Unity scripts are derived.

When using C#, you must explicitly derive from MonoBehaviour.
The class does not support  the null conditional operator  ( ?. ) and  the null coalescing operator  ( ?? ).
Note: In the Unity editor there is a checkbox to enable or disable MonoBehaviour. It disables the function when unchecked. If none of these functions exist in the script, the Unity editor does not show the checkbox. These functions are:
Start ()
Update ()
FixedUpdate ()
LateUpdate ()
OnGUI ()
OnDisable ()
OnEnable ()

六、Rigidbody.velocity

The velocity vector of the rigid body. It represents the rate of change of the position of the rigid body.

In most cases, velocity should not be modified directly, as this can lead to distorted behavior - use AddForce instead. Do not set the velocity of an object at each physics step, this will result in an unrealistic physics simulation. A typical use where speed needs to be changed is in the design of a jumping motion in a first-person shooter game, where the speed needs to be changed immediately.

7. Vector3

Used to represent 3D vectors and points.

Unity internally uses this structure to communicate 3D position and orientation. Additionally, it contains functions for performing common vector operations.

8. Default

It is very important to get in the habit of using it as a default when creating new game objects

Nine, GameObject

The base class for all entities in a Unity scene.

十、Debug.Break

Pause the Editor.

This is useful when you want to inspect some value on that Inspector and you can't pause it manually.

Guess you like

Origin blog.csdn.net/m0_63024355/article/details/130444685