Practice_Unity/Assets/Scripts/Scenes/BaseScene.cs
SEAN-59 ee2026017f 작업
1. 리소스 메니저 생성
2. 풀 매니저 생성
3. 조이스틱 생성 - 조이스틱 이미지 잘 움직이는것도 확인 함

To-Do
1. 조이스틱과 플레이어 캐릭터를 연결하는 로직
2. 몬스터 이동 로직을 고민해서 구현해보기
2025-09-21 23:55:29 +09:00

50 lines
1.5 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem; // InputSystem 사용을 위해 추가
public class BaseScene : MonoBehaviour
{
List<GameObject> _activeObjects = new List<GameObject>();
void Start()
{
// "Prefabs/Test" 전체 경로를 사용하도록 수정
Manager.Pool.CreatePool("Prefabs/Test", 3);
Manager.Pool.CreatePool("Prefabs/Player", 3);
CreateJoyStick();
}
void Update()
{
// Input System 방식으로 수정
if (Keyboard.current.aKey.wasPressedThisFrame)
{
Debug.Log("Pop !");
// "Prefabs/Test" 전체 경로를 사용하도록 수정
GameObject go = Manager.Pool.Pop("Prefabs/Test");
if (go != null)
{
go.transform.position = new Vector3(Random.Range(-5f, 5f), Random.Range(0f, 5f), 0);
_activeObjects.Add(go);
}
}
// Input System 방식으로 수정
if (Keyboard.current.sKey.wasPressedThisFrame)
{
Debug.Log("Push All!");
foreach (GameObject go in _activeObjects)
{
Manager.Pool.Push(go);
}
_activeObjects.Clear();
}
}
void CreateJoyStick()
{
GameObject joystick = Manager.Resource.Instantiate("Prefabs/UI/JoyStick", GameObject.Find("@Scene").transform);
joystick.AddComponent<VirtualJoystick>();
}
}