인풋매니저, 리소스매니저 구조 생성 및 리소스 정리

This commit is contained in:
2026-01-21 00:47:45 +09:00
parent de039d4ffb
commit 2eee8e2ab2
1036 changed files with 713 additions and 3137 deletions

View File

@@ -0,0 +1,20 @@
using System;
using UnityEngine;
public class InputManager
{
public Action KeytAction = null;
public void OnUpdate()
{
if (Input.anyKey == false)
{
return;
}
if (KeytAction != null)
{
KeytAction.Invoke();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8affb13a0221d604ebc76b80353674ef

View File

@@ -3,8 +3,12 @@ using UnityEngine;
public class Managers : MonoBehaviour
{
static Managers s_instance; // static으로 유일성 보장
public static Managers Instance { get { Init(); return s_instance; } } // 유일한 매니저를 가져온다.
static Managers Instance { get { Init(); return s_instance; } } // 유일한 매니저를 가져온다.
InputManager _input = new InputManager();
ResourceManager _resource = new ResourceManager();
public static InputManager Input { get { return Instance._input; } }
public static ResourceManager Resource { get { return Instance._resource; } }
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
@@ -15,7 +19,7 @@ public class Managers : MonoBehaviour
// Update is called once per frame
void Update()
{
_input.OnUpdate();
}
static void Init()

View File

@@ -0,0 +1,30 @@
using UnityEngine;
public class ResourceManager
{
public T Load<T>(string path) where T : Object
{
return Resources.Load<T>(path);
}
public GameObject Instantiate(string path, Transform parent = null)
{
GameObject prefab = Load<GameObject>($"Prefabs/{path}");
if (prefab == null)
{
Debug.Log($"Failed to load prefab : {path}");
return null;
}
return Object.Instantiate(prefab, parent);
}
public void Destroy(GameObject go)
{
if (go == null)
{
return;
}
Object.Destroy(go);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 02a54b2c0d9166a4fad881d75ebc136b

View File

@@ -3,7 +3,6 @@ using TreeEditor;
using UnityEngine;
using Quaternion = UnityEngine.Quaternion;
using Vector3 = UnityEngine.Vector3;
public class PlayerController : MonoBehaviour
{
[SerializeField]
@@ -11,44 +10,39 @@ public class PlayerController : MonoBehaviour
void Start()
{
Managers.Input.KeytAction -= OnKyeboard;
Managers.Input.KeytAction += OnKyeboard;
}
float _yAngle = 0.0f;
void Update()
{
_yAngle += Time.deltaTime * 100.0f;
// 절대 회전값 지정해서 회전
// transform.eulerAngles = new Vector3(0.0f, _yAngle, 0.0f);
// +- delta 값을 특정 축으로 회전
// transform.Rotate(new Vector3(0.0f, Time.deltaTime * 100.0f, 0.0f));
}
// transform.rotation = Quaternion.Euler(new Vector3(0.0f, _yAngle, 0.0f));
void OnKyeboard()
{
if (Input.GetKey(KeyCode.W))
{
transform.rotation = Quaternion.LookRotation(Vector3.forward);
// transform.Translate(Vector3.forward * Time.deltaTime * _speed);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3.forward), 0.2f);
transform.position += (Vector3.forward * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.S))
{
transform.rotation = Quaternion.LookRotation(Vector3.back);
// transform.Translate(Vector3.back * Time.deltaTime * _speed);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3.back), 0.2f);
transform.position += (Vector3.back * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.A))
{
transform.rotation = Quaternion.LookRotation(Vector3.left);
// transform.Translate(Vector3.left * Time.deltaTime * _speed);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3.left), 0.2f);
transform.position += (Vector3.left * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.D))
{
transform.rotation = Quaternion.LookRotation(Vector3.right);
// transform.Translate(Vector3.right * Time.deltaTime * _speed);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3.right), 0.2f);
transform.position += (Vector3.right * Time.deltaTime * _speed);
}
}
}