반응형
반응형
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Threading.Tasks; public class Example : MonoBehaviour { int number = 0; private void Start() { Task.Run(() => Testing()); } async Task Testing() { await Task.Run(() => { while(number < 500) { number++; } }); await Task.Delay(5000); } }
인터페이스 선언 using System.Collections; using System.Collections.Generic; using UnityEngine; public class InterfaceManager : MonoBehaviour { } public interface IButtonClick { void Initalize(); void OnClick(); } 인터페이스 활용 (상속 받을 시 무조건 구현해야함) using System.Collections; using System.Collections.Generic; using UnityEngine; public class ExampleOne : IButtonClick { public int number = 0; public void Initaliz..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class Example : MonoBehaviour { int a = 0; int b = 0; private void Start() { a = 5; b = 4; CheckAction(a + b, ResultAction); } public void CheckAction(int number, Action action) { if(number > 10) { action.Invoke(true); } else { action.Invoke(false); } } public void ResultAction(bool check) {..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Button[] buttons; private void Start() { for(int i = 0; i OnClick(temp + i)); } } void OnClick(int number) { Debug.Log(number); } } 리스너 제거 (제거 안해줄경우 ..
유니티 C# 예외처리 Try Catch Finally 문 간단 사용법Try Catch Finally 문을 사용하는 이유는?프로그램 실행 중 예외상황이 발생하면 프로그램이 멈춰버리기 때문에 예외처리를 해줘서 멈추지 않게 만들어줍니다. 코드 작성using System.Collections;using System.Collections.Generic;using UnityEngine;using System;public class Example : MonoBehaviour{ int a = 0; int b = 0; int result = 0; private void Start() { try { result = a + b; De..
For문 for (int i = 0; i < 10; i++) { Debug.Log("Iteration " + i); } Foreach문 int[] numbers = {1, 2, 3, 4, 5}; foreach (int number in numbers) { Debug.Log("Number: " + number); } While문 int count = 0; while (count < 5) { Debug.Log("Count: " + count); count++; }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { int a = 0; int b = 0; string s = "안녕하세요"; string t = "반갑습니다"; private void Start() { if (a > b) { Debug.Log("a가 b보다 큽니다."); } else { Debug.Log("a가 b보다 같거나 작습니다."); } if (s.Equals(t)) { Debug.Log("서로 같습니다."); } else { Debug.Log("서로 다릅니다."); } switch(a) { case..
구글 로그인 SDK 설치 GitHub - playgameservices/play-games-plugin-for-unity: Google Play Games plugin for Unity Google Play Games plugin for Unity. Contribute to playgameservices/play-games-plugin-for-unity development by creating an account on GitHub. github.com 구글 로그인 구현 using GooglePlayGames; using GooglePlayGames.BasicApi; using PlayFab; using PlayFab.ClientModels; using PlayFab.Json; using PlayFab...
코드 작성using PlayFab;using PlayFab.ClientModels;using PlayFab.Json;using PlayFab.ProfilesModels;using System;using System.Collections;using System.Collections.Generic;using System.Linq;using UnityEngine;using EntityKey = PlayFab.ProfilesModels.EntityKey;public class PlayfabManager : MonoBehaviour{ private string customId = ""; private string playfabId = ""; private string entityId = ""; ..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Text versionText; private void Awake() { Application.targetFrameRate = 60; //프레임 조절 Screen.sleepTimeout = SleepTimeout.NeverSleep; //잠들지 않도록 설정 Screen.sleepTimeout = SleepTimeout.SystemSetting; //시스템 설정 사용 versionText.text = Application.version;..
델리게이트 선언 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public delegate void GameEvent(); //이벤트 선언 public static event GameEvent eGameStart, eGamePause, eGameEnd; public delegate void ScoreEvent(int number); //이벤트 선언 public static event ScoreEvent ePlusScore, eMinusScore; private void Start() { eGameStar..
데이터 저장 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { private void SetValue() { PlayerPrefs.SetFloat("Apple", 1.0f); PlayerPrefs.SetInt("Orange", 1); PlayerPrefs.SetString("Banana", "Banana"); } } 데이터 불러오기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { pri..