清理项目目录,引入 InputModule 做多平台输入适配

This commit is contained in:
SepComet
2026-06-16 17:09:19 +08:00
committed by basil
parent d28ccaa7f9
commit 29c4468d54
227 changed files with 16702 additions and 2059 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 95995d871479bf14ea8fb43f508a1799
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0015eb550e61afd47b3c2b1e4b30281d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
namespace SepCore.InputModule
{
public readonly struct InputBindingSnapshot
{
public InputBindingSnapshot(string overridesJson)
{
OverridesJson = overridesJson ?? string.Empty;
}
public string OverridesJson { get; }
public bool HasOverrides => !string.IsNullOrEmpty(OverridesJson);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 37e063fcb3008b04984822e35f0fc443
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
using UnityEngine;
namespace SepCore.InputModule
{
public readonly struct InputCommand
{
public InputCommand(
InputActionId actionId,
InputContextId contextId,
InputCommandPhase phase,
InputDeviceKind deviceKind,
Vector2 vector2Value,
float scalarValue,
double time)
{
ActionId = actionId;
ContextId = contextId;
Phase = phase;
DeviceKind = deviceKind;
Vector2Value = vector2Value;
ScalarValue = scalarValue;
Time = time;
}
public InputActionId ActionId { get; }
public InputContextId ContextId { get; }
public InputCommandPhase Phase { get; }
public InputDeviceKind DeviceKind { get; }
public Vector2 Vector2Value { get; }
public float ScalarValue { get; }
public double Time { get; }
public bool IsPressed => ScalarValue > 0.5f;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5e4a224672596ce4f97e7de628bdfb74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,21 @@
namespace SepCore.InputModule
{
public readonly struct InputPrompt
{
public InputPrompt(string textLabel, string spriteName = null)
{
TextLabel = textLabel ?? string.Empty;
SpriteName = spriteName ?? string.Empty;
}
public string TextLabel { get; }
public string SpriteName { get; }
public bool HasSprite => !string.IsNullOrEmpty(SpriteName);
public bool IsValid => !string.IsNullOrEmpty(TextLabel);
public static readonly InputPrompt None = new InputPrompt(string.Empty);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
namespace SepCore.InputModule
{
public readonly struct RebindResult
{
public RebindResult(
RebindStatus status,
InputContextId contextId,
InputActionId actionId,
int bindingIndex,
string path,
string previousPath)
{
Status = status;
ContextId = contextId;
ActionId = actionId;
BindingIndex = bindingIndex;
Path = path ?? string.Empty;
PreviousPath = previousPath ?? string.Empty;
}
public RebindStatus Status { get; }
public InputContextId ContextId { get; }
public InputActionId ActionId { get; }
public int BindingIndex { get; }
public string Path { get; }
public string PreviousPath { get; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7fa4402e32895cf47bd7a4d30fb15ec7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ee3d2de89a7a3114097ea1547932e957
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
namespace SepCore.InputModule
{
public enum InputActionId
{
Unknown = 0,
Pause = 1,
Navigate = 2,
Confirm = 3,
Cancel = 4,
Move = 5,
Sprint = 6,
Interact = 7,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5744682c4d693b45aecf8397d9414c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace SepCore.InputModule
{
public enum InputCommandPhase
{
Started = 0,
Performed = 1,
Canceled = 2,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5b60a18dd87bec43a87b7a63f9dba0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
namespace SepCore.InputModule
{
public enum InputContextId
{
None = 0,
Global = 1,
UI = 2,
GameplayExplore = 3,
Dialog = 4,
Rebind = 5,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f34b39d43d5333748b77d1809281b6ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
namespace SepCore.InputModule
{
public enum InputDeviceKind
{
Unknown = 0,
KeyboardMouse = 1,
Gamepad = 2,
Touch = 3,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1205d37744db74045a2359d4185d7aa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
namespace SepCore.InputModule
{
public enum RebindStatus
{
Started = 0,
Succeeded = 1,
Canceled = 2,
Timeout = 3,
ConflictDetected = 4,
Error = 5,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0bd22251370a207409b12614eb800d72
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
namespace SepCore.InputModule
{
public interface IInputPromptMap
{
bool TryGetPrompt(InputActionId actionId, InputDeviceKind deviceKind, out InputPrompt prompt);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
{
"name": "SepCore.InputModule.Base",
"rootNamespace": "SepCore.InputModule",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d54b9488b03814a44ab937f0aeb738b1
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3d8ba5ee58ab1fc479e0969971a885a3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,79 @@
using System.Collections.Generic;
namespace SepCore.InputModule
{
public sealed class InputContextStack
{
private readonly List<InputContextId> _contexts = new List<InputContextId>();
public int Count => _contexts.Count;
public InputContextId Current => Count > 0 ? _contexts[Count - 1] : InputContextId.None;
public IReadOnlyList<InputContextId> Items => _contexts;
public bool Push(InputContextId context)
{
if (!IsStackable(context) || Current == context)
{
return false;
}
if (_contexts.Contains(context))
{
_contexts.Remove(context);
}
_contexts.Add(context);
return true;
}
public bool Pop(out InputContextId context)
{
if (Count == 0)
{
context = InputContextId.None;
return false;
}
int index = Count - 1;
context = _contexts[index];
_contexts.RemoveAt(index);
return true;
}
public bool Set(InputContextId context)
{
if (!IsStackable(context))
{
return Clear();
}
if (Count == 1 && Current == context)
{
return false;
}
_contexts.Clear();
_contexts.Add(context);
return true;
}
public bool Clear()
{
if (Count == 0)
{
return false;
}
_contexts.Clear();
return true;
}
private static bool IsStackable(InputContextId context)
{
return context != InputContextId.None && context != InputContextId.Global;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3164a25880fece946b5acf0d3d6bf006
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: