유니티로 배우는 c#

함수

테오구 2021. 9. 30. 14:20
728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test : MonoBehaviour
{
    int intValue;

    float floatValue = 10.5f;
    float floatValue2  = 20.1f;

// void 함수의 처리 결과에 아무런 반환값이 없을 때 사용
    void FloatToint(float parameter, float parameter2, string stringParm = "디폴트"){//stringParm의 값이 없으면 디폴트가 입력
        intValue = (int)parameter// 강제 형 변환을 일으켜줌
        print(intValue);
        print(stringParm);
    }

    int FloatToInt(float parameter, float parameter2){
        return (int)(parameter + parameter2)
    }

    // Start is called before the first frame update
    void Start()//게임이 시작될 때 최초 1회 진행되는 아이
    {
        FloatToint(floatValue, floatValue2, "테스트");
        print(FloatToInt(floatValue, floatValue2));
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
728x90

'유니티로 배우는 c#' 카테고리의 다른 글

구조체  (0) 2021.10.10
네임스페이스  (0) 2021.10.10
컬렉션  (0) 2021.10.03
지정자  (0) 2021.09.30
자료형  (0) 2021.09.30