- 기본 사용법
int intValue;
floatValue = 10.5f;
void FloatToInt()
{
intValue = (int)floatValue;
}
void Start() {
FloatToInt();
print(intValue);
}
- 입력값 받기
int intValue;
floatValue = 10.5f;
floatValue2 = 20.5f;
void FloatToInt(float _parameter) // 입력 받아서 처리
{
intValue = (int)_parameter;
print(intValue);
}
void Start() {
FloatToInt(floatValue);
FloatToInt(floatValue2);
}
- 2개의 입력값 받기
int intValue;
floatValue = 10.5f;
floatValue2 = 20.5f;
void FloatToInt(float _parameter, float _parameter2)
{
intValue = (int)(_parameter + _parameter2);
print(intValue);
}
void Start() {
FloatToInt(floatValue, floatValue2);
}
- 반환값이 있는 함수 생성
int intValue;
floatValue = 10.5f;
floatValue2 = 20.5f;
int FloatToInt(float _parameter, float _parameter2)
{
return (int)(_parameter + _parameter2);
}
void Start() {
print(FloatToInt(floatValue, floatValue2));
}
- 함수 내에서 다른 함수 호출
int intValue;
floatValue = 10.5f;
floatValue2 = 20.5f;
int FloatToInt(float _parameter, float _parameter2)
{
return Multiply((int)(_parameter + _parameter2));
}
int Multiply(int _parameter)
{
return _parameter * _parameter;
}
void Start() {
print(FloatToInt(floatValue, floatValue2));
}