발사
발사라던가 제작했습니다만 .. 데미지 구현은 모르겠고 큐 효율성을 높여주세요
This commit is contained in:
31
Assets/Scripts/InputManager.cs
Normal file
31
Assets/Scripts/InputManager.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class InputManager : MonoBehaviour
|
||||
{
|
||||
// 1. 진짜 데이터가 담길 숨겨진 변수
|
||||
private static InputSystem _inputSystem;
|
||||
|
||||
// 2. 외부에서 접근할 프로퍼티
|
||||
public static InputSystem InputSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
// 누군가 InputSystem을 찾았는데 없을 때만 새로 생성
|
||||
_inputSystem ??= new InputSystem();
|
||||
return _inputSystem;
|
||||
}
|
||||
}
|
||||
|
||||
// Start에서는 더 이상 new를 할 필요가 없습니다!
|
||||
// (위의 get에서 자동으로 해주니까요)
|
||||
private void OnEnable()
|
||||
{
|
||||
// 이때 객체가 없으면 자동으로 생성(get 호출)된 후 Enable()이 실행됩니다.
|
||||
InputSystem.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
InputSystem.Disable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user