TMP 임포트해서 뭐가 엄청 많아졌구나
This commit is contained in:
3
Assets/Scripts/Unicorn/Game.meta
Normal file
3
Assets/Scripts/Unicorn/Game.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a876daf45e834b59879bf88d11a77ebe
|
||||
timeCreated: 1777908804
|
||||
14
Assets/Scripts/Unicorn/Game/Enemy.cs
Normal file
14
Assets/Scripts/Unicorn/Game/Enemy.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Unicorn.Game.Hitbox;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Game
|
||||
{
|
||||
public class Enemy : LivingEntity
|
||||
{
|
||||
protected override void OnDamaged(DamageInfo info)
|
||||
{
|
||||
var dir = transform.position - info.hitPoint;
|
||||
Rb.linearVelocity = dir.normalized * info.knockbackForce;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Unicorn/Game/Enemy.cs.meta
Normal file
2
Assets/Scripts/Unicorn/Game/Enemy.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63fc82d3df1a3164584e678e0f04f817
|
||||
3
Assets/Scripts/Unicorn/Game/Hitbox.meta
Normal file
3
Assets/Scripts/Unicorn/Game/Hitbox.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 271b8726c0e0470bbe992a207e5da700
|
||||
timeCreated: 1777908913
|
||||
11
Assets/Scripts/Unicorn/Game/Hitbox/DamageInfo.cs
Normal file
11
Assets/Scripts/Unicorn/Game/Hitbox/DamageInfo.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Game.Hitbox
|
||||
{
|
||||
public struct DamageInfo
|
||||
{
|
||||
public float damage;
|
||||
public float knockbackForce;
|
||||
public Vector3 hitPoint; // 넉백 방향 계산을 위해 필요
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Unicorn/Game/Hitbox/DamageInfo.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Game/Hitbox/DamageInfo.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d01fae1e974b477591fb12d00e8c10ba
|
||||
timeCreated: 1777908924
|
||||
8
Assets/Scripts/Unicorn/Game/Hitbox/SO.meta
Normal file
8
Assets/Scripts/Unicorn/Game/Hitbox/SO.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64fa6e6de39c4aa418339d93d6f9c418
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Unicorn/Game/Hitbox/SO/ExampleAD.asset
Normal file
16
Assets/Scripts/Unicorn/Game/Hitbox/SO/ExampleAD.asset
Normal file
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4de4d4a74d5b4258863a8173560a93ab, type: 3}
|
||||
m_Name: ExampleAD
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Unicorn.Game.Hitbox.UnicornAttackDataSO
|
||||
damage: 5
|
||||
knockbackForce: 15
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67ddb0901f4c7754a9e47e5cf5cac286
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/Scripts/Unicorn/Game/Hitbox/UnicornAttackDataSO.cs
Normal file
11
Assets/Scripts/Unicorn/Game/Hitbox/UnicornAttackDataSO.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Game.Hitbox
|
||||
{
|
||||
[CreateAssetMenu(fileName = "NewAttackData", menuName = "Unicorn/AttackData")]
|
||||
public class UnicornAttackDataSO: ScriptableObject
|
||||
{
|
||||
public float damage;
|
||||
public float knockbackForce;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4de4d4a74d5b4258863a8173560a93ab
|
||||
timeCreated: 1777908942
|
||||
22
Assets/Scripts/Unicorn/Game/Hitbox/UnicornHitbox.cs
Normal file
22
Assets/Scripts/Unicorn/Game/Hitbox/UnicornHitbox.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Game.Hitbox
|
||||
{
|
||||
public class UnicornHitbox : MonoBehaviour
|
||||
{
|
||||
public UnicornAttackDataSO attackData;
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.TryGetComponent(out LivingEntity target)) return;
|
||||
var info = new DamageInfo
|
||||
{
|
||||
damage = attackData.damage,
|
||||
knockbackForce = attackData.knockbackForce,
|
||||
hitPoint = transform.position
|
||||
};
|
||||
|
||||
target.Damage(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Unicorn/Game/Hitbox/UnicornHitbox.cs.meta
Normal file
2
Assets/Scripts/Unicorn/Game/Hitbox/UnicornHitbox.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdb9c585da578ee408fc4177ce2010e1
|
||||
45
Assets/Scripts/Unicorn/Game/LivingEntity.cs
Normal file
45
Assets/Scripts/Unicorn/Game/LivingEntity.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Unicorn.Game.Hitbox;
|
||||
using UnityEngine;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace Unicorn.Game
|
||||
{
|
||||
public partial class LivingEntity : MonoBehaviour
|
||||
{
|
||||
private Rigidbody2D _rb;
|
||||
public float health = 20.0f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rb = TryGetComponent(out Rigidbody2D rb) ? rb : null;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (_rb == null) return;
|
||||
var transformPosition = other.transform.position - transform.position;
|
||||
_rb.linearVelocity = Vector2.zero;
|
||||
_rb.AddForce(transformPosition.normalized * health, ForceMode2D.Impulse);
|
||||
}
|
||||
|
||||
public void Damage(DamageInfo info)
|
||||
{
|
||||
health -= info.damage;
|
||||
OnDamaged(info);
|
||||
if (health <= 0.0f) OnDeath();
|
||||
}
|
||||
|
||||
|
||||
protected virtual void OnDeath()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Rigidbody2D Rb => _rb;
|
||||
|
||||
protected virtual void OnDamaged(DamageInfo info)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Unicorn/Game/LivingEntity.cs.meta
Normal file
2
Assets/Scripts/Unicorn/Game/LivingEntity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe858eccb62e2294f91ad1a4291f2b10
|
||||
3
Assets/Scripts/Unicorn/Game/Player.meta
Normal file
3
Assets/Scripts/Unicorn/Game/Player.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5614445efa7d41dc8cc9af23def94c20
|
||||
timeCreated: 1777908834
|
||||
7
Assets/Scripts/Unicorn/Game/Player/Player.cs
Normal file
7
Assets/Scripts/Unicorn/Game/Player/Player.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
public class Player: LivingEntity
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Unicorn/Game/Player/Player.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Game/Player/Player.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28098bcb033145e7aed508aa64877be6
|
||||
timeCreated: 1777820261
|
||||
35
Assets/Scripts/Unicorn/Game/Player/PlayerAttack.cs
Normal file
35
Assets/Scripts/Unicorn/Game/Player/PlayerAttack.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using Unicorn.System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
public class PlayerAttack: MonoBehaviour
|
||||
{
|
||||
public GameObject attackHitbox;
|
||||
private UnicornInputSystem _unicornInput;
|
||||
private void Start()
|
||||
{
|
||||
_unicornInput = UnicornInput.Unicorn;
|
||||
_unicornInput.Player.Attack.performed += Attack;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_unicornInput.Player.Attack.performed -= Attack;
|
||||
}
|
||||
|
||||
private void Attack(InputAction.CallbackContext obj)
|
||||
{
|
||||
StartCoroutine(OnAttack());
|
||||
}
|
||||
|
||||
private IEnumerator OnAttack()
|
||||
{
|
||||
attackHitbox.SetActive(true);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
attackHitbox.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Unicorn/Game/Player/PlayerAttack.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Game/Player/PlayerAttack.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54eed17cf1e34c79b343bc0642ca8797
|
||||
timeCreated: 1777820778
|
||||
42
Assets/Scripts/Unicorn/Game/Player/PlayerMovement.cs
Normal file
42
Assets/Scripts/Unicorn/Game/Player/PlayerMovement.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Unicorn.System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed;
|
||||
public float jumpForce;
|
||||
|
||||
private Rigidbody2D _rb;
|
||||
private UnicornInputSystem _unicorn;
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_unicorn.Player.Jump.performed -= Jump;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
_unicorn = UnicornInput.Unicorn;
|
||||
_unicorn.Player.Jump.performed += Jump;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db8b3864bdcf65d40b42ee58c17e87aa
|
||||
3
Assets/Scripts/Unicorn/System.meta
Normal file
3
Assets/Scripts/Unicorn/System.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8401e6c224a64b938938375ee5061879
|
||||
timeCreated: 1777908811
|
||||
33
Assets/Scripts/Unicorn/System/UnicornInput.cs
Normal file
33
Assets/Scripts/Unicorn/System/UnicornInput.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.System
|
||||
{
|
||||
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/Unicorn/System/UnicornInput.cs.meta
Normal file
2
Assets/Scripts/Unicorn/System/UnicornInput.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: caadd15da6c47e04a83c5441344e74c0
|
||||
577
Assets/Scripts/Unicorn/System/UnicornInputSystem.cs
Normal file
577
Assets/Scripts/Unicorn/System/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/Unicorn/System/UnicornInputSystem.cs.meta
Normal file
2
Assets/Scripts/Unicorn/System/UnicornInputSystem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fb3f9c4dc3857b49b9fd9d12bc1b1f3
|
||||
Reference in New Issue
Block a user