C# void Start(), void Update()
2023. 1. 5. 23:48ㆍ개인적인 공부/Unity
What are Method?
Methods (also called Functions) execute blocks of code that makes our game do things
We can:
Use the methods already available in Unity
Create our own methods
Creating And Calling
When we CREATE a method, we are giving it a name and saying what if should do.
처음에 C# Script를 생성하면 나오는 것.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
void Start() : 시작하자마자.
transform Rotation 에 z 축 을 45도 기울인다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
void Start()
{
transform.Rotate(0,0,45);
}
void Update()
{
}
}
void Update() 프레임 마다 출력한다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
void Start()
{
}
void Update() //프레임마다 호출된다.
{
transform.Rotate(0,0,45);
}
}
45 에서 0.1 f 로 변경
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
void Start()
{
}
void Update() //프레임마다 호출된다.
{
transform.Rotate(0,0,0.1f);
}
}
'개인적인 공부 > Unity' 카테고리의 다른 글
C# Time.deltaTime (0) | 2023.01.12 |
---|---|
C# Input.GetAxis() (0) | 2023.01.10 |
Serialize Field 사용방법 (0) | 2023.01.10 |
C# 변수 (0) | 2023.01.10 |
C# Transform.Translate() (1) | 2023.01.10 |