提交
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using UI;
|
||||
using Rewired.UI;
|
||||
|
||||
[AddComponentMenu("Rewired/Rewired Standalone Input Module")]
|
||||
public sealed class RewiredStandaloneInputModule : RewiredPointerInputModule {
|
||||
@@ -402,8 +402,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(value == horizontalActionId) return;
|
||||
horizontalActionId = value;
|
||||
if(ReInput.isReady) {
|
||||
m_HorizontalAxis = ReInput.mapping.GetAction(value) != null ? ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
if(Rewired.ReInput.isReady) {
|
||||
m_HorizontalAxis = Rewired.ReInput.mapping.GetAction(value) != null ? Rewired.ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,8 +418,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(value == verticalActionId) return;
|
||||
verticalActionId = value;
|
||||
if(ReInput.isReady) {
|
||||
m_VerticalAxis = ReInput.mapping.GetAction(value) != null ? ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
if(Rewired.ReInput.isReady) {
|
||||
m_VerticalAxis = Rewired.ReInput.mapping.GetAction(value) != null ? Rewired.ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,8 +434,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(value == submitActionId) return;
|
||||
submitActionId = value;
|
||||
if(ReInput.isReady) {
|
||||
m_SubmitButton = ReInput.mapping.GetAction(value) != null ? ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
if(Rewired.ReInput.isReady) {
|
||||
m_SubmitButton = Rewired.ReInput.mapping.GetAction(value) != null ? Rewired.ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,8 +450,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(value == cancelActionId) return;
|
||||
cancelActionId = value;
|
||||
if(ReInput.isReady) {
|
||||
m_CancelButton = ReInput.mapping.GetAction(value) != null ? ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
if(Rewired.ReInput.isReady) {
|
||||
m_CancelButton = Rewired.ReInput.mapping.GetAction(value) != null ? Rewired.ReInput.mapping.GetAction(value).name : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,8 +523,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(m_HorizontalAxis == value) return;
|
||||
m_HorizontalAxis = value;
|
||||
if(ReInput.isReady) {
|
||||
horizontalActionId = ReInput.mapping.GetActionId(value);
|
||||
if(Rewired.ReInput.isReady) {
|
||||
horizontalActionId = Rewired.ReInput.mapping.GetActionId(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,8 +537,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(m_VerticalAxis == value) return;
|
||||
m_VerticalAxis = value;
|
||||
if(ReInput.isReady) {
|
||||
verticalActionId = ReInput.mapping.GetActionId(value);
|
||||
if(Rewired.ReInput.isReady) {
|
||||
verticalActionId = Rewired.ReInput.mapping.GetActionId(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -551,8 +551,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(m_SubmitButton == value) return;
|
||||
m_SubmitButton = value;
|
||||
if(ReInput.isReady) {
|
||||
submitActionId = ReInput.mapping.GetActionId(value);
|
||||
if(Rewired.ReInput.isReady) {
|
||||
submitActionId = Rewired.ReInput.mapping.GetActionId(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,8 +565,8 @@ namespace Rewired.Integration.UnityUI {
|
||||
set {
|
||||
if(m_CancelButton == value) return;
|
||||
m_CancelButton = value;
|
||||
if(ReInput.isReady) {
|
||||
cancelActionId = ReInput.mapping.GetActionId(value);
|
||||
if(Rewired.ReInput.isReady) {
|
||||
cancelActionId = Rewired.ReInput.mapping.GetActionId(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,7 +583,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
// Determine if touch is supported
|
||||
isTouchSupported = defaultTouchInputSource.touchSupported;
|
||||
|
||||
ReInput.InitializedEvent += OnRewiredInitialized;
|
||||
Rewired.ReInput.InitializedEvent += OnRewiredInitialized;
|
||||
|
||||
// Initialize Rewired
|
||||
InitializeRewired();
|
||||
@@ -592,7 +592,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
public override void UpdateModule() {
|
||||
CheckEditorRecompile();
|
||||
if (recompiling) return;
|
||||
if (!ReInput.isReady) return;
|
||||
if (!Rewired.ReInput.isReady) return;
|
||||
|
||||
if (!m_HasFocus && ShouldIgnoreEventsOnNoFocus()) return;
|
||||
}
|
||||
@@ -604,13 +604,13 @@ namespace Rewired.Integration.UnityUI {
|
||||
public override bool ShouldActivateModule() {
|
||||
if (!base.ShouldActivateModule()) return false;
|
||||
if (recompiling) return false;
|
||||
if (!ReInput.isReady) return false;
|
||||
if (!Rewired.ReInput.isReady) return false;
|
||||
|
||||
bool shouldActivate = m_ForceModuleActive;
|
||||
|
||||
// Combine input for all players
|
||||
for (int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if (player == null) continue;
|
||||
if (usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
|
||||
@@ -662,7 +662,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
}
|
||||
|
||||
public override void Process() {
|
||||
if (!ReInput.isReady) return;
|
||||
if (!Rewired.ReInput.isReady) return;
|
||||
if (!m_HasFocus && ShouldIgnoreEventsOnNoFocus()) return;
|
||||
if (!enabled || !gameObject.activeInHierarchy) return;
|
||||
|
||||
@@ -739,7 +739,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
// Debug.Log("Pressed: " + newPressed);
|
||||
|
||||
double time = ReInput.time.unscaledTime;
|
||||
double time = Rewired.ReInput.time.unscaledTime;
|
||||
|
||||
if (newPressed == pointerEvent.lastPress) {
|
||||
var diffTime = time - pointerEvent.clickTime;
|
||||
@@ -813,7 +813,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
var data = GetBaseEventData();
|
||||
for (int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if (player == null) continue;
|
||||
if (usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
|
||||
@@ -839,7 +839,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
// Combine inputs of all Players
|
||||
for (int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if (player == null) continue;
|
||||
if (usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
|
||||
@@ -873,7 +873,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
private bool SendMoveEventToSelectedObject() {
|
||||
if (recompiling) return false; // never allow movement while recompiling
|
||||
|
||||
double time = ReInput.time.unscaledTime; // get the current time
|
||||
double time = Rewired.ReInput.time.unscaledTime; // get the current time
|
||||
|
||||
// Check for zero movement and clear
|
||||
Vector2 movement = GetRawMoveVector();
|
||||
@@ -948,7 +948,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
downVertical = false;
|
||||
|
||||
for (int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if (player == null) continue;
|
||||
if (usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
|
||||
@@ -959,7 +959,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
private void ProcessMouseEvents() {
|
||||
for(int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if(player == null) continue;
|
||||
if(usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
int pointerCount = GetMouseInputSourceCount(playerIds[i]);
|
||||
@@ -1041,7 +1041,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
// Debug.Log("Pressed: " + newPressed);
|
||||
|
||||
double time = ReInput.time.unscaledTime;
|
||||
double time = Rewired.ReInput.time.unscaledTime;
|
||||
|
||||
if (newPressed == pointerEvent.lastPress) {
|
||||
var diffTime = time - pointerEvent.clickTime;
|
||||
@@ -1133,11 +1133,11 @@ namespace Rewired.Integration.UnityUI {
|
||||
#if UNITY_EDITOR && UNITY_5_PLUS
|
||||
if(UnityEditor.EditorApplication.isRemoteConnected) return false;
|
||||
#endif
|
||||
if(!ReInput.isReady) return true;
|
||||
if(!Rewired.ReInput.isReady) return true;
|
||||
#else
|
||||
if (!Rewired.ReInput.isReady) return false;
|
||||
#endif
|
||||
return ReInput.configuration.ignoreInputWhenAppNotInFocus;
|
||||
return Rewired.ReInput.configuration.ignoreInputWhenAppNotInFocus;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -1151,16 +1151,16 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
protected override void OnDestroy() {
|
||||
base.OnDestroy();
|
||||
ReInput.InitializedEvent -= OnRewiredInitialized;
|
||||
ReInput.ShutDownEvent -= OnRewiredShutDown;
|
||||
ReInput.EditorRecompileEvent -= OnEditorRecompile;
|
||||
Rewired.ReInput.InitializedEvent -= OnRewiredInitialized;
|
||||
Rewired.ReInput.ShutDownEvent -= OnRewiredShutDown;
|
||||
Rewired.ReInput.EditorRecompileEvent -= OnEditorRecompile;
|
||||
}
|
||||
|
||||
#region Rewired Methods
|
||||
|
||||
protected override bool IsDefaultPlayer(int playerId) {
|
||||
if(playerIds == null) return false;
|
||||
if(!ReInput.isReady) return false;
|
||||
if(!Rewired.ReInput.isReady) return false;
|
||||
|
||||
for(int tries = 0; tries < 3; tries++) {
|
||||
|
||||
@@ -1169,7 +1169,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
// Try 2: Find the first Player
|
||||
|
||||
for(int i = 0; i < playerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(playerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerIds[i]);
|
||||
if(player == null) continue;
|
||||
if(tries < 1 && usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
if(tries < 2 && !player.controllers.hasMouse) continue;
|
||||
@@ -1181,19 +1181,19 @@ namespace Rewired.Integration.UnityUI {
|
||||
}
|
||||
|
||||
private void InitializeRewired() {
|
||||
if (!ReInput.isReady) {
|
||||
if (!Rewired.ReInput.isReady) {
|
||||
Debug.LogError("Rewired is not initialized! Are you missing a Rewired Input Manager in your scene?");
|
||||
return;
|
||||
}
|
||||
ReInput.ShutDownEvent -= OnRewiredShutDown;
|
||||
ReInput.ShutDownEvent += OnRewiredShutDown;
|
||||
ReInput.EditorRecompileEvent -= OnEditorRecompile;
|
||||
ReInput.EditorRecompileEvent += OnEditorRecompile;
|
||||
Rewired.ReInput.ShutDownEvent -= OnRewiredShutDown;
|
||||
Rewired.ReInput.ShutDownEvent += OnRewiredShutDown;
|
||||
Rewired.ReInput.EditorRecompileEvent -= OnEditorRecompile;
|
||||
Rewired.ReInput.EditorRecompileEvent += OnEditorRecompile;
|
||||
SetupRewiredVars();
|
||||
}
|
||||
|
||||
private void SetupRewiredVars() {
|
||||
if(!ReInput.isReady) return;
|
||||
if(!Rewired.ReInput.isReady) return;
|
||||
|
||||
// Set up Rewired vars
|
||||
|
||||
@@ -1202,22 +1202,22 @@ namespace Rewired.Integration.UnityUI {
|
||||
|
||||
// Set up Rewired Players
|
||||
if (useAllRewiredGamePlayers) {
|
||||
IList<Player> rwPlayers = useRewiredSystemPlayer ? ReInput.players.AllPlayers : ReInput.players.Players;
|
||||
playerIds = new int[rwPlayers.Count];
|
||||
IList<Rewired.Player> rwPlayers = useRewiredSystemPlayer ? Rewired.ReInput.players.AllPlayers : Rewired.ReInput.players.Players;
|
||||
this.playerIds = new int[rwPlayers.Count];
|
||||
for (int i = 0; i < rwPlayers.Count; i++) {
|
||||
playerIds[i] = rwPlayers[i].id;
|
||||
this.playerIds[i] = rwPlayers[i].id;
|
||||
}
|
||||
} else {
|
||||
bool foundSystem = false;
|
||||
List<int> playerIds = new List<int>(rewiredPlayerIds.Length + 1);
|
||||
for (int i = 0; i < rewiredPlayerIds.Length; i++) {
|
||||
Player player = ReInput.players.GetPlayer(rewiredPlayerIds[i]);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(rewiredPlayerIds[i]);
|
||||
if(player == null) continue;
|
||||
if(playerIds.Contains(player.id)) continue; // already in list
|
||||
playerIds.Add(player.id);
|
||||
if(player.id == Consts.systemPlayerId) foundSystem = true;
|
||||
}
|
||||
if(useRewiredSystemPlayer && !foundSystem) playerIds.Insert(0, ReInput.players.GetSystemPlayer().id);
|
||||
if(useRewiredSystemPlayer && !foundSystem) playerIds.Insert(0, Rewired.ReInput.players.GetSystemPlayer().id);
|
||||
this.playerIds = playerIds.ToArray();
|
||||
}
|
||||
|
||||
@@ -1225,7 +1225,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
}
|
||||
|
||||
private void SetUpRewiredPlayerMice() {
|
||||
if(!ReInput.isReady) return;
|
||||
if(!Rewired.ReInput.isReady) return;
|
||||
ClearMouseInputSources();
|
||||
for(int i = 0; i < playerMice.Count; i++) {
|
||||
var mouse = playerMice[i];
|
||||
@@ -1235,57 +1235,57 @@ namespace Rewired.Integration.UnityUI {
|
||||
}
|
||||
|
||||
private void SetUpRewiredActions() {
|
||||
if(!ReInput.isReady) return;
|
||||
if(!Rewired.ReInput.isReady) return;
|
||||
if(!setActionsById) {
|
||||
horizontalActionId = ReInput.mapping.GetActionId(m_HorizontalAxis);
|
||||
verticalActionId = ReInput.mapping.GetActionId(m_VerticalAxis);
|
||||
submitActionId = ReInput.mapping.GetActionId(m_SubmitButton);
|
||||
cancelActionId = ReInput.mapping.GetActionId(m_CancelButton);
|
||||
horizontalActionId = Rewired.ReInput.mapping.GetActionId(m_HorizontalAxis);
|
||||
verticalActionId = Rewired.ReInput.mapping.GetActionId(m_VerticalAxis);
|
||||
submitActionId = Rewired.ReInput.mapping.GetActionId(m_SubmitButton);
|
||||
cancelActionId = Rewired.ReInput.mapping.GetActionId(m_CancelButton);
|
||||
} else {
|
||||
InputAction action;
|
||||
action = ReInput.mapping.GetAction(horizontalActionId);
|
||||
action = Rewired.ReInput.mapping.GetAction(horizontalActionId);
|
||||
m_HorizontalAxis = action != null ? action.name : string.Empty;
|
||||
if(action == null) horizontalActionId = -1;
|
||||
action = ReInput.mapping.GetAction(verticalActionId);
|
||||
action = Rewired.ReInput.mapping.GetAction(verticalActionId);
|
||||
m_VerticalAxis = action != null ? action.name : string.Empty;
|
||||
if(action == null) verticalActionId = -1;
|
||||
action = ReInput.mapping.GetAction(submitActionId);
|
||||
action = Rewired.ReInput.mapping.GetAction(submitActionId);
|
||||
m_SubmitButton = action != null ? action.name : string.Empty;
|
||||
if(action == null) submitActionId = -1;
|
||||
action = ReInput.mapping.GetAction(cancelActionId);
|
||||
action = Rewired.ReInput.mapping.GetAction(cancelActionId);
|
||||
m_CancelButton = action != null ? action.name : string.Empty;
|
||||
if(action == null) cancelActionId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetButton(Player player, int actionId) {
|
||||
private bool GetButton(Rewired.Player player, int actionId) {
|
||||
if(actionId < 0) return false; // silence warnings
|
||||
return player.GetButton(actionId);
|
||||
}
|
||||
|
||||
private bool GetButtonDown(Player player, int actionId) {
|
||||
private bool GetButtonDown(Rewired.Player player, int actionId) {
|
||||
if(actionId < 0) return false; // silence warnings
|
||||
return player.GetButtonDown(actionId);
|
||||
}
|
||||
|
||||
private bool GetNegativeButton(Player player, int actionId) {
|
||||
private bool GetNegativeButton(Rewired.Player player, int actionId) {
|
||||
if(actionId < 0) return false; // silence warnings
|
||||
return player.GetNegativeButton(actionId);
|
||||
}
|
||||
|
||||
private bool GetNegativeButtonDown(Player player, int actionId) {
|
||||
private bool GetNegativeButtonDown(Rewired.Player player, int actionId) {
|
||||
if(actionId < 0) return false; // silence warnings
|
||||
return player.GetNegativeButtonDown(actionId);
|
||||
}
|
||||
|
||||
private float GetAxis(Player player, int actionId) {
|
||||
private float GetAxis(Rewired.Player player, int actionId) {
|
||||
if(actionId < 0) return 0f; // silence warnings
|
||||
return player.GetAxis(actionId);
|
||||
}
|
||||
|
||||
private void CheckEditorRecompile() {
|
||||
if (!recompiling) return;
|
||||
if (!ReInput.isReady) return;
|
||||
if (!Rewired.ReInput.isReady) return;
|
||||
recompiling = false;
|
||||
InitializeRewired();
|
||||
}
|
||||
@@ -1303,7 +1303,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
private bool DidAnyMouseMove() {
|
||||
for(int i = 0; i < playerIds.Length; i++) {
|
||||
int playerId = playerIds[i];
|
||||
Player player = ReInput.players.GetPlayer(playerId);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId);
|
||||
if(player == null) continue;
|
||||
if(usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
int mouseCount = GetMouseInputSourceCount(playerId);
|
||||
@@ -1319,7 +1319,7 @@ namespace Rewired.Integration.UnityUI {
|
||||
private bool GetMouseButtonDownOnAnyMouse(int buttonIndex) {
|
||||
for(int i = 0; i < playerIds.Length; i++) {
|
||||
int playerId = playerIds[i];
|
||||
Player player = ReInput.players.GetPlayer(playerId);
|
||||
Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId);
|
||||
if(player == null) continue;
|
||||
if(usePlayingPlayersOnly && !player.isPlaying) continue;
|
||||
int mouseCount = GetMouseInputSourceCount(playerId);
|
||||
@@ -1352,11 +1352,11 @@ namespace Rewired.Integration.UnityUI {
|
||||
}
|
||||
private PlayerSetting(PlayerSetting other) {
|
||||
if(other == null) throw new ArgumentNullException("other");
|
||||
playerId = other.playerId;
|
||||
playerMice = new List<Components.PlayerMouse>();
|
||||
this.playerId = other.playerId;
|
||||
this.playerMice = new List<Components.PlayerMouse>();
|
||||
if(other.playerMice != null) {
|
||||
foreach(var m in other.playerMice) {
|
||||
playerMice.Add(m);
|
||||
this.playerMice.Add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user