J's Study log

[Unity] Script 본문

Computer Language/Unity

[Unity] Script

정우섭 2019. 2. 23. 02:16

Unity users usually make scripts by C#. So I recommend you to use C# Script.


Click left mouse button on Project View to create a C# Script. You can find void Start() and void Update() functions. Start() function is activated when the game starts. And Update() function is activated every frame of the game. You have to write in 'Debug.log(A)'. A is what you call on the console log. This is the variable you've coded on the script.


We call each things in Start() and Update(), Start Method and Update Method.


public class fileName:MonoBehavior{

void Start(){

start method

}

void Update(){

update method

}

.

.

.

}


This is just a formal thing to make a class in C#. And you can add new function below Update() function, but because the system in Unity only calls Start() and Update() two function, you have to call the function you made in them to use it.


If you want to see the log of an object on console. First the object needs script component. So you have to drag the script file to the object you want to code.

'Computer Language > Unity' 카테고리의 다른 글

[Unity] Camera Work  (0) 2019.02.25
[Unity] GetComponent  (0) 2019.02.23
[Unity] Physics Material  (0) 2019.02.21
[Unity] Component  (0) 2019.02.19
[Unity] Camera & Light  (0) 2019.02.19
Comments