当前位置:网站首页>Unity3d learning notes

Unity3d learning notes

2022-07-07 07:01:00 Tool man of konjaku

C# Basics

// Input 
int.parse(Console.ReadLine());
// Output 
Console.WriteLine();

 Pass in object x
Person xiaoming = object x as Person

unity3d

Class inheritance in the script has three default functions

Awake() Start() Update()

And variables  Insert picture description here

Commonly used gameObject,transform…

translation

transform.Translate(Vector3. up * Time. deltaTime)  

rotate

Show

setActive(boolean)

tip: Shortcut key Ctrl+N New scene

API

The coordinate is a three-dimensional vector

To obtain position , size , Rotating information

transform.position、rotation、localScale

Get other objects

 Object object= GameObject.Find(" Object name "); 
 Object object= GameObject.FindWithTag(" Object tag name ");

Get components

Component comp=gameObject.GetComponent<>()

Calling method

Invoke("Func", 1.0);  //1s Post trigger Func function 

call ( Other objects ) Method

SendMessge() command : One calls instructions on other objects ( That is, the function in the script on the object ) Methods 

Instantiate an object ( Copy )

Instantiate(object, transform.position, rotation);

Destruction of objects

Destroy(gameObject,3.0); // 3 Destroy the object in seconds 

Collision events

 If  Is Trigger  Option is checked , Once the object collides , No physical interaction , Will produce  3  Collision information is sent to the script parameters , Namely  OnTriggerEnter、OnTriggerExit、OnTriggerStay. It is often used in picking and other events .

Rewriting methods
Collider callback method :( stop )

//  The collision begins 
void OnCollisionEnter(Collision other)
//  During the collision , Once per frame 
void OnCollisionStay(Collision other)
//  End of collision 
void OnCollisionExit(Collision other)

Trigger callback method :

//  Trigger start 
void OnTriggerEnter(Collider other)
//  During triggering , Once per frame 
void void OnTriggerStay(Collider other)
//  Trigger end 
void OnTriggerExit(Collider other)

Input

原网站

版权声明
本文为[Tool man of konjaku]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070222584090.html