Programing
-
[Unity3D] Timer 만들기Programing 2021. 7. 23. 03:15
작업을 하다보면 줄어드는 타이머를 필요할 때가 있다. 코루틴을 이용하여 만들 수가 있는데. float fullTime = 200; public Text Count; bool Timerstart = false; void Update() { if (Timerstart == false) { Timerstart = true; if (fullTime > 0) { StartCoroutine(CountDown((fullTime - 1))); fullTime--; } else if (fullTime == 0) { Debug.Log("Time Over"); } } } IEnumerator CountDown(float msg) { yield return new WaitForSeconds(1.0f); int minutes ..
-
[Unity3D] Prefab 실시간 생성하기 (Instantiate)Programing 2020. 7. 3. 22:12
Unity3d를 하다보면 프리팹을 만들어 놓고, 실시간으로 불러서 사용해야 할 때가 있습니다. 그럴때 사용하는 것이 인스턴스화(Instantiate) 입니다. Asstes 경로에 Resources 폴더를 생성하고 난 후에 하위 경로에 프리팹을 생성하기만 하면 준비가 끝납니다. 그러면 간단한 방법으로 호출을 할 수 있습니다. public class prefabcopy : MonoBehaviour { GameObject prefab_obj; void Start() { prefab_obj = Resources.Load("Prefabs/prefab_sample") as GameObject; } void Update() { if (Input.GetKeyDown(KeyCode.A)) { GameObject obj ..