04_코딩기초(4)-함수 addition
04_코딩기초(4)-함수 addition
어떠한 계산을 하는 과정을 넣어두고,
어떠한 역할을 특정한 작업을 목표로 할 수 있도록 하는것
Void Start / void update→이거도 함수 중에 하나
void(자료형) addition()
public class 4 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
addition(); //2.함수 호출
}
// Update is called once per frame
void Update()
{
}
void addition()
{
Debug.Log("This is Function"); //1. 함수를 선언한것
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class 4 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
addition(10,20); //2.함수 호출 ->첫번째 인자와 두번째 인사를 호출해주는것
addition(20,30);
}
// Update is called once per frame
void Update()
{
}
void addition(int number01, int number02) //변수선언 number01.number02->인자값
{
answer = number01 + number02
Debug.Log("This is Function"); //1. 함수를 선언한것
}
}
// 함수를 넣는 이유_ 가독성
// 함수의 장점 = 재활용 가능
// 함수란 모듈이고 이걸 선언해주면 void start쪽에서 숫자를 넣어서 모듈을 불러올 수 있는것. 만약에 void addition 함수선언을 하지않았다면,
// void start에서 합에 대한 방정식을 계속 써줘야함.