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에서 합에 대한 방정식을 계속 써줘야함.
'Metaverse World Creator > Unity & C#' 카테고리의 다른 글
06_유니티에서 스크립트와 API (0) | 2022.05.11 |
---|---|
05_유니티에서 스크립트 생성하기 / C# void strat / void update의 차이 (0) | 2022.05.09 |
03_코딩기초(3)-반복문 for / while (0) | 2022.05.07 |
02_코딩기초(2)-조건문 if / else if (0) | 2022.05.06 |
01_C# 기초 코딩(1) 변수 (0) | 2022.05.04 |