완
This commit is contained in:
15
.idea/.idea.UnicornElimination/.idea/.gitignore
generated
vendored
Normal file
15
.idea/.idea.UnicornElimination/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# 디폴트 무시된 파일
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider에서 무시된 파일
|
||||||
|
/contentModel.xml
|
||||||
|
/.idea.UnicornElimination.iml
|
||||||
|
/modules.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
# 에디터 기반 HTTP 클라이언트 요청
|
||||||
|
/httpRequests/
|
||||||
|
# 쿼리 파일을 포함한 무시된 디폴트 폴더
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
4
.idea/.idea.UnicornElimination/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.UnicornElimination/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
.idea/.idea.UnicornElimination/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.UnicornElimination/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/.idea.UnicornElimination/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.UnicornElimination/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ ScriptedImporter:
|
|||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
generateWrapperCode: 0
|
generateWrapperCode: 1
|
||||||
wrapperCodePath:
|
wrapperCodePath: Assets/Scripts/UnicornInputSystem.cs
|
||||||
wrapperClassName:
|
wrapperClassName: UnicornInputSystem
|
||||||
wrapperCodeNamespace:
|
wrapperCodeNamespace:
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ GameObject:
|
|||||||
- component: {fileID: 68822292}
|
- component: {fileID: 68822292}
|
||||||
- component: {fileID: 68822294}
|
- component: {fileID: 68822294}
|
||||||
- component: {fileID: 68822295}
|
- component: {fileID: 68822295}
|
||||||
|
- component: {fileID: 68822296}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -273,7 +274,7 @@ Rigidbody2D:
|
|||||||
m_Mass: 1
|
m_Mass: 1
|
||||||
m_LinearDamping: 0
|
m_LinearDamping: 0
|
||||||
m_AngularDamping: 0.05
|
m_AngularDamping: 0.05
|
||||||
m_GravityScale: 1
|
m_GravityScale: 10
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_IncludeLayers:
|
m_IncludeLayers:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -285,6 +286,20 @@ Rigidbody2D:
|
|||||||
m_SleepingMode: 1
|
m_SleepingMode: 1
|
||||||
m_CollisionDetection: 1
|
m_CollisionDetection: 1
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
|
--- !u!114 &68822296
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 68822291}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: db8b3864bdcf65d40b42ee58c17e87aa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::PlayerMovement
|
||||||
|
moveSpeed: 8
|
||||||
|
jumpForce: 20
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -366,7 +381,7 @@ Camera:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_ClearFlags: 2
|
m_ClearFlags: 2
|
||||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
m_BackGroundColor: {r: 0.21960786, g: 0.21960786, b: 0.21960786, a: 1}
|
||||||
m_projectionMatrixMode: 1
|
m_projectionMatrixMode: 1
|
||||||
m_GateFitMode: 2
|
m_GateFitMode: 2
|
||||||
m_FOVAxisMode: 0
|
m_FOVAxisMode: 0
|
||||||
@@ -644,6 +659,50 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1472544503
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1472544505}
|
||||||
|
- component: {fileID: 1472544504}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: UnicornInput
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1472544504
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1472544503}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: caadd15da6c47e04a83c5441344e74c0, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::UnicornInput
|
||||||
|
--- !u!4 &1472544505
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1472544503}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.67683, y: 0.09318, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1660057539 &9223372036854775807
|
--- !u!1660057539 &9223372036854775807
|
||||||
SceneRoots:
|
SceneRoots:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -652,3 +711,4 @@ SceneRoots:
|
|||||||
- {fileID: 619394802}
|
- {fileID: 619394802}
|
||||||
- {fileID: 68822293}
|
- {fileID: 68822293}
|
||||||
- {fileID: 603434665}
|
- {fileID: 603434665}
|
||||||
|
- {fileID: 1472544505}
|
||||||
|
|||||||
@@ -1,16 +1,38 @@
|
|||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
public class PlayerMovement : MonoBehaviour
|
public class PlayerMovement : MonoBehaviour
|
||||||
{
|
{
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
public float moveSpeed;
|
||||||
|
public float jumpForce;
|
||||||
|
|
||||||
|
private Rigidbody2D _rb;
|
||||||
|
private UnicornInputSystem _unicorn;
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_unicorn.Player.Jump.performed -= Jump;
|
||||||
|
}
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
_rb = GetComponent<Rigidbody2D>();
|
||||||
|
_unicorn = UnicornInput.Unicorn;
|
||||||
|
_unicorn.Player.Jump.performed += Jump;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
|
private void Jump(InputAction.CallbackContext obj)
|
||||||
{
|
{
|
||||||
|
_rb.linearVelocityY = jumpForce;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
var readValue = _unicorn.Player.Horizontal.ReadValue<float>();
|
||||||
|
_rb.linearVelocityX = readValue * moveSpeed;
|
||||||
|
if (_unicorn.Player.Down.IsPressed() && _rb.linearVelocityY < jumpForce/1.5)
|
||||||
|
_rb.linearVelocityY = Math.Min(0, _rb.linearVelocityY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
Assets/Scripts/UnicornInput.cs
Normal file
30
Assets/Scripts/UnicornInput.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class UnicornInput : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static UnicornInputSystem Unicorn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
_unicorn ??= new UnicornInputSystem();
|
||||||
|
return _unicorn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UnicornInputSystem _unicorn;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_unicorn ??= new UnicornInputSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
Unicorn.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
Unicorn.Disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/UnicornInput.cs.meta
Normal file
2
Assets/Scripts/UnicornInput.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: caadd15da6c47e04a83c5441344e74c0
|
||||||
577
Assets/Scripts/UnicornInputSystem.cs
Normal file
577
Assets/Scripts/UnicornInputSystem.cs
Normal file
@@ -0,0 +1,577 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||||
|
// version 1.19.0
|
||||||
|
// from Assets/InputSystem_Actions.inputactions
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.InputSystem.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides programmatic access to <see cref="InputActionAsset" />, <see cref="InputActionMap" />, <see cref="InputAction" /> and <see cref="InputControlScheme" /> instances defined in asset "Assets/InputSystem_Actions.inputactions".
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// using namespace UnityEngine;
|
||||||
|
/// using UnityEngine.InputSystem;
|
||||||
|
///
|
||||||
|
/// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
|
||||||
|
/// public class Example : MonoBehaviour, MyActions.IPlayerActions
|
||||||
|
/// {
|
||||||
|
/// private MyActions_Actions m_Actions; // Source code representation of asset.
|
||||||
|
/// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
|
||||||
|
///
|
||||||
|
/// void Awake()
|
||||||
|
/// {
|
||||||
|
/// m_Actions = new MyActions_Actions(); // Create asset object.
|
||||||
|
/// m_Player = m_Actions.Player; // Extract action map object.
|
||||||
|
/// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnDestroy()
|
||||||
|
/// {
|
||||||
|
/// m_Actions.Dispose(); // Destroy asset object.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnEnable()
|
||||||
|
/// {
|
||||||
|
/// m_Player.Enable(); // Enable all actions within map.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnDisable()
|
||||||
|
/// {
|
||||||
|
/// m_Player.Disable(); // Disable all actions within map.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #region Interface implementation of MyActions.IPlayerActions
|
||||||
|
///
|
||||||
|
/// // Invoked when "Move" action is either started, performed or canceled.
|
||||||
|
/// public void OnMove(InputAction.CallbackContext context)
|
||||||
|
/// {
|
||||||
|
/// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// // Invoked when "Attack" action is either started, performed or canceled.
|
||||||
|
/// public void OnAttack(InputAction.CallbackContext context)
|
||||||
|
/// {
|
||||||
|
/// Debug.Log($"OnAttack: {context.ReadValue<float>()}");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #endregion
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
public partial class @UnicornInputSystem: IInputActionCollection2, IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying asset instance.
|
||||||
|
/// </summary>
|
||||||
|
public InputActionAsset asset { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance.
|
||||||
|
/// </summary>
|
||||||
|
public @UnicornInputSystem()
|
||||||
|
{
|
||||||
|
asset = InputActionAsset.FromJson(@"{
|
||||||
|
""version"": 1,
|
||||||
|
""name"": ""InputSystem_Actions"",
|
||||||
|
""maps"": [
|
||||||
|
{
|
||||||
|
""name"": ""Player"",
|
||||||
|
""id"": ""23e63a77-aaa3-4fcd-bb66-31913284fe35"",
|
||||||
|
""actions"": [
|
||||||
|
{
|
||||||
|
""name"": ""Horizontal"",
|
||||||
|
""type"": ""Value"",
|
||||||
|
""id"": ""100a554f-b568-427c-b2a9-d6cafc7d9d0a"",
|
||||||
|
""expectedControlType"": ""Axis"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Jump"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""f45129b6-6739-442e-acd0-d6070dab4308"",
|
||||||
|
""expectedControlType"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Down"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""2c15cba3-2056-4ac1-8c65-6f2ce18c4b28"",
|
||||||
|
""expectedControlType"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Attack"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""c2bb66ee-38f8-4779-81cc-a62aff07e657"",
|
||||||
|
""expectedControlType"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""bindings"": [
|
||||||
|
{
|
||||||
|
""name"": ""1D Axis"",
|
||||||
|
""id"": ""2c969357-44d1-4014-940f-bdf59c08cec1"",
|
||||||
|
""path"": ""1DAxis"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Horizontal"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""eaefe266-b882-42e9-ba04-59f693fd3e8b"",
|
||||||
|
""path"": ""<Keyboard>/a"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Horizontal"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""99947c72-29a6-48be-9939-5b23e27824be"",
|
||||||
|
""path"": ""<Keyboard>/d"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Horizontal"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""b8c510f7-204c-4113-b3e3-b28c81951c77"",
|
||||||
|
""path"": ""<Keyboard>/space"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Jump"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""c0ba4b5e-fbe5-4b10-9de8-52dac5c4b424"",
|
||||||
|
""path"": ""<Keyboard>/s"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Down"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""b4a9a8a1-bf89-4482-bfec-08f95531cddb"",
|
||||||
|
""path"": ""<Mouse>/leftButton"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Attack"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""controlSchemes"": [
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard&Mouse"",
|
||||||
|
""bindingGroup"": ""Keyboard&Mouse"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Keyboard>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Mouse>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""bindingGroup"": ""Gamepad"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Gamepad>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Touch"",
|
||||||
|
""bindingGroup"": ""Touch"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Touchscreen>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Joystick"",
|
||||||
|
""bindingGroup"": ""Joystick"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Joystick>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""XR"",
|
||||||
|
""bindingGroup"": ""XR"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<XRController>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}");
|
||||||
|
// Player
|
||||||
|
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
|
||||||
|
m_Player_Horizontal = m_Player.FindAction("Horizontal", throwIfNotFound: true);
|
||||||
|
m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
|
||||||
|
m_Player_Down = m_Player.FindAction("Down", throwIfNotFound: true);
|
||||||
|
m_Player_Attack = m_Player.FindAction("Attack", throwIfNotFound: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
~@UnicornInputSystem()
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Assert(!m_Player.enabled, "This will cause a leak and performance issues, UnicornInputSystem.Player.Disable() has not been called.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys this asset and all associated <see cref="InputAction"/> instances.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
UnityEngine.Object.Destroy(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindingMask" />
|
||||||
|
public InputBinding? bindingMask
|
||||||
|
{
|
||||||
|
get => asset.bindingMask;
|
||||||
|
set => asset.bindingMask = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.devices" />
|
||||||
|
public ReadOnlyArray<InputDevice>? devices
|
||||||
|
{
|
||||||
|
get => asset.devices;
|
||||||
|
set => asset.devices = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.controlSchemes" />
|
||||||
|
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Contains(InputAction)" />
|
||||||
|
public bool Contains(InputAction action)
|
||||||
|
{
|
||||||
|
return asset.Contains(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.GetEnumerator()" />
|
||||||
|
public IEnumerator<InputAction> GetEnumerator()
|
||||||
|
{
|
||||||
|
return asset.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Enable()" />
|
||||||
|
public void Enable()
|
||||||
|
{
|
||||||
|
asset.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Disable()" />
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
asset.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindings" />
|
||||||
|
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindAction(string, bool)" />
|
||||||
|
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||||
|
{
|
||||||
|
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindBinding(InputBinding, out InputAction)" />
|
||||||
|
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||||
|
{
|
||||||
|
return asset.FindBinding(bindingMask, out action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player
|
||||||
|
private readonly InputActionMap m_Player;
|
||||||
|
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
|
||||||
|
private readonly InputAction m_Player_Horizontal;
|
||||||
|
private readonly InputAction m_Player_Jump;
|
||||||
|
private readonly InputAction m_Player_Down;
|
||||||
|
private readonly InputAction m_Player_Attack;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to input actions defined in input action map "Player".
|
||||||
|
/// </summary>
|
||||||
|
public struct PlayerActions
|
||||||
|
{
|
||||||
|
private @UnicornInputSystem m_Wrapper;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Construct a new instance of the input action map wrapper class.
|
||||||
|
/// </summary>
|
||||||
|
public PlayerActions(@UnicornInputSystem wrapper) { m_Wrapper = wrapper; }
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Player/Horizontal".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Horizontal => m_Wrapper.m_Player_Horizontal;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Player/Jump".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Jump => m_Wrapper.m_Player_Jump;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Player/Down".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Down => m_Wrapper.m_Player_Down;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Player/Attack".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Attack => m_Wrapper.m_Player_Attack;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action map instance.
|
||||||
|
/// </summary>
|
||||||
|
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
|
||||||
|
public void Enable() { Get().Enable(); }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
|
||||||
|
public void Disable() { Get().Disable(); }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
|
||||||
|
public bool enabled => Get().enabled;
|
||||||
|
/// <summary>
|
||||||
|
/// Implicitly converts an <see ref="PlayerActions" /> to an <see ref="InputActionMap" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
|
||||||
|
/// <summary>
|
||||||
|
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Callback instance.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="PlayerActions" />
|
||||||
|
public void AddCallbacks(IPlayerActions instance)
|
||||||
|
{
|
||||||
|
if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return;
|
||||||
|
m_Wrapper.m_PlayerActionsCallbackInterfaces.Add(instance);
|
||||||
|
@Horizontal.started += instance.OnHorizontal;
|
||||||
|
@Horizontal.performed += instance.OnHorizontal;
|
||||||
|
@Horizontal.canceled += instance.OnHorizontal;
|
||||||
|
@Jump.started += instance.OnJump;
|
||||||
|
@Jump.performed += instance.OnJump;
|
||||||
|
@Jump.canceled += instance.OnJump;
|
||||||
|
@Down.started += instance.OnDown;
|
||||||
|
@Down.performed += instance.OnDown;
|
||||||
|
@Down.canceled += instance.OnDown;
|
||||||
|
@Attack.started += instance.OnAttack;
|
||||||
|
@Attack.performed += instance.OnAttack;
|
||||||
|
@Attack.canceled += instance.OnAttack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="PlayerActions" />
|
||||||
|
private void UnregisterCallbacks(IPlayerActions instance)
|
||||||
|
{
|
||||||
|
@Horizontal.started -= instance.OnHorizontal;
|
||||||
|
@Horizontal.performed -= instance.OnHorizontal;
|
||||||
|
@Horizontal.canceled -= instance.OnHorizontal;
|
||||||
|
@Jump.started -= instance.OnJump;
|
||||||
|
@Jump.performed -= instance.OnJump;
|
||||||
|
@Jump.canceled -= instance.OnJump;
|
||||||
|
@Down.started -= instance.OnDown;
|
||||||
|
@Down.performed -= instance.OnDown;
|
||||||
|
@Down.canceled -= instance.OnDown;
|
||||||
|
@Attack.started -= instance.OnAttack;
|
||||||
|
@Attack.performed -= instance.OnAttack;
|
||||||
|
@Attack.canceled -= instance.OnAttack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
|
||||||
|
public void RemoveCallbacks(IPlayerActions instance)
|
||||||
|
{
|
||||||
|
if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance))
|
||||||
|
UnregisterCallbacks(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
|
||||||
|
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
|
||||||
|
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
|
||||||
|
public void SetCallbacks(IPlayerActions instance)
|
||||||
|
{
|
||||||
|
foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces)
|
||||||
|
UnregisterCallbacks(item);
|
||||||
|
m_Wrapper.m_PlayerActionsCallbackInterfaces.Clear();
|
||||||
|
AddCallbacks(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a new <see cref="PlayerActions" /> instance referencing this action map.
|
||||||
|
/// </summary>
|
||||||
|
public PlayerActions @Player => new PlayerActions(this);
|
||||||
|
private int m_KeyboardMouseSchemeIndex = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the input control scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputControlScheme" />
|
||||||
|
public InputControlScheme KeyboardMouseScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_KeyboardMouseSchemeIndex == -1) m_KeyboardMouseSchemeIndex = asset.FindControlSchemeIndex("Keyboard&Mouse");
|
||||||
|
return asset.controlSchemes[m_KeyboardMouseSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_GamepadSchemeIndex = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the input control scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputControlScheme" />
|
||||||
|
public InputControlScheme GamepadScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
|
||||||
|
return asset.controlSchemes[m_GamepadSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_TouchSchemeIndex = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the input control scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputControlScheme" />
|
||||||
|
public InputControlScheme TouchScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_TouchSchemeIndex == -1) m_TouchSchemeIndex = asset.FindControlSchemeIndex("Touch");
|
||||||
|
return asset.controlSchemes[m_TouchSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_JoystickSchemeIndex = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the input control scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputControlScheme" />
|
||||||
|
public InputControlScheme JoystickScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_JoystickSchemeIndex == -1) m_JoystickSchemeIndex = asset.FindControlSchemeIndex("Joystick");
|
||||||
|
return asset.controlSchemes[m_JoystickSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_XRSchemeIndex = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the input control scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputControlScheme" />
|
||||||
|
public InputControlScheme XRScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_XRSchemeIndex == -1) m_XRSchemeIndex = asset.FindControlSchemeIndex("XR");
|
||||||
|
return asset.controlSchemes[m_XRSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Player" which allows adding and removing callbacks.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
|
||||||
|
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
|
||||||
|
public interface IPlayerActions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Horizontal" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnHorizontal(InputAction.CallbackContext context);
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Jump" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnJump(InputAction.CallbackContext context);
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Down" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnDown(InputAction.CallbackContext context);
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Attack" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnAttack(InputAction.CallbackContext context);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/UnicornInputSystem.cs.meta
Normal file
2
Assets/Scripts/UnicornInputSystem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5fb3f9c4dc3857b49b9fd9d12bc1b1f3
|
||||||
Reference in New Issue
Block a user