유니티 95

SpawnSystem 구현

각 스테이지 별로 직접 Spawn하는 Enemy와 Spawn 시간을 입력해서 게임 난이도를 조절 가능 구현 방법 1. SpawnSystem 생성 빈 게임오브젝트로 SpawnSystem을 추가하고, 자식으로 빈 게임오브젝트로 Spawn 위치를 추가 2. 스크립트 작성 SpawnSystem using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpawnSystem : MonoBehaviour { [System.Serializable] public struct StageInfo { public int Stage; public string[] enemys; // enemy + 생성되는 시간 입력 ex)..

유니티 2024.03.21

롱클릭 구현 (Event Trigger)

롱클릭 구현 1. Event Trigger 추가 2. Pointer Up, Pointer Down 추가 3. 스크립트 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerAttack : MonoBehaviour { public float minClickTime = 1; // 최소 클릭시간 private float _clickTime; // 클릭 중인 시간 private bool _isClick; // 클릭 중인지 판단 // 버튼 클릭이 시작했을 때 public void ButtonDown() { _isClick = true; } // 버튼 클릭이 끝났을 때 public void..

유니티 2024.03.19

방치형 보상 구현

방치형 보상 DateTime.Now 로 저장 시간을 구해서 PlayerPrefs로 로컬 저장 DateTime.Now로 현재 시간을 구해서 종료 후, 경과한 시간을 구해서 시간에 따른 보상 지급 구현 방법 스크립트 작성 DataManager using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.UI; using TMPro; public class DataManagerJaeMin : MonoBehaviour { [Header("Reward")] [SerializeField] private GameObject _rewardMenu; [SerializeField] pr..

유니티 2024.02.08

게임 종료

public void ExitGame(){ // 현재 실행 환경이 에디터이면 에디터 플레이모드 종료 #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; // 현재 실행 환경이 에디터가 아니면 프로그램 종료 #else Application.Quit(); #endif}   종료 시, 실행 함수private void OnApplicationQuit(){ if(CurrentSceneName == "MultiBattleScene1") { if(GameManager.I.DataManager.GameData.RankPoint >= 1) GameManager.I.DataManager.GameD..

유니티 2024.02.07

로딩 씬 구현

로딩 화면이 필요한 이유게임 씬이 전환 될 때, 다음 씬에서 사용될 리소스들을 읽어와서 게임을 위한 준비 작업로딩 화면이 없다면 가만히 멈춘 화면이나 까만 화면만 보일 수 있음  구현 방법1. LoadingScene 생성 및 Image 추가  2. Slider 추가  3. 스크립트 작성LoadingSceneusing System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.SceneManagement;public class LoadingScene : MonoBehaviour{ public static string NextScene; [SerializeFiel..

유니티 2024.02.01

튜토리얼

준비 1. Tutorial 빈 게임오브젝트 생성 및 UI 생성 Tutorial 빈 게임오브젝트에 Canvas 추가, Canvas의 자식으로 튜토리얼 UI 생성 2. Area 설정 Area가 필요한 경우, Tutorial 빈 게임오브젝트에 Area를 IsTrigger로 설정, 햇갈리지 않게 Tutorial의 숫자와 맞춰준다. 스크립트 1. IslandTutorial using System.Collections; using System.Collections.Generic; using UnityEngine; public class IslandTutorial : MonoBehaviour { [Header("Tutorial")] [SerializeField] private GameObject[] _tutorial..

유니티 2024.01.31