75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using Assets.Scripts;
|
|
using Assets.Scripts.Menu;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.UI;
|
|
|
|
public class ControlsMenu : MonoBehaviour
|
|
{
|
|
UIHandlerMenu uihandler;
|
|
MoveDirection direction;
|
|
PlayerInput playerInput;
|
|
|
|
|
|
void Start()
|
|
{
|
|
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandlerMenu>();
|
|
direction = MoveDirection.None;
|
|
playerInput = GetComponent<PlayerInput>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
changeNameInput();
|
|
if (Cursor.lockState != CursorLockMode.Confined)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Confined;
|
|
}
|
|
}
|
|
|
|
public void FixedUpdate()
|
|
{
|
|
if (direction != MoveDirection.None)
|
|
{
|
|
AxisEventData data = new AxisEventData(EventSystem.current);
|
|
data.moveDir = direction;
|
|
data.selectedObject = EventSystem.current.currentSelectedGameObject;
|
|
ExecuteEvents.Execute(data.selectedObject, data, ExecuteEvents.moveHandler);
|
|
}
|
|
}
|
|
|
|
public void OnMovement(InputValue value)
|
|
{
|
|
if (value.Get<Vector2>().x < 0)
|
|
{
|
|
direction = MoveDirection.Left;
|
|
}
|
|
else if (value.Get<Vector2>().x > 0)
|
|
{
|
|
direction = MoveDirection.Right;
|
|
}
|
|
else if (value.Get<Vector2>().y < 0)
|
|
{
|
|
direction = MoveDirection.Down;
|
|
}
|
|
else if (value.Get<Vector2>().y > 0)
|
|
{
|
|
direction = MoveDirection.Up;
|
|
}
|
|
}
|
|
|
|
public void OnBack()
|
|
{
|
|
|
|
}
|
|
|
|
public void changeNameInput()
|
|
{
|
|
GameObject.Find("inName").GetComponent<InputField>().interactable = true;
|
|
}
|
|
}
|