/
SomeOneDay
/
UnityLesson
Обзор
Документация
Войти
/
SomeOneDay
/
UnityLesson
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
GAME/Assets/Scripts/GameInput.cs
32 строки
976 B
weeny
first commit
01 мар 2026, 17:01
01 мар 2026, 17:01
fb4adfb
Код
Авторство
О чём код?
using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.InputSystem; //(1) Довляем эту дерективу чтобы получить доступ к классу Mouse public class GameInput : MonoBehaviour { public static GameInput Instance { get; private set; } private PlayerInputActions playerInputActions; private void Awake() { Instance = this; playerInputActions = new PlayerInputActions(); playerInputActions.Enable(); } public Vector2 GetMovementVector() { Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>(); return inputVector; } //(2) Создадим метод который возвращает позицию мыши X.Y.Z осях public Vector3 GetMousePosition() { Vector3 mousePos = Mouse.current.position.ReadValue(); return mousePos; } }