Attempt to refactor input handling
This commit is contained in:
parent
b703b7607d
commit
6c2d2dfca7
15 changed files with 200 additions and 92 deletions
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b92d82434aeb1f3fda097a73de13612e
|
||||
guid: 72e11eb82c4e0900994a843f520605c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
45
Assets/Prefab/InputManager.prefab
Normal file
45
Assets/Prefab/InputManager.prefab
Normal file
|
@ -0,0 +1,45 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1403606303201775
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4313665066920544}
|
||||
- component: {fileID: 3770296088317502516}
|
||||
m_Layer: 24
|
||||
m_Name: InputManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4313665066920544
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1403606303201775}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3770296088317502516
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1403606303201775}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 19e228d4d289a94f19ef06ee08631c71, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
7
Assets/Prefab/InputManager.prefab.meta
Normal file
7
Assets/Prefab/InputManager.prefab.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84d2411aefd50c2b28e8c76596d99fbf
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,22 +1,12 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 1209647188101178}
|
||||
m_IsPrefabParent: 1
|
||||
--- !u!1 &1209647188101178
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 5
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4427594563210266}
|
||||
- component: {fileID: 114346300641634211}
|
||||
|
@ -29,9 +19,10 @@ GameObject:
|
|||
m_IsActive: 1
|
||||
--- !u!4 &4427594563210266
|
||||
Transform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1209647188101178}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
|
@ -42,65 +33,77 @@ Transform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &114346300641634211
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1209647188101178}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 42af34292849d49646aeed71c6456225, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_platformSingletons:
|
||||
- platforms: 000000000100000005000000
|
||||
singleton: {fileID: 1875469945980329, guid: 87f883c80c4c22a34bc0c215f2a0c1d2, type: 2}
|
||||
singleton: {fileID: 1875469945980329, guid: 87f883c80c4c22a34bc0c215f2a0c1d2,
|
||||
type: 3}
|
||||
- platforms: 000000000100000005000000
|
||||
singleton: {fileID: 1339581412702681, guid: 7246ea46be0c438b432b1d81d683d1cb, type: 2}
|
||||
singleton: {fileID: 1339581412702681, guid: 7246ea46be0c438b432b1d81d683d1cb,
|
||||
type: 3}
|
||||
- platforms: 00000000
|
||||
singleton: {fileID: 1828283935284296, guid: 8521902550f847ab482c260997a828a0, type: 2}
|
||||
singleton: {fileID: 1828283935284296, guid: 8521902550f847ab482c260997a828a0,
|
||||
type: 3}
|
||||
- platforms: 00000000
|
||||
singleton: {fileID: 1839078755916108, guid: 778973e669b94680413797f09df3434c, type: 2}
|
||||
singleton: {fileID: 1839078755916108, guid: 778973e669b94680413797f09df3434c,
|
||||
type: 3}
|
||||
- platforms: 02000000
|
||||
singleton: {fileID: 1647089105227813, guid: 50879702d96bc3994cb08006850a8a37, type: 2}
|
||||
singleton: {fileID: 1647089105227813, guid: 50879702d96bc3994cb08006850a8a37,
|
||||
type: 3}
|
||||
- platforms: 02000000
|
||||
singleton: {fileID: 1003855045099876, guid: a4462998a6a36cbb4c89d37a1d237e4c, type: 2}
|
||||
singleton: {fileID: 1003855045099876, guid: a4462998a6a36cbb4c89d37a1d237e4c,
|
||||
type: 3}
|
||||
- platforms: 01000000
|
||||
singleton: {fileID: 1235751572096289, guid: d991b15bbf6f18b54aa109e4b7bc5220, type: 2}
|
||||
singleton: {fileID: 1235751572096289, guid: d991b15bbf6f18b54aa109e4b7bc5220,
|
||||
type: 3}
|
||||
- platforms: 0000000001000000
|
||||
singleton: {fileID: 1378047639872964, guid: 78165b4888ceb1814166abb8454e9395, type: 2}
|
||||
singleton: {fileID: 1378047639872964, guid: 78165b4888ceb1814166abb8454e9395,
|
||||
type: 3}
|
||||
- platforms: 0000000001000000
|
||||
singleton: {fileID: 1201587426226787, guid: f0f163b39d26cd9241daac80ae6fc79a, type: 2}
|
||||
singleton: {fileID: 1201587426226787, guid: f0f163b39d26cd9241daac80ae6fc79a,
|
||||
type: 3}
|
||||
- platforms: 0000000001000000
|
||||
singleton: {fileID: 1339637025689374, guid: d3537e440434edbb4c9af32d5381d072, type: 2}
|
||||
singleton: {fileID: 1339637025689374, guid: d3537e440434edbb4c9af32d5381d072,
|
||||
type: 3}
|
||||
m_commonSingletons:
|
||||
- {fileID: 1583279984661014, guid: bfb81bad87b868b14f5bf29fba8e176c, type: 2}
|
||||
- {fileID: 1844482152914794, guid: 8a606db6ace058b5409e0604aa4cb6d7, type: 2}
|
||||
- {fileID: 1749767312629123, guid: 38c39f2e54718e934519da0fc8fa297a, type: 2}
|
||||
- {fileID: 1333083021282635, guid: 9be4dec8158c8aa9405d345d2c6e6e25, type: 2}
|
||||
- {fileID: 1489955188834915, guid: 7088cfb5e96cf9b942b3f092fe678064, type: 2}
|
||||
- {fileID: 1670200755745761, guid: 3039005e35d18ca84df544e2bfa5335b, type: 2}
|
||||
- {fileID: 1494574746522880, guid: a03b1fcceedfc1be43c84ce2f4ba6adb, type: 2}
|
||||
- {fileID: 1229503408300461, guid: 197e1d759349b5884a3af0a50dbe71c6, type: 2}
|
||||
- {fileID: 1948536838405027, guid: 990ad7c6483ab4b84672ee6bafb36efa, type: 2}
|
||||
- {fileID: 1109176693036910, guid: c3e1dae49488a5bf4a6f324905694cb6, type: 2}
|
||||
- {fileID: 1082059118330139, guid: 199890c9fa408a884fbd33cec17a3c43, type: 2}
|
||||
- {fileID: 1845685163491465, guid: 8b9bdca0e0e05b8d4d8aafa9741096c5, type: 2}
|
||||
- {fileID: 1423745085298059, guid: 82e9eeb0f333139745b3223aaa648dc6, type: 2}
|
||||
- {fileID: 1492337780157316, guid: 3b74c335f9bb248547cefd868e3ced7b, type: 2}
|
||||
- {fileID: 1297496267986254, guid: 12e6fb69c093b59a4235c41bc1e2300b, type: 2}
|
||||
- {fileID: 1288395191254353, guid: add6c97bc117c5a240ed8d334efc1434, type: 2}
|
||||
- {fileID: 1689028653866908, guid: a0cb3b7b3dbf158d4592bc65cb38f961, type: 2}
|
||||
- {fileID: 1973774761334177, guid: 749ef4121da89fb3443a75815988319c, type: 2}
|
||||
- {fileID: 1333551932251375, guid: 35bda4023eaac58745da5960457ae352, type: 2}
|
||||
- {fileID: 1627512324759526, guid: b6c174dce53d29b84f4f70b5371df5e6, type: 2}
|
||||
- {fileID: 1086168063367571, guid: 7c7706b857a509a74a7fb631b7f35787, type: 2}
|
||||
- {fileID: 1300994118367831, guid: 8fc088593d16fa8f436f854ca90b1f35, type: 2}
|
||||
- {fileID: 1887923683873935, guid: c611e9a2583d338a495ac6bc5089b465, type: 2}
|
||||
- {fileID: 1062975116743938, guid: 91a93feda03ecf824a1c912c65ec4922, type: 2}
|
||||
- {fileID: 1380739253970218, guid: da2126c6f7107da146e905c9409a6d43, type: 2}
|
||||
- {fileID: 1165003388906840, guid: 317a9cfa78c4c9b24f7906173e3b0e75, type: 2}
|
||||
- {fileID: 1505058240137202, guid: 4dbff79b8486c68e4b8fcef1de07b707, type: 2}
|
||||
- {fileID: 1225123916247272, guid: 6ca6e38cef897bb940003b4d4b904671, type: 2}
|
||||
- {fileID: 1865442820050835, guid: dfc2807d00d1d2a24f6853be15a217ef, type: 2}
|
||||
- {fileID: 1813356220450816, guid: 597b92a7d8ea78a2435d74a087566129, type: 2}
|
||||
- {fileID: 1373626037220906, guid: 7146ba416ca11c9c4b74b78687fa25ec, type: 2}
|
||||
- {fileID: 1583279984661014, guid: bfb81bad87b868b14f5bf29fba8e176c, type: 3}
|
||||
- {fileID: 1844482152914794, guid: 8a606db6ace058b5409e0604aa4cb6d7, type: 3}
|
||||
- {fileID: 1749767312629123, guid: 38c39f2e54718e934519da0fc8fa297a, type: 3}
|
||||
- {fileID: 1333083021282635, guid: 9be4dec8158c8aa9405d345d2c6e6e25, type: 3}
|
||||
- {fileID: 1489955188834915, guid: 7088cfb5e96cf9b942b3f092fe678064, type: 3}
|
||||
- {fileID: 1670200755745761, guid: 3039005e35d18ca84df544e2bfa5335b, type: 3}
|
||||
- {fileID: 1494574746522880, guid: a03b1fcceedfc1be43c84ce2f4ba6adb, type: 3}
|
||||
- {fileID: 1229503408300461, guid: 197e1d759349b5884a3af0a50dbe71c6, type: 3}
|
||||
- {fileID: 1948536838405027, guid: 990ad7c6483ab4b84672ee6bafb36efa, type: 3}
|
||||
- {fileID: 1109176693036910, guid: c3e1dae49488a5bf4a6f324905694cb6, type: 3}
|
||||
- {fileID: 1082059118330139, guid: 199890c9fa408a884fbd33cec17a3c43, type: 3}
|
||||
- {fileID: 1845685163491465, guid: 8b9bdca0e0e05b8d4d8aafa9741096c5, type: 3}
|
||||
- {fileID: 1423745085298059, guid: 82e9eeb0f333139745b3223aaa648dc6, type: 3}
|
||||
- {fileID: 1492337780157316, guid: 3b74c335f9bb248547cefd868e3ced7b, type: 3}
|
||||
- {fileID: 1297496267986254, guid: 12e6fb69c093b59a4235c41bc1e2300b, type: 3}
|
||||
- {fileID: 1288395191254353, guid: add6c97bc117c5a240ed8d334efc1434, type: 3}
|
||||
- {fileID: 1689028653866908, guid: a0cb3b7b3dbf158d4592bc65cb38f961, type: 3}
|
||||
- {fileID: 1973774761334177, guid: 749ef4121da89fb3443a75815988319c, type: 3}
|
||||
- {fileID: 1333551932251375, guid: 35bda4023eaac58745da5960457ae352, type: 3}
|
||||
- {fileID: 1627512324759526, guid: b6c174dce53d29b84f4f70b5371df5e6, type: 3}
|
||||
- {fileID: 1086168063367571, guid: 7c7706b857a509a74a7fb631b7f35787, type: 3}
|
||||
- {fileID: 1300994118367831, guid: 8fc088593d16fa8f436f854ca90b1f35, type: 3}
|
||||
- {fileID: 1887923683873935, guid: c611e9a2583d338a495ac6bc5089b465, type: 3}
|
||||
- {fileID: 1062975116743938, guid: 91a93feda03ecf824a1c912c65ec4922, type: 3}
|
||||
- {fileID: 1380739253970218, guid: da2126c6f7107da146e905c9409a6d43, type: 3}
|
||||
- {fileID: 1165003388906840, guid: 317a9cfa78c4c9b24f7906173e3b0e75, type: 3}
|
||||
- {fileID: 1505058240137202, guid: 4dbff79b8486c68e4b8fcef1de07b707, type: 3}
|
||||
- {fileID: 1225123916247272, guid: 6ca6e38cef897bb940003b4d4b904671, type: 3}
|
||||
- {fileID: 1865442820050835, guid: dfc2807d00d1d2a24f6853be15a217ef, type: 3}
|
||||
- {fileID: 1813356220450816, guid: 597b92a7d8ea78a2435d74a087566129, type: 3}
|
||||
- {fileID: 1373626037220906, guid: 7146ba416ca11c9c4b74b78687fa25ec, type: 3}
|
||||
- {fileID: 1403606303201775, guid: 84d2411aefd50c2b28e8c76596d99fbf, type: 3}
|
||||
|
|
|
@ -156,7 +156,7 @@ public class Button : Widget
|
|||
if (this.animate)
|
||||
{
|
||||
bool flag = !this.down && this.mouseOver;
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
flag = (this.down || this.mouseOver);
|
||||
}
|
||||
|
|
|
@ -142,8 +142,6 @@ public class ConstructionUI : WPFMonoBehaviour
|
|||
int num = 0;
|
||||
int num2 = 0;
|
||||
int num3 = 0;
|
||||
this.m_useDragOffset = (DeviceInfo.UsesTouchInput && !Singleton<BuildCustomizationLoader>.Instance.IsHDVersion);
|
||||
this.m_allowDragPlacement = !DeviceInfo.UsesTouchInput;
|
||||
foreach (GameObject gameObject in WPFMonoBehaviour.gameData.m_parts)
|
||||
{
|
||||
Transform transform = gameObject.transform;
|
||||
|
@ -274,6 +272,9 @@ public class ConstructionUI : WPFMonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
this.m_useDragOffset = (Singleton<InputManager>.Instance.UsesTouchInput && !Singleton<BuildCustomizationLoader>.Instance.IsHDVersion);
|
||||
this.m_allowDragPlacement = !Singleton<InputManager>.Instance.UsesTouchInput;
|
||||
|
||||
if (this.m_disableFunctionality)
|
||||
{
|
||||
return;
|
||||
|
@ -808,7 +809,7 @@ public class ConstructionUI : WPFMonoBehaviour
|
|||
this.m_dragStarted = false;
|
||||
}
|
||||
float num = 1f;
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
num = ((!this.m_useDragOffset) ? 10f : 20f);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ public class DeviceInfo
|
|||
{
|
||||
get
|
||||
{
|
||||
return Input.touchSupported && Input.touchCount != 0; // * Input.touchCount is checked so that if there are no touches, mouse input will be used (this is assummed to be called on every update)
|
||||
return Singleton<InputManager>.Instance.UsesTouchInput;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,18 +163,18 @@ public class EpisodeSelector : MonoBehaviour
|
|||
{
|
||||
UserSettings.SetInt(Singleton<GameManager>.Instance.CurrentSceneName + "_active_page", this.m_page);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(true);
|
||||
this.m_leftScroll.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (!DeviceInfo.UsesTouchInput)
|
||||
else if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (this.CurrentPage == 0)
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ public class EpisodeSelector : MonoBehaviour
|
|||
float num2 = vector2.x - vector.x;
|
||||
this.m_scrollPivot.transform.localPosition = new Vector3(Mathf.Clamp(this.m_scrollPivot.transform.localPosition.x + num2, this.m_rightDragLimit, this.m_leftDragLimit), this.m_scrollPivot.transform.localPosition.y, this.m_scrollPivot.transform.localPosition.z);
|
||||
Vector3 vector3 = this.m_hudCamera.ScreenToWorldPoint(this.m_initialInputPos);
|
||||
if (!DeviceInfo.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
|
@ -319,7 +319,7 @@ public class EpisodeSelector : MonoBehaviour
|
|||
}
|
||||
this.m_rightDragLimit = -this.m_hudCamera.ScreenToWorldPoint(new Vector3((float)(Screen.width * this.m_pageCount) - this.EdgeMargin, 0f, 0f)).x;
|
||||
this.m_leftDragLimit = -this.m_hudCamera.ScreenToWorldPoint(new Vector3(this.EdgeMargin, 0f, 0f)).x;
|
||||
if (DeviceInfo.UsesTouchInput || this.m_pageCount <= 1)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput || this.m_pageCount <= 1)
|
||||
{
|
||||
this.m_leftScroll.SetActive(false);
|
||||
this.m_rightScroll.SetActive(false);
|
||||
|
|
|
@ -243,7 +243,7 @@ public class GuiManager : Singleton<GuiManager>
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.TouchInput();
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public class IngameCamera : WPFMonoBehaviour
|
|||
}
|
||||
if (WPFMonoBehaviour.levelManager.gameState == LevelManager.GameState.Building)
|
||||
{
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
float num = Input.GetAxis("Mouse ScrollWheel") + this.m_keyZoomDelta;
|
||||
if (num < 0f && !WPFMonoBehaviour.levelManager.ConstructionUI.IsDragging())
|
||||
|
@ -194,7 +194,7 @@ public class IngameCamera : WPFMonoBehaviour
|
|||
}
|
||||
if (WPFMonoBehaviour.levelManager.gameState == LevelManager.GameState.PreviewWhileBuilding)
|
||||
{
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (this.currentFOV <= 9f)
|
||||
{
|
||||
|
@ -644,7 +644,7 @@ public class IngameCamera : WPFMonoBehaviour
|
|||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
Vector3 vector = WPFMonoBehaviour.ScreenToZ0(this.m_panStartPosition) - WPFMonoBehaviour.ScreenToZ0(Input.mousePosition);
|
||||
this.m_panStartPosition = Input.mousePosition;
|
||||
|
@ -707,7 +707,7 @@ public class IngameCamera : WPFMonoBehaviour
|
|||
{
|
||||
return 0f;
|
||||
}
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (Input.touchCount != 2)
|
||||
{
|
||||
|
@ -766,7 +766,7 @@ public class IngameCamera : WPFMonoBehaviour
|
|||
|
||||
private void DoPanning()
|
||||
{
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (Input.touchCount == 1)
|
||||
{
|
||||
|
|
38
Assets/Scripts/Assembly-CSharp/InputManager.cs
Normal file
38
Assets/Scripts/Assembly-CSharp/InputManager.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InputManager : Singleton<InputManager>
|
||||
{
|
||||
public bool UsesTouchInput { get; set; } // * This value may change at any time
|
||||
|
||||
#if !UNITY_WEBGL
|
||||
private void Awake()
|
||||
{
|
||||
Input.simulateMouseWithTouches = false;
|
||||
RuntimePlatform runtimePlatform = Application.platform;
|
||||
this.UsesTouchInput = runtimePlatform == RuntimePlatform.IPhonePlayer || runtimePlatform == RuntimePlatform.Android; // * This is just a default value
|
||||
base.SetAsPersistant();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
bool usesTouch = this.UsesTouchInput;
|
||||
|
||||
if (!usesTouch && Input.touchCount != 0)
|
||||
{
|
||||
this.UsesTouchInput = true;
|
||||
}
|
||||
else if (usesTouch && InputManager.CheckMouse())
|
||||
{
|
||||
this.UsesTouchInput = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckMouse()
|
||||
{
|
||||
if (!Input.mousePresent) return false;
|
||||
return Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2);
|
||||
}
|
||||
#endif
|
||||
}
|
11
Assets/Scripts/Assembly-CSharp/InputManager.cs.meta
Normal file
11
Assets/Scripts/Assembly-CSharp/InputManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19e228d4d289a94f19ef06ee08631c71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -175,12 +175,13 @@ public class LevelSelector : WPFMonoBehaviour
|
|||
this.m_buttonGrid = base.transform.Find("ButtonGrid").GetComponent<ButtonGrid>();
|
||||
this.m_currentScreenWidth = Screen.width;
|
||||
this.m_currentScreenHeight = Screen.height;
|
||||
this.m_currentUsesTouchInput = Singleton<InputManager>.Instance.UsesTouchInput;
|
||||
this.m_page = Mathf.Min(this.m_page, this.m_pageCount);
|
||||
Singleton<GameManager>.Instance.OpenEpisode(this);
|
||||
this.CreateButtons();
|
||||
this.CreatePageDots();
|
||||
this.LayoutButtons(this.m_page);
|
||||
if (DeviceInfo.UsesTouchInput)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_leftScroll.SetActive(false);
|
||||
this.m_rightScroll.SetActive(false);
|
||||
|
@ -566,7 +567,7 @@ public class LevelSelector : WPFMonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (this.m_currentScreenWidth != Screen.width || this.m_currentScreenHeight != Screen.height)
|
||||
if (this.m_currentScreenWidth != Screen.width || this.m_currentScreenHeight != Screen.height || this.m_currentUsesTouchInput != Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.LayoutButtons(this.m_page);
|
||||
this.m_currentScreenWidth = Screen.width;
|
||||
|
@ -583,18 +584,18 @@ public class LevelSelector : WPFMonoBehaviour
|
|||
{
|
||||
UserSettings.SetInt(Singleton<GameManager>.Instance.CurrentSceneName + "_active_page", this.m_page);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(true);
|
||||
this.m_leftScroll.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (!DeviceInfo.UsesTouchInput)
|
||||
else if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (this.CurrentPage == 0)
|
||||
{
|
||||
|
@ -625,7 +626,7 @@ public class LevelSelector : WPFMonoBehaviour
|
|||
float num = vector2.x - vector.x;
|
||||
this.m_buttonGrid.transform.localPosition = new Vector3(Mathf.Clamp(this.m_buttonGrid.transform.localPosition.x + num, this.m_rightDragLimit, this.m_leftDragLimit), this.m_buttonGrid.transform.localPosition.y, this.m_buttonGrid.transform.localPosition.z);
|
||||
Vector3 vector3 = WPFMonoBehaviour.hudCamera.ScreenToWorldPoint(this.m_initialInputPos);
|
||||
if (!DeviceInfo.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
|
@ -1037,6 +1038,8 @@ public class LevelSelector : WPFMonoBehaviour
|
|||
|
||||
private int m_currentScreenHeight;
|
||||
|
||||
private bool m_currentUsesTouchInput;
|
||||
|
||||
private bool m_isIapOpen;
|
||||
|
||||
private bool m_isDialogOpen;
|
||||
|
|
|
@ -153,18 +153,18 @@ public class PageSelector : MonoBehaviour
|
|||
{
|
||||
UserSettings.SetInt(Singleton<GameManager>.Instance.CurrentSceneName + "_active_page", this.m_page);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(true);
|
||||
this.m_leftScroll.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (!DeviceInfo.UsesTouchInput)
|
||||
else if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
}
|
||||
if (!DeviceInfo.UsesTouchInput)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput)
|
||||
{
|
||||
if (this.CurrentPage == 0)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ public class PageSelector : MonoBehaviour
|
|||
float num2 = vector2.x - vector.x;
|
||||
this.m_scrollPivot.transform.localPosition = new Vector3(Mathf.Clamp(this.m_scrollPivot.transform.localPosition.x + num2, this.m_rightDragLimit, this.m_leftDragLimit), this.m_scrollPivot.transform.localPosition.y, this.m_scrollPivot.transform.localPosition.z);
|
||||
Vector3 vector3 = this.m_hudCamera.ScreenToWorldPoint(this.m_initialInputPos);
|
||||
if (!DeviceInfo.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
if (!Singleton<InputManager>.Instance.UsesTouchInput && Mathf.Abs(vector2.x - vector3.x) > 0.2f)
|
||||
{
|
||||
this.m_rightScroll.SetActive(false);
|
||||
this.m_leftScroll.SetActive(false);
|
||||
|
@ -311,7 +311,7 @@ public class PageSelector : MonoBehaviour
|
|||
}
|
||||
this.m_rightDragLimit = -this.m_hudCamera.ScreenToWorldPoint(new Vector3((float)(Screen.width * this.m_pageCount) - this.EdgeMargin, 0f, 0f)).x;
|
||||
this.m_leftDragLimit = -this.m_hudCamera.ScreenToWorldPoint(new Vector3(this.EdgeMargin, 0f, 0f)).x;
|
||||
if (DeviceInfo.UsesTouchInput || this.m_pageCount <= 1)
|
||||
if (Singleton<InputManager>.Instance.UsesTouchInput || this.m_pageCount <= 1)
|
||||
{
|
||||
this.m_leftScroll.SetActive(false);
|
||||
this.m_rightScroll.SetActive(false);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9f40fa0a387a2bdb9f4171ac9b2fdc5
|
||||
guid: 70431cd6bf4f947d9ad137403fc91c46
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue