C
unity 변수 및 함수
unix
2023. 4. 25. 19:52
using UnityEngine;
using System.Collections;
public class VariablesAndFunctions : MonoBehaviour
{
int myInt = 5; // int 타입으로 변수 myint 를 5로 초기화
void Start () // 이 스크립트와 연결된 오브젝트가 씬에 진입할때 호출되는 함수
{
myInt = MultiplyByTwo(myInt); //함수 호출. myInt는 여기서 인자(argument)
Debug.Log (myInt);
}
int MultiplyByTwo (int number) //함수는 메서드 라고도 한다. 함수는 반환이라는 작업을 한다.
{
int result;
result = number * 2;
return result; // result 변수값을 반환
}
}