first
This commit is contained in:
50
Runtime/Engine/Code/Services/Input/InputService.cs
Normal file
50
Runtime/Engine/Code/Services/Input/InputService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
public class InputService : IService {
|
||||
[Serializable]
|
||||
public class Config {
|
||||
public InputActionAsset InputAsset;
|
||||
}
|
||||
|
||||
private Config _config;
|
||||
|
||||
public InputService(Config config) {
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public void EnableControls() {
|
||||
_config.InputAsset.Enable();
|
||||
}
|
||||
|
||||
public void DisableControls() {
|
||||
_config.InputAsset.Disable();
|
||||
}
|
||||
|
||||
public InputAction FindInputAction(string path) {
|
||||
return _config.InputAsset.FindAction(path);
|
||||
}
|
||||
|
||||
public void LockCursor() {
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
public void UnlockCursor() {
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Services/Input/InputService.cs.meta
Normal file
3
Runtime/Engine/Code/Services/Input/InputService.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6ee7382dba74afe84aaf53259b1cf8a
|
||||
timeCreated: 1740769896
|
||||
14
Runtime/Engine/Code/Services/Input/InputServiceAsset.cs
Normal file
14
Runtime/Engine/Code/Services/Input/InputServiceAsset.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
[CreateAssetMenu(menuName = RConsts.ServiceAssetMenu + "Input")]
|
||||
public class InputServiceAsset : ServiceAsset<InputService> {
|
||||
[SerializeField]
|
||||
private InputService.Config _config;
|
||||
|
||||
public override InputService Create() {
|
||||
return new InputService(_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fcf71fe79ef1ed4cbfdefde09e708d9
|
||||
12
Runtime/Engine/Code/Services/Input/ScriptableInputAction.cs
Normal file
12
Runtime/Engine/Code/Services/Input/ScriptableInputAction.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input
|
||||
{
|
||||
[CreateAssetMenu(menuName = RConsts.AssetMenu + "Input Action", fileName = "Input Action")]
|
||||
public class ScriptableInputAction : ScriptableObject
|
||||
{
|
||||
[field: SerializeField]
|
||||
public InputAction Action { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8d574cf0e024ec7bc4363a675dbb2c9
|
||||
timeCreated: 1740768148
|
||||
Reference in New Issue
Block a user