Commit a4efa25d authored by Markus Schlösser's avatar Markus Schlösser
Browse files

Fixed Input Provider not being serializable

parent 19ed7887
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c2fa31169218b543acfac6ff6ce0c2b, type: 3}
m_Name: Player
m_EditorClassIdentifier:
jump: 32
peek: 304
fileFormatVersion: 2
guid: 70f7d7f3479adef4db8d8c8e4ac5a91c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
public interface IInputProvider {
Vector2 MoveDirection { get; }
bool JumpPressed { get; }
bool PeekingPressed { get; }
}
using UnityEngine;
public abstract class InputProvider : ScriptableObject {
public abstract Vector2 MoveDirection { get; }
public abstract bool JumpPressed { get; }
public abstract bool PeekingPressed { get; }
}
using UnityEngine;
[CreateAssetMenu]
public class KeyCodeInputProvider : ScriptableObject , IInputProvider {
public class KeyCodeInputProvider : InputProvider {
[SerializeField] private KeyCode jump;
[SerializeField] private KeyCode peek;
public Vector2 MoveDirection => new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
public override Vector2 MoveDirection => new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
public bool JumpPressed => Input.GetKeyDown(jump);
public override bool JumpPressed => Input.GetKeyDown(jump);
public bool PeekingPressed => Input.GetKey(peek);
public override bool PeekingPressed => Input.GetKey(peek);
}
......@@ -38,7 +38,7 @@ public class PlayerActor : MonoBehaviour {
[SerializeField] private MovementDirection facing = MovementDirection.Right;
[SerializeField] public IInputProvider inputProvider;
[SerializeField] public InputProvider inputProvider;
private void Update() {
if (isMoving) return;
......
......@@ -612,7 +612,7 @@ MonoBehaviour:
tilemap: {fileID: 185498795}
orientation: 0
facing: 1
InputProvider: {fileID: 11400000, guid: 026a5a3d17da2ec4b878bae9363baa61, type: 2}
inputProvider: {fileID: 11400000, guid: 70f7d7f3479adef4db8d8c8e4ac5a91c, type: 2}
--- !u!212 &427587215
SpriteRenderer:
m_ObjectHideFlags: 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment