浏览代码

Renaming and refactoring on UI

/devlogs-3-input
Ciro Continisio 4 年前
当前提交
0f73b995
共有 12 个文件被更改,包括 483 次插入502 次删除
  1. 635
      UOP1_Project/Assets/Scripts/Input/GameInput.cs
  2. 118
      UOP1_Project/Assets/Scripts/Input/InputReader.cs
  3. 2
      UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs
  4. 8
      UOP1_Project/Assets/Scripts/Menu/MenuController.cs
  5. 48
      UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs
  6. 42
      UOP1_Project/Assets/Settings/Input/GameInput.inputactions
  7. 39
      UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs
  8. 29
      UOP1_Project/Assets/Scripts/Menu/MultiInputSelectableElement.cs
  9. 35
      UOP1_Project/Assets/Scripts/Menu/CC_Button.cs
  10. 29
      UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs
  11. 0
      /UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs.meta
  12. 0
      /UOP1_Project/Assets/Scripts/Menu/MultiInputSelectableElement.cs.meta

635
UOP1_Project/Assets/Scripts/Input/GameInput.cs


public class @GameInput : IInputActionCollection, IDisposable
{
public InputActionAsset asset { get; }
public @GameInput()
{
asset = InputActionAsset.FromJson(@"{
public InputActionAsset asset { get; }
public @GameInput()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""GameInput"",
""maps"": [
{

""id"": ""a6b0dc37-2ef3-420d-990a-eef5df26ae21"",
""actions"": [
{
""name"": ""MoveMenuSelection"",
""name"": ""MoveSelection"",
""type"": ""Value"",
""id"": ""ca8fee63-58a3-49c0-9b34-e74351e25113"",
""expectedControlType"": ""Vector2"",

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": true,
""isPartOfComposite"": false
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

""interactions"": """",
""processors"": """",
""groups"": ""KeyboardOrGamepad"",
""action"": ""MoveMenuSelection"",
""action"": ""MoveSelection"",
""isComposite"": false,
""isPartOfComposite"": true
},

}
]
}");
// Gameplay
m_Gameplay = asset.FindActionMap("Gameplay", throwIfNotFound: true);
m_Gameplay_Move = m_Gameplay.FindAction("Move", throwIfNotFound: true);
m_Gameplay_Jump = m_Gameplay.FindAction("Jump", throwIfNotFound: true);
m_Gameplay_Attack = m_Gameplay.FindAction("Attack", throwIfNotFound: true);
m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true);
m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true);
m_Gameplay_ExtraAction = m_Gameplay.FindAction("ExtraAction", throwIfNotFound: true);
m_Gameplay_RotateCamera = m_Gameplay.FindAction("RotateCamera", throwIfNotFound: true);
m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true);
m_Gameplay_Run = m_Gameplay.FindAction("Run", throwIfNotFound: true);
// Menus
m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true);
m_Menus_MoveMenuSelection = m_Menus.FindAction("MoveMenuSelection", throwIfNotFound: true);
m_Menus_Confirm = m_Menus.FindAction("Confirm", throwIfNotFound: true);
m_Menus_Cancel = m_Menus.FindAction("Cancel", throwIfNotFound: true);
m_Menus_MouseMove = m_Menus.FindAction("MouseMove", throwIfNotFound: true);
m_Menus_Unpause = m_Menus.FindAction("Unpause", throwIfNotFound: true);
// Dialogues
m_Dialogues = asset.FindActionMap("Dialogues", throwIfNotFound: true);
m_Dialogues_MoveSelection = m_Dialogues.FindAction("MoveSelection", throwIfNotFound: true);
m_Dialogues_AdvanceDialogue = m_Dialogues.FindAction("AdvanceDialogue", throwIfNotFound: true);
}
// Gameplay
m_Gameplay = asset.FindActionMap("Gameplay", throwIfNotFound: true);
m_Gameplay_Move = m_Gameplay.FindAction("Move", throwIfNotFound: true);
m_Gameplay_Jump = m_Gameplay.FindAction("Jump", throwIfNotFound: true);
m_Gameplay_Attack = m_Gameplay.FindAction("Attack", throwIfNotFound: true);
m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true);
m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true);
m_Gameplay_ExtraAction = m_Gameplay.FindAction("ExtraAction", throwIfNotFound: true);
m_Gameplay_RotateCamera = m_Gameplay.FindAction("RotateCamera", throwIfNotFound: true);
m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true);
m_Gameplay_Run = m_Gameplay.FindAction("Run", throwIfNotFound: true);
// Menus
m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true);
m_Menus_MoveSelection = m_Menus.FindAction("MoveSelection", throwIfNotFound: true);
m_Menus_Confirm = m_Menus.FindAction("Confirm", throwIfNotFound: true);
m_Menus_Cancel = m_Menus.FindAction("Cancel", throwIfNotFound: true);
m_Menus_MouseMove = m_Menus.FindAction("MouseMove", throwIfNotFound: true);
m_Menus_Unpause = m_Menus.FindAction("Unpause", throwIfNotFound: true);
// Dialogues
m_Dialogues = asset.FindActionMap("Dialogues", throwIfNotFound: true);
m_Dialogues_MoveSelection = m_Dialogues.FindAction("MoveSelection", throwIfNotFound: true);
m_Dialogues_AdvanceDialogue = m_Dialogues.FindAction("AdvanceDialogue", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public void Disable()
{
asset.Disable();
}
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Move;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Attack;
private readonly InputAction m_Gameplay_Interact;
private readonly InputAction m_Gameplay_Pause;
private readonly InputAction m_Gameplay_ExtraAction;
private readonly InputAction m_Gameplay_RotateCamera;
private readonly InputAction m_Gameplay_MouseControlCamera;
private readonly InputAction m_Gameplay_Run;
public struct GameplayActions
{
private @GameInput m_Wrapper;
public GameplayActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Attack => m_Wrapper.m_Gameplay_Attack;
public InputAction @Interact => m_Wrapper.m_Gameplay_Interact;
public InputAction @Pause => m_Wrapper.m_Gameplay_Pause;
public InputAction @ExtraAction => m_Wrapper.m_Gameplay_ExtraAction;
public InputAction @RotateCamera => m_Wrapper.m_Gameplay_RotateCamera;
public InputAction @MouseControlCamera => m_Wrapper.m_Gameplay_MouseControlCamera;
public InputAction @Run => m_Wrapper.m_Gameplay_Run;
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Attack.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Interact.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Pause.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@ExtraAction.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@ExtraAction.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@ExtraAction.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@RotateCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@MouseControlCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@Run.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Attack.started += instance.OnAttack;
@Attack.performed += instance.OnAttack;
@Attack.canceled += instance.OnAttack;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
@ExtraAction.started += instance.OnExtraAction;
@ExtraAction.performed += instance.OnExtraAction;
@ExtraAction.canceled += instance.OnExtraAction;
@RotateCamera.started += instance.OnRotateCamera;
@RotateCamera.performed += instance.OnRotateCamera;
@RotateCamera.canceled += instance.OnRotateCamera;
@MouseControlCamera.started += instance.OnMouseControlCamera;
@MouseControlCamera.performed += instance.OnMouseControlCamera;
@MouseControlCamera.canceled += instance.OnMouseControlCamera;
@Run.started += instance.OnRun;
@Run.performed += instance.OnRun;
@Run.canceled += instance.OnRun;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Move;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Attack;
private readonly InputAction m_Gameplay_Interact;
private readonly InputAction m_Gameplay_Pause;
private readonly InputAction m_Gameplay_ExtraAction;
private readonly InputAction m_Gameplay_RotateCamera;
private readonly InputAction m_Gameplay_MouseControlCamera;
private readonly InputAction m_Gameplay_Run;
public struct GameplayActions
{
private @GameInput m_Wrapper;
public GameplayActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Attack => m_Wrapper.m_Gameplay_Attack;
public InputAction @Interact => m_Wrapper.m_Gameplay_Interact;
public InputAction @Pause => m_Wrapper.m_Gameplay_Pause;
public InputAction @ExtraAction => m_Wrapper.m_Gameplay_ExtraAction;
public InputAction @RotateCamera => m_Wrapper.m_Gameplay_RotateCamera;
public InputAction @MouseControlCamera => m_Wrapper.m_Gameplay_MouseControlCamera;
public InputAction @Run => m_Wrapper.m_Gameplay_Run;
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Attack.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Interact.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Pause.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@ExtraAction.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@ExtraAction.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@ExtraAction.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnExtraAction;
@RotateCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@MouseControlCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@Run.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Attack.started += instance.OnAttack;
@Attack.performed += instance.OnAttack;
@Attack.canceled += instance.OnAttack;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
@ExtraAction.started += instance.OnExtraAction;
@ExtraAction.performed += instance.OnExtraAction;
@ExtraAction.canceled += instance.OnExtraAction;
@RotateCamera.started += instance.OnRotateCamera;
@RotateCamera.performed += instance.OnRotateCamera;
@RotateCamera.canceled += instance.OnRotateCamera;
@MouseControlCamera.started += instance.OnMouseControlCamera;
@MouseControlCamera.performed += instance.OnMouseControlCamera;
@MouseControlCamera.canceled += instance.OnMouseControlCamera;
@Run.started += instance.OnRun;
@Run.performed += instance.OnRun;
@Run.canceled += instance.OnRun;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
// Menus
private readonly InputActionMap m_Menus;
private IMenusActions m_MenusActionsCallbackInterface;
private readonly InputAction m_Menus_MoveMenuSelection;
private readonly InputAction m_Menus_Confirm;
private readonly InputAction m_Menus_Cancel;
private readonly InputAction m_Menus_MouseMove;
private readonly InputAction m_Menus_Unpause;
public struct MenusActions
{
private @GameInput m_Wrapper;
public MenusActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveMenuSelection => m_Wrapper.m_Menus_MoveMenuSelection;
public InputAction @Confirm => m_Wrapper.m_Menus_Confirm;
public InputAction @Cancel => m_Wrapper.m_Menus_Cancel;
public InputAction @MouseMove => m_Wrapper.m_Menus_MouseMove;
public InputAction @Unpause => m_Wrapper.m_Menus_Unpause;
public InputActionMap Get() { return m_Wrapper.m_Menus; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(MenusActions set) { return set.Get(); }
public void SetCallbacks(IMenusActions instance)
{
if (m_Wrapper.m_MenusActionsCallbackInterface != null)
{
@MoveMenuSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@MoveMenuSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@MoveMenuSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveMenuSelection;
@Confirm.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Cancel.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@MouseMove.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@Unpause.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
}
m_Wrapper.m_MenusActionsCallbackInterface = instance;
if (instance != null)
{
@MoveMenuSelection.started += instance.OnMoveMenuSelection;
@MoveMenuSelection.performed += instance.OnMoveMenuSelection;
@MoveMenuSelection.canceled += instance.OnMoveMenuSelection;
@Confirm.started += instance.OnConfirm;
@Confirm.performed += instance.OnConfirm;
@Confirm.canceled += instance.OnConfirm;
@Cancel.started += instance.OnCancel;
@Cancel.performed += instance.OnCancel;
@Cancel.canceled += instance.OnCancel;
@MouseMove.started += instance.OnMouseMove;
@MouseMove.performed += instance.OnMouseMove;
@MouseMove.canceled += instance.OnMouseMove;
@Unpause.started += instance.OnUnpause;
@Unpause.performed += instance.OnUnpause;
@Unpause.canceled += instance.OnUnpause;
}
}
}
public MenusActions @Menus => new MenusActions(this);
// Menus
private readonly InputActionMap m_Menus;
private IMenusActions m_MenusActionsCallbackInterface;
private readonly InputAction m_Menus_MoveSelection;
private readonly InputAction m_Menus_Confirm;
private readonly InputAction m_Menus_Cancel;
private readonly InputAction m_Menus_MouseMove;
private readonly InputAction m_Menus_Unpause;
public struct MenusActions
{
private @GameInput m_Wrapper;
public MenusActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Menus_MoveSelection;
public InputAction @Confirm => m_Wrapper.m_Menus_Confirm;
public InputAction @Cancel => m_Wrapper.m_Menus_Cancel;
public InputAction @MouseMove => m_Wrapper.m_Menus_MouseMove;
public InputAction @Unpause => m_Wrapper.m_Menus_Unpause;
public InputActionMap Get() { return m_Wrapper.m_Menus; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(MenusActions set) { return set.Get(); }
public void SetCallbacks(IMenusActions instance)
{
if (m_Wrapper.m_MenusActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@Confirm.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Cancel.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@MouseMove.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@Unpause.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
}
m_Wrapper.m_MenusActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@Confirm.started += instance.OnConfirm;
@Confirm.performed += instance.OnConfirm;
@Confirm.canceled += instance.OnConfirm;
@Cancel.started += instance.OnCancel;
@Cancel.performed += instance.OnCancel;
@Cancel.canceled += instance.OnCancel;
@MouseMove.started += instance.OnMouseMove;
@MouseMove.performed += instance.OnMouseMove;
@MouseMove.canceled += instance.OnMouseMove;
@Unpause.started += instance.OnUnpause;
@Unpause.performed += instance.OnUnpause;
@Unpause.canceled += instance.OnUnpause;
}
}
}
public MenusActions @Menus => new MenusActions(this);
// Dialogues
private readonly InputActionMap m_Dialogues;
private IDialoguesActions m_DialoguesActionsCallbackInterface;
private readonly InputAction m_Dialogues_MoveSelection;
private readonly InputAction m_Dialogues_AdvanceDialogue;
public struct DialoguesActions
{
private @GameInput m_Wrapper;
public DialoguesActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Dialogues_MoveSelection;
public InputAction @AdvanceDialogue => m_Wrapper.m_Dialogues_AdvanceDialogue;
public InputActionMap Get() { return m_Wrapper.m_Dialogues; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(DialoguesActions set) { return set.Get(); }
public void SetCallbacks(IDialoguesActions instance)
{
if (m_Wrapper.m_DialoguesActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@AdvanceDialogue.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
}
m_Wrapper.m_DialoguesActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@AdvanceDialogue.started += instance.OnAdvanceDialogue;
@AdvanceDialogue.performed += instance.OnAdvanceDialogue;
@AdvanceDialogue.canceled += instance.OnAdvanceDialogue;
}
}
}
public DialoguesActions @Dialogues => new DialoguesActions(this);
private int m_KeyboardOrGamepadSchemeIndex = -1;
public InputControlScheme KeyboardOrGamepadScheme
{
get
{
if (m_KeyboardOrGamepadSchemeIndex == -1)
m_KeyboardOrGamepadSchemeIndex = asset.FindControlSchemeIndex("KeyboardOrGamepad");
return asset.controlSchemes[m_KeyboardOrGamepadSchemeIndex];
}
}
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnAttack(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
void OnPause(InputAction.CallbackContext context);
void OnExtraAction(InputAction.CallbackContext context);
void OnRotateCamera(InputAction.CallbackContext context);
void OnMouseControlCamera(InputAction.CallbackContext context);
void OnRun(InputAction.CallbackContext context);
}
public interface IMenusActions
{
void OnMoveMenuSelection(InputAction.CallbackContext context);
void OnConfirm(InputAction.CallbackContext context);
void OnCancel(InputAction.CallbackContext context);
void OnMouseMove(InputAction.CallbackContext context);
void OnUnpause(InputAction.CallbackContext context);
}
public interface IDialoguesActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnAdvanceDialogue(InputAction.CallbackContext context);
}
// Dialogues
private readonly InputActionMap m_Dialogues;
private IDialoguesActions m_DialoguesActionsCallbackInterface;
private readonly InputAction m_Dialogues_MoveSelection;
private readonly InputAction m_Dialogues_AdvanceDialogue;
public struct DialoguesActions
{
private @GameInput m_Wrapper;
public DialoguesActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Dialogues_MoveSelection;
public InputAction @AdvanceDialogue => m_Wrapper.m_Dialogues_AdvanceDialogue;
public InputActionMap Get() { return m_Wrapper.m_Dialogues; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(DialoguesActions set) { return set.Get(); }
public void SetCallbacks(IDialoguesActions instance)
{
if (m_Wrapper.m_DialoguesActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@AdvanceDialogue.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
}
m_Wrapper.m_DialoguesActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@AdvanceDialogue.started += instance.OnAdvanceDialogue;
@AdvanceDialogue.performed += instance.OnAdvanceDialogue;
@AdvanceDialogue.canceled += instance.OnAdvanceDialogue;
}
}
}
public DialoguesActions @Dialogues => new DialoguesActions(this);
private int m_KeyboardOrGamepadSchemeIndex = -1;
public InputControlScheme KeyboardOrGamepadScheme
{
get
{
if (m_KeyboardOrGamepadSchemeIndex == -1) m_KeyboardOrGamepadSchemeIndex = asset.FindControlSchemeIndex("KeyboardOrGamepad");
return asset.controlSchemes[m_KeyboardOrGamepadSchemeIndex];
}
}
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnAttack(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
void OnPause(InputAction.CallbackContext context);
void OnExtraAction(InputAction.CallbackContext context);
void OnRotateCamera(InputAction.CallbackContext context);
void OnMouseControlCamera(InputAction.CallbackContext context);
void OnRun(InputAction.CallbackContext context);
}
public interface IMenusActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnConfirm(InputAction.CallbackContext context);
void OnCancel(InputAction.CallbackContext context);
void OnMouseMove(InputAction.CallbackContext context);
void OnUnpause(InputAction.CallbackContext context);
}
public interface IDialoguesActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnAdvanceDialogue(InputAction.CallbackContext context);
}
}

118
UOP1_Project/Assets/Scripts/Input/InputReader.cs


[CreateAssetMenu(fileName = "InputReader", menuName = "Game/Input Reader")]
public class InputReader : ScriptableObject, GameInput.IGameplayActions, GameInput.IDialoguesActions, GameInput.IMenusActions
{
// Assign delegate{} to events to initialise them with an empty delegate
// so we can skip the null check when we use them
public event UnityAction jumpEvent;
public event UnityAction jumpCanceledEvent;
public event UnityAction attackEvent;
public event UnityAction interactEvent; // Used to talk, pickup objects, interact with tools like the cooking cauldron
public event UnityAction extraActionEvent; // Used to bring up the inventory
public event UnityAction pauseEvent;
public event UnityAction<Vector2> moveEvent;
public event UnityAction<Vector2, bool> cameraMoveEvent;
public event UnityAction enableMouseControlCameraEvent;
public event UnityAction disableMouseControlCameraEvent;
public event UnityAction startedRunning;
public event UnityAction stoppedRunning;
public event UnityAction jumpEvent = delegate { };
public event UnityAction jumpCanceledEvent = delegate { };
public event UnityAction attackEvent = delegate { };
public event UnityAction interactEvent = delegate { }; // Used to talk, pickup objects, interact with tools like the cooking cauldron
public event UnityAction extraActionEvent = delegate { }; // Used to bring up the inventory
public event UnityAction pauseEvent = delegate { };
public event UnityAction<Vector2> moveEvent = delegate { };
public event UnityAction<Vector2, bool> cameraMoveEvent = delegate { };
public event UnityAction enableMouseControlCameraEvent = delegate { };
public event UnityAction disableMouseControlCameraEvent = delegate { };
public event UnityAction startedRunning = delegate { };
public event UnityAction stoppedRunning = delegate { };
// Shared between menus and dialogues
public event UnityAction moveSelectionEvent = delegate { };
// Dialogue
public event UnityAction advanceDialogueEvent;
public event UnityAction onMoveSelectionEvent;
// Dialogues
public event UnityAction advanceDialogueEvent = delegate { };
// MenuEvents
public event UnityAction MoveSelectionMenuEvent = delegate { };
public event UnityAction MouseMoveMenuEvent = delegate { };
public event UnityAction ConfirmMenuEvent = delegate { };
public event UnityAction CancelMenuEvent = delegate { };
public event UnityAction UnpauseMenuEvent = delegate { };
// Menus
public event UnityAction menuMouseMoveEvent = delegate { };
public event UnityAction menuConfirmEvent = delegate { };
public event UnityAction menuCancelEvent = delegate { };
public event UnityAction menuUnpauseEvent = delegate { };
private GameInput gameInput;

public void OnAttack(InputAction.CallbackContext context)
{
if (attackEvent != null
&& context.phase == InputActionPhase.Performed)
if (context.phase == InputActionPhase.Performed)
if (extraActionEvent != null
&& context.phase == InputActionPhase.Performed)
if (context.phase == InputActionPhase.Performed)
if (interactEvent != null
&& context.phase == InputActionPhase.Performed)
if (context.phase == InputActionPhase.Performed)
if (jumpEvent != null
&& context.phase == InputActionPhase.Performed)
if (context.phase == InputActionPhase.Performed)
if (jumpCanceledEvent != null
&& context.phase == InputActionPhase.Canceled)
if (context.phase == InputActionPhase.Canceled)
if (moveEvent != null)
{
moveEvent.Invoke(context.ReadValue<Vector2>());
}
moveEvent.Invoke(context.ReadValue<Vector2>());
}
public void OnRun(InputAction.CallbackContext context)

case InputActionPhase.Performed:
startedRunning?.Invoke();
startedRunning.Invoke();
stoppedRunning?.Invoke();
stoppedRunning.Invoke();
break;
}
}

if (pauseEvent != null
&& context.phase == InputActionPhase.Performed)
if (context.phase == InputActionPhase.Performed)
if (cameraMoveEvent != null)
{
cameraMoveEvent.Invoke(context.ReadValue<Vector2>(), IsDeviceMouse(context));
}
cameraMoveEvent.Invoke(context.ReadValue<Vector2>(), IsDeviceMouse(context));
enableMouseControlCameraEvent?.Invoke();
enableMouseControlCameraEvent.Invoke();
disableMouseControlCameraEvent?.Invoke();
disableMouseControlCameraEvent.Invoke();
}
private bool IsDeviceMouse(InputAction.CallbackContext context) => context.control.device.name == "Mouse";

if (context.phase == InputActionPhase.Performed)
onMoveSelectionEvent();
moveSelectionEvent();
}
public void OnAdvanceDialogue(InputAction.CallbackContext context)

}
public void OnMoveMenuSelection(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
MoveSelectionMenuEvent();
}
ConfirmMenuEvent();
menuConfirmEvent();
CancelMenuEvent();
menuCancelEvent();
MouseMoveMenuEvent();
menuMouseMoveEvent();
UnpauseMenuEvent();
menuUnpauseEvent();
gameInput.Dialogues.Enable();
gameInput.Menus.Disable();
gameInput.Dialogues.Enable();
gameInput.Gameplay.Enable();
gameInput.Menus.Disable();
gameInput.Gameplay.Enable();
public void EnableUIInput()
public void EnableMenuInput()
gameInput.Dialogues.Disable();
gameInput.Dialogues.Disable();
gameInput.Menus.Enable();
}

gameInput.Menus.Disable();
gameInput.Dialogues.Disable();
}
public void EnableMenuInput()
{
gameInput.Dialogues.Disable();
gameInput.Gameplay.Disable();
gameInput.Menus.Enable();
}
public bool LeftMouseDown() => Mouse.current.leftButton.isPressed;

2
UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs


_onCookingStart.RaiseEvent();
Debug.Log("Cooking event raised");
//Change the action map
_inputReader.EnableUIInput();
_inputReader.EnableMenuInput();
//set current interaction for state machine
currentInteraction = InteractionType.Cook;
}

8
UOP1_Project/Assets/Scripts/Menu/MenuController.cs


using System;
using UnityEngine;
using UnityEngine;
public class MenuController : MonoBehaviour
{

private void OnEnable()
{
_inputReader.pauseEvent += OpenMenu;
_inputReader.UnpauseMenuEvent += UnpauseMenu;
_inputReader.menuUnpauseEvent += UnpauseMenu;
_inputReader.UnpauseMenuEvent -= UnpauseMenu;
_inputReader.menuUnpauseEvent -= UnpauseMenu;
}
private void OpenMenu()

_menuInstance.SetActive(true);
_inputReader.EnableMenuInput();
}

48
UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs


using System;
using System.Collections;
using System.Collections;
using UnityEngine.InputSystem;
public GameObject _currentSelection;
public GameObject _mouseSelection;
public GameObject currentSelection;
public GameObject mouseSelection;
_inputReader.MouseMoveMenuEvent += HandleMoveCursor;
_inputReader.MoveSelectionMenuEvent += HandleMoveSelection;
_inputReader.menuMouseMoveEvent += HandleMoveCursor;
_inputReader.moveSelectionEvent += HandleMoveSelection;
StartCoroutine(SelectDefault());
}

_inputReader.MouseMoveMenuEvent -= HandleMoveCursor;
_inputReader.MoveSelectionMenuEvent -= HandleMoveSelection;
_inputReader.menuMouseMoveEvent -= HandleMoveCursor;
_inputReader.moveSelectionEvent -= HandleMoveSelection;
}
/// <summary>

// Handle case where no UI element is selected because mouse left selectable bounds
if (EventSystem.current.currentSelectedGameObject == null)
EventSystem.current.SetSelectedGameObject(_currentSelection);
EventSystem.current.SetSelectedGameObject(currentSelection);
if (_mouseSelection != null)
if (mouseSelection != null)
EventSystem.current.SetSelectedGameObject(_mouseSelection);
EventSystem.current.SetSelectedGameObject(mouseSelection);
public void HandleMouseEnter(GameObject uiElement)
public void HandleMouseEnter(GameObject UIElement)
_mouseSelection = uiElement;
EventSystem.current.SetSelectedGameObject(uiElement);
mouseSelection = UIElement;
EventSystem.current.SetSelectedGameObject(UIElement);
public void HandleMouseExit(GameObject uiElement)
public void HandleMouseExit(GameObject UIElement)
if (EventSystem.current.currentSelectedGameObject != uiElement)
if (EventSystem.current.currentSelectedGameObject != UIElement)
_mouseSelection = null;
mouseSelection = null;
EventSystem.current.SetSelectedGameObject(null);
}

/// <returns></returns>
public bool AllowsSubmitOccurance()
public bool AllowsSubmit()
|| _mouseSelection != null && _mouseSelection == _currentSelection;
|| mouseSelection != null && mouseSelection == currentSelection;
/// <param name="uiElement"></param>
public void UpdateSelection(GameObject uiElement) => _currentSelection = uiElement;
/// <param name="UIElement"></param>
public void UpdateSelection(GameObject UIElement) => currentSelection = UIElement;
// debug
// Debug
// GUILayout.Box($"_currentSelection: {(_currentSelection != null ? _currentSelection.name : "null")}");
// GUILayout.Box($"_mouseSelection: {(_mouseSelection != null ? _mouseSelection.name : "null")}");
// GUILayout.Box($"_currentSelection: {(_currentSelection != null ? _currentSelection.name : "null")}");
// GUILayout.Box($"_mouseSelection: {(_mouseSelection != null ? _mouseSelection.name : "null")}");
// }
}

42
UOP1_Project/Assets/Settings/Input/GameInput.inputactions


"id": "a6b0dc37-2ef3-420d-990a-eef5df26ae21",
"actions": [
{
"name": "MoveMenuSelection",
"name": "MoveSelection",
"type": "Value",
"id": "ca8fee63-58a3-49c0-9b34-e74351e25113",
"expectedControlType": "Vector2",

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": true,
"isPartOfComposite": false
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

"interactions": "",
"processors": "",
"groups": "KeyboardOrGamepad",
"action": "MoveMenuSelection",
"action": "MoveSelection",
"isComposite": false,
"isPartOfComposite": true
},

39
UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs


using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
/// <summary>
/// An extension of Unity's base Button class, to support input from both mouse and keyboard/joypad
/// </summary>
[AddComponentMenu("UOP1/UI/MultiInputButton")]
public class MultiInputButton : Button
{
private MenuSelectionHandler _menuSelectionHandler;
private new void Awake()
{
_menuSelectionHandler = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
}
public override void OnPointerEnter(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseEnter(gameObject);
}
public override void OnPointerExit(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseExit(gameObject);
}
public override void OnSelect(BaseEventData eventData)
{
_menuSelectionHandler.UpdateSelection(gameObject);
base.OnSelect(eventData);
}
public override void OnSubmit(BaseEventData eventData)
{
if (_menuSelectionHandler.AllowsSubmit())
base.OnSubmit(eventData);
}
}

29
UOP1_Project/Assets/Scripts/Menu/MultiInputSelectableElement.cs


using System;
using UnityEngine;
using UnityEngine.EventSystems;
[AddComponentMenu("UOP1/UI/MultiInputSelectableElement")]
public class MultiInputSelectableElement : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler
{
private MenuSelectionHandler _menuSelectionHandler;
private void Awake()
{
_menuSelectionHandler = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
}
public void OnPointerEnter(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseEnter(gameObject);
}
public void OnPointerExit(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseExit(gameObject);
}
public void OnSelect(BaseEventData eventData)
{
_menuSelectionHandler.UpdateSelection(gameObject);
}
}

35
UOP1_Project/Assets/Scripts/Menu/CC_Button.cs


using UnityEngine.EventSystems;
using UnityEngine.UI;
// Chop Chop button
public class CC_Button : Button
{
private MenuSelectionHandler _menuSelectionHandler;
private void Awake()
{
_menuSelectionHandler = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
}
public override void OnPointerEnter(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseEnter(gameObject);
}
public override void OnPointerExit(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseExit(gameObject);
}
public override void OnSelect(BaseEventData eventData)
{
_menuSelectionHandler.UpdateSelection(gameObject);
base.OnSelect(eventData);
}
public override void OnSubmit(BaseEventData eventData)
{
if (_menuSelectionHandler.AllowsSubmitOccurance())
base.OnSubmit(eventData);
}
}

29
UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs


using System;
using UnityEngine;
using UnityEngine.EventSystems;
[AddComponentMenu("UI/SelectableUIElement")]
public class SelectableUIElement : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler
{
private MenuSelectionHandler _menuInput;
private void Awake()
{
_menuInput = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
}
public void OnPointerEnter(PointerEventData eventData)
{
_menuInput.HandleMouseEnter(gameObject);
}
public void OnPointerExit(PointerEventData eventData)
{
_menuInput.HandleMouseExit(gameObject);
}
public void OnSelect(BaseEventData eventData)
{
_menuInput.UpdateSelection(gameObject);
}
}

/UOP1_Project/Assets/Scripts/Menu/CC_Button.cs.meta → /UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs.meta

/UOP1_Project/Assets/Scripts/Menu/SelectableUIElement.cs.meta → /UOP1_Project/Assets/Scripts/Menu/MultiInputSelectableElement.cs.meta

正在加载...
取消
保存