UICamera.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using UnityEngine;
  7. [ExecuteInEditMode]
  8. [AddComponentMenu("NGUI/UI/NGUI Event System (UICamera)")]
  9. [RequireComponent(typeof(Camera))]
  10. public class UICamera : MonoBehaviour
  11. {
  12. [Obsolete("Use new OnDragStart / OnDragOver / OnDragOut / OnDragEnd events instead")]
  13. public bool stickyPress
  14. {
  15. get
  16. {
  17. return true;
  18. }
  19. }
  20. public static Ray currentRay
  21. {
  22. get
  23. {
  24. return (!(UICamera.currentCamera != null) || UICamera.currentTouch == null) ? default(Ray) : UICamera.currentCamera.ScreenPointToRay(UICamera.currentTouch.pos);
  25. }
  26. }
  27. [Obsolete("Use delegates instead such as UICamera.onClick, UICamera.onHover, etc.")]
  28. public static GameObject genericEventHandler
  29. {
  30. get
  31. {
  32. return UICamera.mGenericHandler;
  33. }
  34. set
  35. {
  36. UICamera.mGenericHandler = value;
  37. }
  38. }
  39. private bool handlesEvents
  40. {
  41. get
  42. {
  43. return UICamera.eventHandler == this;
  44. }
  45. }
  46. public Camera cachedCamera
  47. {
  48. get
  49. {
  50. if (this.mCam == null)
  51. {
  52. this.mCam = base.GetComponent<Camera>();
  53. }
  54. return this.mCam;
  55. }
  56. }
  57. public bool Hover
  58. {
  59. get
  60. {
  61. return this.m_bHover;
  62. }
  63. private set
  64. {
  65. this.m_bHover = value;
  66. }
  67. }
  68. public bool EnableProcess
  69. {
  70. get
  71. {
  72. return this.m_bProcessEnable;
  73. }
  74. set
  75. {
  76. this.m_bProcessEnable = value;
  77. }
  78. }
  79. public void SetOvrVirtualMousePos(bool f_bHandL, Vector3 v)
  80. {
  81. v.x = Mathf.Min(Mathf.Max(v.x, 3f), 1277f);
  82. v.y = Mathf.Min(Mathf.Max(v.y, 3f), 717f);
  83. v.z = 0f;
  84. this.m_vVirtualMousePos[(!f_bHandL) ? 1 : 0] = v;
  85. }
  86. public Vector3 GetOvrVirtualMousePos(bool f_bHandL)
  87. {
  88. return this.m_vVirtualMousePos[(!f_bHandL) ? 1 : 0];
  89. }
  90. public Vector3 GetOvrVirtualMouseCurrentSidePos()
  91. {
  92. return this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide];
  93. }
  94. public void CreateVirtualCursorObj()
  95. {
  96. if (this.m_goVirtualCursor != null)
  97. {
  98. this.m_goVirtualCursor = new GameObject[2];
  99. }
  100. if (this.m_spriteVirtualCursor != null)
  101. {
  102. this.m_spriteVirtualCursor = new UI2DSprite[2];
  103. }
  104. GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("OVR/PanelVCursor")) as GameObject;
  105. gameObject.transform.parent = base.transform.parent;
  106. gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
  107. gameObject.SetActive(true);
  108. this.m_goVirtualCursor[0] = gameObject;
  109. this.m_spriteVirtualCursor[0] = gameObject.GetComponentInChildren<UI2DSprite>();
  110. gameObject = UnityEngine.Object.Instantiate<GameObject>(gameObject);
  111. gameObject.transform.parent = base.transform.parent;
  112. gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
  113. gameObject.SetActive(true);
  114. this.m_goVirtualCursor[1] = gameObject;
  115. this.m_spriteVirtualCursor[1] = gameObject.GetComponentInChildren<UI2DSprite>();
  116. }
  117. public void HideVirtualCursorObj()
  118. {
  119. for (int i = 0; i < 2; i++)
  120. {
  121. this.SetActiveVirtualCursorObj((UICamera.VCURSOR)i, false);
  122. }
  123. }
  124. public void SetActiveVirtualCursorObjByNocurrent(UICamera.VCURSOR f_eCursor, bool f_bActive)
  125. {
  126. if (this.m_goVirtualCursor[(int)f_eCursor] != null)
  127. {
  128. UICamera.VCURSOR vcursor = (f_eCursor != UICamera.VCURSOR.LEFT) ? UICamera.VCURSOR.LEFT : UICamera.VCURSOR.RIGHT;
  129. if (!f_bActive)
  130. {
  131. if (f_eCursor == this.m_eCurrentCursorSide)
  132. {
  133. if (this.m_goVirtualCursor[(int)vcursor].activeInHierarchy)
  134. {
  135. this.SetCurrentCursorSide(vcursor);
  136. this.m_goVirtualCursor[(int)f_eCursor].SetActive(false);
  137. this.m_bVirtualDummyActive[(int)f_eCursor] = false;
  138. }
  139. else
  140. {
  141. this.m_bVirtualDummyActive[(int)f_eCursor] = true;
  142. }
  143. }
  144. else
  145. {
  146. this.m_goVirtualCursor[(int)f_eCursor].SetActive(false);
  147. this.m_bVirtualDummyActive[(int)f_eCursor] = false;
  148. }
  149. }
  150. else
  151. {
  152. this.m_goVirtualCursor[(int)f_eCursor].SetActive(true);
  153. this.m_bVirtualDummyActive[(int)f_eCursor] = false;
  154. if (this.m_bVirtualDummyActive[(int)vcursor])
  155. {
  156. this.m_goVirtualCursor[(int)vcursor].SetActive(false);
  157. this.m_bVirtualDummyActive[(int)vcursor] = false;
  158. this.SetCurrentCursorSide(f_eCursor);
  159. }
  160. }
  161. }
  162. }
  163. public void SetActiveVirtualCursorObj(UICamera.VCURSOR f_eCursor, bool f_bActive)
  164. {
  165. if (this.m_goVirtualCursor[(int)f_eCursor] != null)
  166. {
  167. this.m_goVirtualCursor[(int)f_eCursor].SetActive(f_bActive);
  168. }
  169. }
  170. public void DeleteVirtualCursorObj()
  171. {
  172. for (int i = 0; i < 2; i++)
  173. {
  174. if (this.m_goVirtualCursor[i] != null)
  175. {
  176. UnityEngine.Object.DestroyImmediate(this.m_goVirtualCursor[i]);
  177. this.m_goVirtualCursor[i] = null;
  178. }
  179. }
  180. }
  181. public void SetCurrentCursorSide(UICamera.VCURSOR f_eCursor)
  182. {
  183. this.m_eCurrentCursorSide = f_eCursor;
  184. }
  185. public static bool isOverUI
  186. {
  187. get
  188. {
  189. if (UICamera.currentTouch != null)
  190. {
  191. return UICamera.currentTouch.isOverUI;
  192. }
  193. return !(UICamera.hoveredObject == null) && !(UICamera.hoveredObject == UICamera.fallThrough) && NGUITools.FindInParents<UIRoot>(UICamera.hoveredObject) != null;
  194. }
  195. }
  196. public static GameObject selectedObject
  197. {
  198. get
  199. {
  200. return UICamera.mCurrentSelection;
  201. }
  202. set
  203. {
  204. UICamera.SetSelection(value, UICamera.currentScheme);
  205. }
  206. }
  207. public static bool IsPressed(GameObject go)
  208. {
  209. for (int i = 0; i < 3; i++)
  210. {
  211. if (UICamera.mMouse[i].pressed == go)
  212. {
  213. return true;
  214. }
  215. }
  216. foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
  217. {
  218. if (keyValuePair.Value.pressed == go)
  219. {
  220. return true;
  221. }
  222. }
  223. return UICamera.controller.pressed == go;
  224. }
  225. protected static void SetSelection(GameObject go, UICamera.ControlScheme scheme)
  226. {
  227. if (UICamera.mNextSelection != null)
  228. {
  229. UICamera.mNextSelection = go;
  230. }
  231. else if (UICamera.mCurrentSelection != go)
  232. {
  233. UICamera.mNextSelection = go;
  234. UICamera.mNextScheme = scheme;
  235. if (UICamera.list.size > 0)
  236. {
  237. UICamera uicamera = (!(UICamera.mNextSelection != null)) ? UICamera.list[0] : UICamera.FindCameraForLayer(UICamera.mNextSelection.layer);
  238. if (uicamera != null)
  239. {
  240. uicamera.StartCoroutine(uicamera.ChangeSelection());
  241. }
  242. }
  243. }
  244. }
  245. private IEnumerator ChangeSelection()
  246. {
  247. yield return new WaitForEndOfFrame();
  248. if (UICamera.onSelect != null)
  249. {
  250. UICamera.onSelect(UICamera.mCurrentSelection, false);
  251. }
  252. UICamera.Notify(UICamera.mCurrentSelection, "OnSelect", false);
  253. UICamera.mCurrentSelection = UICamera.mNextSelection;
  254. UICamera.mNextSelection = null;
  255. if (UICamera.mCurrentSelection != null)
  256. {
  257. UICamera.current = this;
  258. UICamera.currentCamera = this.mCam;
  259. UICamera.currentScheme = UICamera.mNextScheme;
  260. UICamera.inputHasFocus = (UICamera.mCurrentSelection.GetComponent<UIInput>() != null);
  261. if (UICamera.onSelect != null)
  262. {
  263. UICamera.onSelect(UICamera.mCurrentSelection, true);
  264. }
  265. UICamera.Notify(UICamera.mCurrentSelection, "OnSelect", true);
  266. UICamera.current = null;
  267. }
  268. else
  269. {
  270. UICamera.inputHasFocus = false;
  271. }
  272. yield break;
  273. }
  274. public static int touchCount
  275. {
  276. get
  277. {
  278. int num = 0;
  279. foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
  280. {
  281. if (keyValuePair.Value.pressed != null)
  282. {
  283. num++;
  284. }
  285. }
  286. for (int i = 0; i < UICamera.mMouse.Length; i++)
  287. {
  288. if (UICamera.mMouse[i].pressed != null)
  289. {
  290. num++;
  291. }
  292. }
  293. if (UICamera.controller.pressed != null)
  294. {
  295. num++;
  296. }
  297. return num;
  298. }
  299. }
  300. public static int dragCount
  301. {
  302. get
  303. {
  304. int num = 0;
  305. foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
  306. {
  307. if (keyValuePair.Value.dragged != null)
  308. {
  309. num++;
  310. }
  311. }
  312. for (int i = 0; i < UICamera.mMouse.Length; i++)
  313. {
  314. if (UICamera.mMouse[i].dragged != null)
  315. {
  316. num++;
  317. }
  318. }
  319. if (UICamera.controller.dragged != null)
  320. {
  321. num++;
  322. }
  323. return num;
  324. }
  325. }
  326. public static Camera mainCamera
  327. {
  328. get
  329. {
  330. UICamera eventHandler = UICamera.eventHandler;
  331. return (!(eventHandler != null)) ? null : eventHandler.cachedCamera;
  332. }
  333. }
  334. public static UICamera eventHandler
  335. {
  336. get
  337. {
  338. for (int i = 0; i < UICamera.list.size; i++)
  339. {
  340. UICamera uicamera = UICamera.list.buffer[i];
  341. if (!(uicamera == null) && uicamera.enabled && NGUITools.GetActive(uicamera.gameObject))
  342. {
  343. return uicamera;
  344. }
  345. }
  346. return null;
  347. }
  348. }
  349. private static int CompareFunc(UICamera a, UICamera b)
  350. {
  351. if (a.cachedCamera.depth < b.cachedCamera.depth)
  352. {
  353. return 1;
  354. }
  355. if (a.cachedCamera.depth > b.cachedCamera.depth)
  356. {
  357. return -1;
  358. }
  359. return 0;
  360. }
  361. private static Rigidbody FindRootRigidbody(Transform trans)
  362. {
  363. while (trans != null)
  364. {
  365. if (trans.GetComponent<UIPanel>() != null)
  366. {
  367. return null;
  368. }
  369. Rigidbody component = trans.GetComponent<Rigidbody>();
  370. if (component != null)
  371. {
  372. return component;
  373. }
  374. trans = trans.parent;
  375. }
  376. return null;
  377. }
  378. private static Rigidbody2D FindRootRigidbody2D(Transform trans)
  379. {
  380. while (trans != null)
  381. {
  382. if (trans.GetComponent<UIPanel>() != null)
  383. {
  384. return null;
  385. }
  386. Rigidbody2D component = trans.GetComponent<Rigidbody2D>();
  387. if (component != null)
  388. {
  389. return component;
  390. }
  391. trans = trans.parent;
  392. }
  393. return null;
  394. }
  395. public static bool Raycast(Vector3 inPos)
  396. {
  397. for (int i = 0; i < UICamera.list.size; i++)
  398. {
  399. UICamera.list.buffer[i].Hover = false;
  400. }
  401. for (int j = 0; j < UICamera.list.size; j++)
  402. {
  403. UICamera uicamera = UICamera.list.buffer[j];
  404. if (uicamera.enabled && NGUITools.GetActive(uicamera.gameObject) && uicamera.EnableProcess)
  405. {
  406. UICamera.currentCamera = uicamera.cachedCamera;
  407. Vector3 vector = UICamera.currentCamera.ScreenToViewportPoint(inPos);
  408. if (!float.IsNaN(vector.x) && !float.IsNaN(vector.y))
  409. {
  410. if (vector.x >= 0f && vector.x <= 1f && vector.y >= 0f && vector.y <= 1f)
  411. {
  412. Ray ray = UICamera.currentCamera.ScreenPointToRay(inPos);
  413. int layerMask = UICamera.currentCamera.cullingMask & uicamera.eventReceiverMask;
  414. float num = (uicamera.rangeDistance <= 0f) ? (UICamera.currentCamera.farClipPlane - UICamera.currentCamera.nearClipPlane) : uicamera.rangeDistance;
  415. if (uicamera.eventType == UICamera.EventType.World_3D)
  416. {
  417. if (Physics.Raycast(ray, out UICamera.lastHit, num, layerMask))
  418. {
  419. UICamera.lastWorldPosition = UICamera.lastHit.point;
  420. UICamera.hoveredObject = UICamera.lastHit.collider.gameObject;
  421. if (!UICamera.list[0].eventsGoToColliders)
  422. {
  423. Rigidbody rigidbody = UICamera.FindRootRigidbody(UICamera.hoveredObject.transform);
  424. if (rigidbody != null)
  425. {
  426. UICamera.hoveredObject = rigidbody.gameObject;
  427. }
  428. }
  429. uicamera.Hover = true;
  430. return true;
  431. }
  432. }
  433. else if (uicamera.eventType == UICamera.EventType.UI_3D)
  434. {
  435. RaycastHit[] array = Physics.RaycastAll(ray, num, layerMask);
  436. if (array.Length > 1)
  437. {
  438. int k = 0;
  439. while (k < array.Length)
  440. {
  441. GameObject gameObject = array[k].collider.gameObject;
  442. UIWidget component = gameObject.GetComponent<UIWidget>();
  443. if (component != null)
  444. {
  445. if (component.isVisible)
  446. {
  447. if (component.hitCheck == null || component.hitCheck(array[k].point))
  448. {
  449. goto IL_2A2;
  450. }
  451. }
  452. }
  453. else
  454. {
  455. UIRect uirect = NGUITools.FindInParents<UIRect>(gameObject);
  456. if (!(uirect != null) || uirect.finalAlpha >= 0.001f)
  457. {
  458. goto IL_2A2;
  459. }
  460. }
  461. IL_323:
  462. k++;
  463. continue;
  464. IL_2A2:
  465. UICamera.mHit.depth = NGUITools.CalculateRaycastDepth(gameObject);
  466. if (UICamera.mHit.depth != 2147483647)
  467. {
  468. UICamera.mHit.hit = array[k];
  469. UICamera.mHit.point = array[k].point;
  470. UICamera.mHit.go = array[k].collider.gameObject;
  471. UICamera.mHits.Add(UICamera.mHit);
  472. goto IL_323;
  473. }
  474. goto IL_323;
  475. }
  476. UICamera.mHits.Sort((UICamera.DepthEntry r1, UICamera.DepthEntry r2) => r2.depth.CompareTo(r1.depth));
  477. for (int l = 0; l < UICamera.mHits.size; l++)
  478. {
  479. if (UICamera.IsVisible(ref UICamera.mHits.buffer[l]))
  480. {
  481. UICamera.lastHit = UICamera.mHits[l].hit;
  482. UICamera.hoveredObject = UICamera.mHits[l].go;
  483. UICamera.lastWorldPosition = UICamera.mHits[l].point;
  484. UICamera.mHits.Clear();
  485. uicamera.Hover = true;
  486. return true;
  487. }
  488. }
  489. UICamera.mHits.Clear();
  490. }
  491. else if (array.Length == 1)
  492. {
  493. GameObject gameObject2 = array[0].collider.gameObject;
  494. UIWidget component2 = gameObject2.GetComponent<UIWidget>();
  495. if (component2 != null)
  496. {
  497. if (!component2.isVisible)
  498. {
  499. goto IL_849;
  500. }
  501. if (component2.hitCheck != null && !component2.hitCheck(array[0].point))
  502. {
  503. goto IL_849;
  504. }
  505. }
  506. else
  507. {
  508. UIRect uirect2 = NGUITools.FindInParents<UIRect>(gameObject2);
  509. if (uirect2 != null && uirect2.finalAlpha < 0.001f)
  510. {
  511. goto IL_849;
  512. }
  513. }
  514. if (UICamera.IsVisible(array[0].point, array[0].collider.gameObject))
  515. {
  516. UICamera.lastHit = array[0];
  517. UICamera.lastWorldPosition = array[0].point;
  518. UICamera.hoveredObject = UICamera.lastHit.collider.gameObject;
  519. uicamera.Hover = true;
  520. return true;
  521. }
  522. }
  523. }
  524. else if (uicamera.eventType == UICamera.EventType.World_2D)
  525. {
  526. if (UICamera.m2DPlane.Raycast(ray, out num))
  527. {
  528. Vector3 point = ray.GetPoint(num);
  529. Collider2D collider2D = Physics2D.OverlapPoint(point, layerMask);
  530. if (collider2D)
  531. {
  532. UICamera.lastWorldPosition = point;
  533. UICamera.hoveredObject = collider2D.gameObject;
  534. if (!uicamera.eventsGoToColliders)
  535. {
  536. Rigidbody2D rigidbody2D = UICamera.FindRootRigidbody2D(UICamera.hoveredObject.transform);
  537. if (rigidbody2D != null)
  538. {
  539. UICamera.hoveredObject = rigidbody2D.gameObject;
  540. }
  541. }
  542. uicamera.Hover = true;
  543. return true;
  544. }
  545. }
  546. }
  547. else if (uicamera.eventType == UICamera.EventType.UI_2D)
  548. {
  549. if (UICamera.m2DPlane.Raycast(ray, out num))
  550. {
  551. UICamera.lastWorldPosition = ray.GetPoint(num);
  552. Collider2D[] array2 = Physics2D.OverlapPointAll(UICamera.lastWorldPosition, layerMask);
  553. if (array2.Length > 1)
  554. {
  555. int m = 0;
  556. while (m < array2.Length)
  557. {
  558. GameObject gameObject3 = array2[m].gameObject;
  559. UIWidget component3 = gameObject3.GetComponent<UIWidget>();
  560. if (component3 != null)
  561. {
  562. if (component3.isVisible)
  563. {
  564. if (component3.hitCheck == null || component3.hitCheck(UICamera.lastWorldPosition))
  565. {
  566. goto IL_692;
  567. }
  568. }
  569. }
  570. else
  571. {
  572. UIRect uirect3 = NGUITools.FindInParents<UIRect>(gameObject3);
  573. if (!(uirect3 != null) || uirect3.finalAlpha >= 0.001f)
  574. {
  575. goto IL_692;
  576. }
  577. }
  578. IL_6E1:
  579. m++;
  580. continue;
  581. IL_692:
  582. UICamera.mHit.depth = NGUITools.CalculateRaycastDepth(gameObject3);
  583. if (UICamera.mHit.depth != 2147483647)
  584. {
  585. UICamera.mHit.go = gameObject3;
  586. UICamera.mHit.point = UICamera.lastWorldPosition;
  587. UICamera.mHits.Add(UICamera.mHit);
  588. goto IL_6E1;
  589. }
  590. goto IL_6E1;
  591. }
  592. UICamera.mHits.Sort((UICamera.DepthEntry r1, UICamera.DepthEntry r2) => r2.depth.CompareTo(r1.depth));
  593. for (int n = 0; n < UICamera.mHits.size; n++)
  594. {
  595. if (UICamera.IsVisible(ref UICamera.mHits.buffer[n]))
  596. {
  597. UICamera.hoveredObject = UICamera.mHits[n].go;
  598. UICamera.mHits.Clear();
  599. uicamera.Hover = true;
  600. return true;
  601. }
  602. }
  603. UICamera.mHits.Clear();
  604. }
  605. else if (array2.Length == 1)
  606. {
  607. GameObject gameObject4 = array2[0].gameObject;
  608. UIWidget component4 = gameObject4.GetComponent<UIWidget>();
  609. if (component4 != null)
  610. {
  611. if (!component4.isVisible)
  612. {
  613. goto IL_849;
  614. }
  615. if (component4.hitCheck != null && !component4.hitCheck(UICamera.lastWorldPosition))
  616. {
  617. goto IL_849;
  618. }
  619. }
  620. else
  621. {
  622. UIRect uirect4 = NGUITools.FindInParents<UIRect>(gameObject4);
  623. if (uirect4 != null && uirect4.finalAlpha < 0.001f)
  624. {
  625. goto IL_849;
  626. }
  627. }
  628. if (UICamera.IsVisible(UICamera.lastWorldPosition, gameObject4))
  629. {
  630. UICamera.hoveredObject = gameObject4;
  631. uicamera.Hover = true;
  632. return true;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. }
  639. }
  640. IL_849:;
  641. }
  642. return false;
  643. }
  644. private static bool IsVisible(Vector3 worldPoint, GameObject go)
  645. {
  646. UIPanel uipanel = NGUITools.FindInParents<UIPanel>(go);
  647. while (uipanel != null)
  648. {
  649. if (!uipanel.IsVisible(worldPoint))
  650. {
  651. return false;
  652. }
  653. uipanel = uipanel.parentPanel;
  654. }
  655. return true;
  656. }
  657. private static bool IsVisible(ref UICamera.DepthEntry de)
  658. {
  659. UIPanel uipanel = NGUITools.FindInParents<UIPanel>(de.go);
  660. while (uipanel != null)
  661. {
  662. if (!uipanel.IsVisible(de.point))
  663. {
  664. return false;
  665. }
  666. uipanel = uipanel.parentPanel;
  667. }
  668. return true;
  669. }
  670. public static bool IsHighlighted(GameObject go)
  671. {
  672. if (UICamera.currentScheme == UICamera.ControlScheme.Mouse)
  673. {
  674. return UICamera.hoveredObject == go;
  675. }
  676. return UICamera.currentScheme == UICamera.ControlScheme.Controller && UICamera.selectedObject == go;
  677. }
  678. public static UICamera FindCameraForLayer(int layer)
  679. {
  680. int num = 1 << layer;
  681. for (int i = 0; i < UICamera.list.size; i++)
  682. {
  683. UICamera uicamera = UICamera.list.buffer[i];
  684. Camera cachedCamera = uicamera.cachedCamera;
  685. if (cachedCamera != null && (cachedCamera.cullingMask & num) != 0)
  686. {
  687. return uicamera;
  688. }
  689. }
  690. return null;
  691. }
  692. private static int GetDirection(KeyCode up, KeyCode down)
  693. {
  694. if (UICamera.GetKeyDown(up))
  695. {
  696. return 1;
  697. }
  698. if (UICamera.GetKeyDown(down))
  699. {
  700. return -1;
  701. }
  702. return 0;
  703. }
  704. private static int GetDirection(KeyCode up0, KeyCode up1, KeyCode down0, KeyCode down1)
  705. {
  706. if (UICamera.GetKeyDown(up0) || UICamera.GetKeyDown(up1))
  707. {
  708. return 1;
  709. }
  710. if (UICamera.GetKeyDown(down0) || UICamera.GetKeyDown(down1))
  711. {
  712. return -1;
  713. }
  714. return 0;
  715. }
  716. private static int GetDirection(string axis)
  717. {
  718. float time = RealTime.time;
  719. if (UICamera.mNextEvent < time && !string.IsNullOrEmpty(axis))
  720. {
  721. float num = UICamera.GetAxis(axis);
  722. if (num > 0.75f)
  723. {
  724. UICamera.mNextEvent = time + 0.25f;
  725. return 1;
  726. }
  727. if (num < -0.75f)
  728. {
  729. UICamera.mNextEvent = time + 0.25f;
  730. return -1;
  731. }
  732. }
  733. return 0;
  734. }
  735. public static void Notify(GameObject go, string funcName, object obj)
  736. {
  737. if (UICamera.mNotifying)
  738. {
  739. return;
  740. }
  741. UICamera.mNotifying = true;
  742. if (NGUITools.GetActive(go))
  743. {
  744. go.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
  745. if (UICamera.mGenericHandler != null && UICamera.mGenericHandler != go)
  746. {
  747. UICamera.mGenericHandler.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
  748. }
  749. }
  750. UICamera.mNotifying = false;
  751. }
  752. public static UICamera.MouseOrTouch GetMouse(int button)
  753. {
  754. return UICamera.mMouse[button];
  755. }
  756. public static UICamera.MouseOrTouch GetTouch(int id)
  757. {
  758. UICamera.MouseOrTouch mouseOrTouch = null;
  759. if (id < 0)
  760. {
  761. return UICamera.GetMouse(-id - 1);
  762. }
  763. if (!UICamera.mTouches.TryGetValue(id, out mouseOrTouch))
  764. {
  765. mouseOrTouch = new UICamera.MouseOrTouch();
  766. mouseOrTouch.pressTime = RealTime.time;
  767. mouseOrTouch.touchBegan = true;
  768. UICamera.mTouches.Add(id, mouseOrTouch);
  769. }
  770. return mouseOrTouch;
  771. }
  772. public static void RemoveTouch(int id)
  773. {
  774. UICamera.mTouches.Remove(id);
  775. }
  776. public static int ScreenWidth
  777. {
  778. get
  779. {
  780. if (Application.isPlaying && (GameMain.Instance != null && GameMain.Instance.VRMode))
  781. {
  782. return 1280;
  783. }
  784. return Screen.width;
  785. }
  786. }
  787. public static int ScreenHeight
  788. {
  789. get
  790. {
  791. if (Application.isPlaying && (GameMain.Instance != null && GameMain.Instance.VRMode))
  792. {
  793. return 720;
  794. }
  795. return Screen.height;
  796. }
  797. }
  798. private void Awake()
  799. {
  800. if (GameMain.Instance != null && GameMain.Instance.VRMode)
  801. {
  802. this.VRUpdateCamDepth();
  803. }
  804. UICamera.mWidth = UICamera.ScreenWidth;
  805. UICamera.mHeight = UICamera.ScreenHeight;
  806. if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WP8Player || Application.platform == RuntimePlatform.BlackBerryPlayer)
  807. {
  808. this.useTouch = true;
  809. if (Application.platform == RuntimePlatform.IPhonePlayer)
  810. {
  811. this.useMouse = false;
  812. this.useKeyboard = false;
  813. this.useController = false;
  814. }
  815. }
  816. else if (Application.platform == RuntimePlatform.PS3 || Application.platform == RuntimePlatform.XBOX360)
  817. {
  818. this.useMouse = false;
  819. this.useTouch = false;
  820. this.useKeyboard = false;
  821. this.useController = true;
  822. }
  823. UICamera.mMouse[0].pos = Input.mousePosition;
  824. for (int i = 1; i < 3; i++)
  825. {
  826. UICamera.mMouse[i].pos = UICamera.mMouse[0].pos;
  827. UICamera.mMouse[i].lastPos = UICamera.mMouse[0].pos;
  828. }
  829. UICamera.lastTouchPosition = UICamera.mMouse[0].pos;
  830. }
  831. private void OnEnable()
  832. {
  833. UICamera.list.Add(this);
  834. BetterList<UICamera> betterList = UICamera.list;
  835. if (UICamera.<>f__mg$cache0 == null)
  836. {
  837. UICamera.<>f__mg$cache0 = new BetterList<UICamera>.CompareFunc(UICamera.CompareFunc);
  838. }
  839. betterList.Sort(UICamera.<>f__mg$cache0);
  840. if (GameMain.Instance != null && GameMain.Instance.VRMode)
  841. {
  842. this.VRUpdateCamDepth();
  843. }
  844. }
  845. private void OnDisable()
  846. {
  847. UICamera.list.Remove(this);
  848. if (GameMain.Instance != null && GameMain.Instance.VRMode)
  849. {
  850. this.VRUpdateCamDepth();
  851. }
  852. }
  853. private void Start()
  854. {
  855. if (this.eventType != UICamera.EventType.World_3D && this.cachedCamera.transparencySortMode != TransparencySortMode.Orthographic)
  856. {
  857. this.cachedCamera.transparencySortMode = TransparencySortMode.Orthographic;
  858. }
  859. if (Application.isPlaying)
  860. {
  861. if (UICamera.fallThrough == null)
  862. {
  863. UIRoot uiroot = NGUITools.FindInParents<UIRoot>(base.gameObject);
  864. if (uiroot != null)
  865. {
  866. UICamera.fallThrough = uiroot.gameObject;
  867. }
  868. else
  869. {
  870. Transform transform = base.transform;
  871. UICamera.fallThrough = ((!(transform.parent != null)) ? base.gameObject : transform.parent.gameObject);
  872. }
  873. }
  874. this.cachedCamera.eventMask = 0;
  875. }
  876. if (this.handlesEvents)
  877. {
  878. NGUIDebug.debugRaycast = this.debug;
  879. }
  880. }
  881. private void VRUpdateCamDepth()
  882. {
  883. if (this.VRExclusionUI)
  884. {
  885. return;
  886. }
  887. UICamera[] array = (from a in UnityEngine.Object.FindObjectsOfType<UICamera>()
  888. where !a.VRExclusionUI
  889. select a).ToArray<UICamera>();
  890. if (array.Length == 0)
  891. {
  892. return;
  893. }
  894. Camera camera = array[0].cachedCamera;
  895. for (int i = 0; i < array.Length; i++)
  896. {
  897. Camera cachedCamera = array[i].cachedCamera;
  898. cachedCamera.clearFlags = CameraClearFlags.Depth;
  899. if (cachedCamera.depth < camera.depth)
  900. {
  901. camera = cachedCamera;
  902. }
  903. }
  904. camera.clearFlags = CameraClearFlags.Color;
  905. this.cachedCamera.targetTexture = GameMain.Instance.OvrMgr.UIRTarget;
  906. if (base.transform.parent.name == "SystemUI Root")
  907. {
  908. this.cachedCamera.clearFlags = CameraClearFlags.Depth;
  909. }
  910. }
  911. public static void InputEnableFlag(UICamera.INPUT_CTRL_TYPE flag, bool bEnable)
  912. {
  913. if (bEnable)
  914. {
  915. UICamera.m_unInputEnableFlag |= (uint)flag;
  916. }
  917. else
  918. {
  919. UICamera.m_unInputEnableFlag &= (uint)(~(uint)flag);
  920. }
  921. }
  922. private void Update()
  923. {
  924. if (!this.handlesEvents)
  925. {
  926. return;
  927. }
  928. if (!UICamera.InputEnable)
  929. {
  930. return;
  931. }
  932. UICamera.current = this;
  933. if (GameMain.Instance.VRMode && Application.isPlaying)
  934. {
  935. for (int i = 0; i < 2; i++)
  936. {
  937. if (!GameMain.Instance.VRDummyMode)
  938. {
  939. Vector3[] vVirtualMousePos = this.m_vVirtualMousePos;
  940. int num = i;
  941. vVirtualMousePos[num].x = vVirtualMousePos[num].x + NInput.GetAxis("Mouse X") * Time.deltaTime * 100f * 10f;
  942. Vector3[] vVirtualMousePos2 = this.m_vVirtualMousePos;
  943. int num2 = i;
  944. vVirtualMousePos2[num2].y = vVirtualMousePos2[num2].y + NInput.GetAxis("Mouse Y") * Time.deltaTime * 100f * 10f;
  945. }
  946. this.m_vVirtualMousePos[i].x = Mathf.Min(Mathf.Max(this.m_vVirtualMousePos[i].x, 3f), 1277f);
  947. this.m_vVirtualMousePos[i].y = Mathf.Min(Mathf.Max(this.m_vVirtualMousePos[i].y, 3f), 717f);
  948. this.m_vVirtualMousePos[i].z = 0f;
  949. if (this.m_goVirtualCursor[i] != null)
  950. {
  951. this.m_goVirtualCursor[i].transform.position = base.GetComponent<Camera>().ScreenToWorldPoint(this.m_vVirtualMousePos[i]);
  952. }
  953. if (this.m_spriteVirtualCursor[i] != null)
  954. {
  955. this.m_spriteVirtualCursor[i].color = ((i != (int)this.m_eCurrentCursorSide) ? new Color(1f, 1f, 1f, 0.5f) : new Color(1f, 1f, 1f, 1f));
  956. }
  957. }
  958. }
  959. if (this.useTouch)
  960. {
  961. this.ProcessTouches();
  962. }
  963. else if (this.useMouse)
  964. {
  965. this.ProcessMouse();
  966. }
  967. if (UICamera.onCustomInput != null)
  968. {
  969. UICamera.onCustomInput();
  970. }
  971. if (this.useMouse && UICamera.mCurrentSelection != null)
  972. {
  973. if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0))
  974. {
  975. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  976. UICamera.currentKey = this.cancelKey0;
  977. UICamera.selectedObject = null;
  978. }
  979. else if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1))
  980. {
  981. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  982. UICamera.currentKey = this.cancelKey1;
  983. UICamera.selectedObject = null;
  984. }
  985. }
  986. if (UICamera.mCurrentSelection == null)
  987. {
  988. UICamera.inputHasFocus = false;
  989. }
  990. if (UICamera.mCurrentSelection != null)
  991. {
  992. this.ProcessOthers();
  993. }
  994. if (this.useMouse && UICamera.mHover != null)
  995. {
  996. float num3 = string.IsNullOrEmpty(this.scrollAxisName) ? 0f : UICamera.GetAxis(this.scrollAxisName);
  997. if (num3 != 0f)
  998. {
  999. if (UICamera.onScroll != null)
  1000. {
  1001. UICamera.onScroll(UICamera.mHover, num3);
  1002. }
  1003. UICamera.Notify(UICamera.mHover, "OnScroll", num3);
  1004. }
  1005. if (UICamera.showTooltips && this.mTooltipTime != 0f && (this.mTooltipTime < RealTime.time || UICamera.GetKey(KeyCode.LeftShift) || UICamera.GetKey(KeyCode.RightShift)))
  1006. {
  1007. this.mTooltip = UICamera.mHover;
  1008. this.ShowTooltip(true);
  1009. }
  1010. }
  1011. UICamera.current = null;
  1012. UICamera.currentTouchID = -100;
  1013. }
  1014. private void LateUpdate()
  1015. {
  1016. if (!this.handlesEvents)
  1017. {
  1018. return;
  1019. }
  1020. int screenWidth = UICamera.ScreenWidth;
  1021. int screenHeight = UICamera.ScreenHeight;
  1022. if (screenWidth != UICamera.mWidth || screenHeight != UICamera.mHeight)
  1023. {
  1024. UICamera.mWidth = screenWidth;
  1025. UICamera.mHeight = screenHeight;
  1026. UIRoot.Broadcast("UpdateAnchors");
  1027. if (UICamera.onScreenResize != null)
  1028. {
  1029. UICamera.onScreenResize();
  1030. }
  1031. }
  1032. }
  1033. public void ProcessMouse()
  1034. {
  1035. if (GameMain.Instance.VRMode && Application.isPlaying)
  1036. {
  1037. if (GameMain.Instance.MainCamera.IsFadeOut())
  1038. {
  1039. return;
  1040. }
  1041. UICamera.lastTouchPosition = new Vector2(this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].x, this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].y);
  1042. }
  1043. else
  1044. {
  1045. UICamera.lastTouchPosition = Input.mousePosition;
  1046. }
  1047. UICamera.mMouse[0].delta = UICamera.lastTouchPosition - UICamera.mMouse[0].pos;
  1048. UICamera.mMouse[0].pos = UICamera.lastTouchPosition;
  1049. bool flag = UICamera.mMouse[0].delta.sqrMagnitude > 0.001f;
  1050. for (int i = 1; i < 3; i++)
  1051. {
  1052. UICamera.mMouse[i].pos = UICamera.mMouse[0].pos;
  1053. UICamera.mMouse[i].delta = UICamera.mMouse[0].delta;
  1054. }
  1055. bool flag2 = false;
  1056. bool flag3 = false;
  1057. if (UICamera.isDisableRightClick && (NInput.GetMouseButtonDown(1) || NInput.GetMouseButton(1) || NInput.GetMouseButtonUp(1)))
  1058. {
  1059. return;
  1060. }
  1061. for (int j = 0; j < 3; j++)
  1062. {
  1063. if (NInput.GetMouseButtonDown(j))
  1064. {
  1065. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1066. flag3 = true;
  1067. flag2 = true;
  1068. }
  1069. else if (NInput.GetMouseButton(j))
  1070. {
  1071. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1072. flag2 = true;
  1073. }
  1074. }
  1075. if (flag2 || flag || this.mNextRaycast < RealTime.time)
  1076. {
  1077. this.mNextRaycast = RealTime.time + 0.02f;
  1078. Vector3 inPos;
  1079. if (GameMain.Instance.VRMode && Application.isPlaying)
  1080. {
  1081. inPos = this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide];
  1082. }
  1083. else
  1084. {
  1085. inPos = Input.mousePosition;
  1086. }
  1087. if (!UICamera.Raycast(inPos))
  1088. {
  1089. UICamera.hoveredObject = UICamera.fallThrough;
  1090. UICamera.isFallThrough = true;
  1091. }
  1092. else
  1093. {
  1094. UICamera.isFallThrough = false;
  1095. }
  1096. if (UICamera.hoveredObject == null)
  1097. {
  1098. UICamera.hoveredObject = UICamera.mGenericHandler;
  1099. }
  1100. for (int k = 0; k < 3; k++)
  1101. {
  1102. UICamera.mMouse[k].current = UICamera.hoveredObject;
  1103. }
  1104. }
  1105. bool flag4 = UICamera.mMouse[0].last != UICamera.mMouse[0].current;
  1106. if (flag4)
  1107. {
  1108. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1109. }
  1110. if (flag2)
  1111. {
  1112. this.mTooltipTime = 0f;
  1113. }
  1114. else if (flag && (!this.stickyTooltip || flag4))
  1115. {
  1116. if (this.mTooltipTime != 0f)
  1117. {
  1118. this.mTooltipTime = RealTime.time + this.tooltipDelay;
  1119. }
  1120. else if (this.mTooltip != null)
  1121. {
  1122. this.ShowTooltip(false);
  1123. }
  1124. }
  1125. if (flag && UICamera.onMouseMove != null)
  1126. {
  1127. UICamera.currentTouch = UICamera.mMouse[0];
  1128. UICamera.onMouseMove(UICamera.currentTouch.delta);
  1129. UICamera.currentTouch = null;
  1130. }
  1131. if ((flag3 || !flag2) && UICamera.mHover != null && flag4)
  1132. {
  1133. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1134. UICamera.currentTouch = UICamera.mMouse[0];
  1135. if (this.mTooltip != null)
  1136. {
  1137. this.ShowTooltip(false);
  1138. }
  1139. if (UICamera.onHover != null)
  1140. {
  1141. UICamera.onHover(UICamera.mHover, false);
  1142. }
  1143. UICamera.Notify(UICamera.mHover, "OnHover", false);
  1144. UICamera.mHover = null;
  1145. }
  1146. for (int l = 0; l < 3; l++)
  1147. {
  1148. bool mouseButtonDown = NInput.GetMouseButtonDown(l);
  1149. bool mouseButtonUp = NInput.GetMouseButtonUp(l);
  1150. if (mouseButtonDown || mouseButtonUp)
  1151. {
  1152. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1153. }
  1154. UICamera.currentTouch = UICamera.mMouse[l];
  1155. UICamera.currentTouchID = -1 - l;
  1156. UICamera.currentKey = KeyCode.Mouse0 + l;
  1157. if (mouseButtonDown)
  1158. {
  1159. UICamera.currentTouch.pressedCam = UICamera.currentCamera;
  1160. }
  1161. else if (UICamera.currentTouch.pressed != null)
  1162. {
  1163. UICamera.currentCamera = UICamera.currentTouch.pressedCam;
  1164. }
  1165. this.ProcessTouch(mouseButtonDown, mouseButtonUp);
  1166. UICamera.currentKey = KeyCode.None;
  1167. }
  1168. if (!flag2 && flag4)
  1169. {
  1170. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1171. this.mTooltipTime = RealTime.time + this.tooltipDelay;
  1172. UICamera.mHover = UICamera.mMouse[0].current;
  1173. UICamera.currentTouch = UICamera.mMouse[0];
  1174. if (UICamera.onHover != null)
  1175. {
  1176. UICamera.onHover(UICamera.mHover, true);
  1177. }
  1178. UICamera.Notify(UICamera.mHover, "OnHover", true);
  1179. }
  1180. UICamera.currentTouch = null;
  1181. UICamera.mMouse[0].last = UICamera.mMouse[0].current;
  1182. for (int m = 1; m < 3; m++)
  1183. {
  1184. UICamera.mMouse[m].last = UICamera.mMouse[0].last;
  1185. }
  1186. }
  1187. public void ProcessTouches()
  1188. {
  1189. UICamera.currentScheme = UICamera.ControlScheme.Touch;
  1190. for (int i = 0; i < Input.touchCount; i++)
  1191. {
  1192. Touch touch = Input.GetTouch(i);
  1193. UICamera.currentTouchID = ((!this.allowMultiTouch) ? 1 : touch.fingerId);
  1194. UICamera.currentTouch = UICamera.GetTouch(UICamera.currentTouchID);
  1195. bool flag = touch.phase == TouchPhase.Began || UICamera.currentTouch.touchBegan;
  1196. bool flag2 = touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended;
  1197. UICamera.currentTouch.touchBegan = false;
  1198. UICamera.currentTouch.delta = ((!flag) ? (touch.position - UICamera.currentTouch.pos) : Vector2.zero);
  1199. UICamera.currentTouch.pos = touch.position;
  1200. if (!UICamera.Raycast(UICamera.currentTouch.pos))
  1201. {
  1202. UICamera.hoveredObject = UICamera.fallThrough;
  1203. }
  1204. if (UICamera.hoveredObject == null)
  1205. {
  1206. UICamera.hoveredObject = UICamera.mGenericHandler;
  1207. }
  1208. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1209. UICamera.currentTouch.current = UICamera.hoveredObject;
  1210. UICamera.lastTouchPosition = UICamera.currentTouch.pos;
  1211. if (flag)
  1212. {
  1213. UICamera.currentTouch.pressedCam = UICamera.currentCamera;
  1214. }
  1215. else if (UICamera.currentTouch.pressed != null)
  1216. {
  1217. UICamera.currentCamera = UICamera.currentTouch.pressedCam;
  1218. }
  1219. if (touch.tapCount > 1)
  1220. {
  1221. UICamera.currentTouch.clickTime = RealTime.time;
  1222. }
  1223. this.ProcessTouch(flag, flag2);
  1224. if (flag2)
  1225. {
  1226. UICamera.RemoveTouch(UICamera.currentTouchID);
  1227. }
  1228. UICamera.currentTouch.last = null;
  1229. UICamera.currentTouch = null;
  1230. if (!this.allowMultiTouch)
  1231. {
  1232. break;
  1233. }
  1234. }
  1235. if (Input.touchCount == 0)
  1236. {
  1237. if (UICamera.mUsingTouchEvents)
  1238. {
  1239. UICamera.mUsingTouchEvents = false;
  1240. return;
  1241. }
  1242. if (this.useMouse)
  1243. {
  1244. this.ProcessMouse();
  1245. }
  1246. }
  1247. else
  1248. {
  1249. UICamera.mUsingTouchEvents = true;
  1250. }
  1251. }
  1252. private void ProcessFakeTouches()
  1253. {
  1254. bool mouseButtonDown = NInput.GetMouseButtonDown(0);
  1255. bool mouseButtonUp = NInput.GetMouseButtonUp(0);
  1256. bool mouseButton = NInput.GetMouseButton(0);
  1257. if (mouseButtonDown || mouseButtonUp || mouseButton)
  1258. {
  1259. UICamera.currentTouchID = 1;
  1260. UICamera.currentTouch = UICamera.mMouse[0];
  1261. UICamera.currentTouch.touchBegan = mouseButtonDown;
  1262. if (mouseButtonDown)
  1263. {
  1264. UICamera.currentTouch.pressTime = RealTime.time;
  1265. }
  1266. Vector2 vector;
  1267. if (GameMain.Instance.VRMode && Application.isPlaying)
  1268. {
  1269. vector = new Vector2(this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].x, this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].y);
  1270. }
  1271. else
  1272. {
  1273. vector = Input.mousePosition;
  1274. }
  1275. UICamera.currentTouch.delta = ((!mouseButtonDown) ? (vector - UICamera.currentTouch.pos) : Vector2.zero);
  1276. UICamera.currentTouch.pos = vector;
  1277. if (!UICamera.Raycast(UICamera.currentTouch.pos))
  1278. {
  1279. UICamera.hoveredObject = UICamera.fallThrough;
  1280. }
  1281. if (UICamera.hoveredObject == null)
  1282. {
  1283. UICamera.hoveredObject = UICamera.mGenericHandler;
  1284. }
  1285. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1286. UICamera.currentTouch.current = UICamera.hoveredObject;
  1287. UICamera.lastTouchPosition = UICamera.currentTouch.pos;
  1288. if (mouseButtonDown)
  1289. {
  1290. UICamera.currentTouch.pressedCam = UICamera.currentCamera;
  1291. }
  1292. else if (UICamera.currentTouch.pressed != null)
  1293. {
  1294. UICamera.currentCamera = UICamera.currentTouch.pressedCam;
  1295. }
  1296. this.ProcessTouch(mouseButtonDown, mouseButtonUp);
  1297. if (mouseButtonUp)
  1298. {
  1299. UICamera.RemoveTouch(UICamera.currentTouchID);
  1300. }
  1301. UICamera.currentTouch.last = null;
  1302. UICamera.currentTouch = null;
  1303. }
  1304. }
  1305. public void ProcessOthers()
  1306. {
  1307. UICamera.currentTouchID = -100;
  1308. UICamera.currentTouch = UICamera.controller;
  1309. bool flag = false;
  1310. bool flag2 = false;
  1311. if (this.submitKey0 != KeyCode.None && UICamera.GetKeyDown(this.submitKey0))
  1312. {
  1313. UICamera.currentKey = this.submitKey0;
  1314. flag = true;
  1315. }
  1316. if (this.submitKey1 != KeyCode.None && UICamera.GetKeyDown(this.submitKey1))
  1317. {
  1318. UICamera.currentKey = this.submitKey1;
  1319. flag = true;
  1320. }
  1321. if (this.submitKey0 != KeyCode.None && UICamera.GetKeyUp(this.submitKey0))
  1322. {
  1323. UICamera.currentKey = this.submitKey0;
  1324. flag2 = true;
  1325. }
  1326. if (this.submitKey1 != KeyCode.None && UICamera.GetKeyUp(this.submitKey1))
  1327. {
  1328. UICamera.currentKey = this.submitKey1;
  1329. flag2 = true;
  1330. }
  1331. if (flag || flag2)
  1332. {
  1333. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1334. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1335. UICamera.currentTouch.current = UICamera.mCurrentSelection;
  1336. UICamera.currentTouch.last = null;
  1337. }
  1338. int num = 0;
  1339. int num2 = 0;
  1340. if (this.useKeyboard)
  1341. {
  1342. if (UICamera.inputHasFocus)
  1343. {
  1344. num += UICamera.GetDirection(KeyCode.UpArrow, KeyCode.DownArrow);
  1345. num2 += UICamera.GetDirection(KeyCode.RightArrow, KeyCode.LeftArrow);
  1346. }
  1347. else
  1348. {
  1349. num += UICamera.GetDirection(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow);
  1350. num2 += UICamera.GetDirection(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow);
  1351. }
  1352. }
  1353. if (num != 0)
  1354. {
  1355. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1356. KeyCode keyCode = (num <= 0) ? KeyCode.DownArrow : KeyCode.UpArrow;
  1357. if (UICamera.onKey != null)
  1358. {
  1359. UICamera.onKey(UICamera.mCurrentSelection, keyCode);
  1360. }
  1361. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode);
  1362. }
  1363. if (num2 != 0)
  1364. {
  1365. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1366. KeyCode keyCode2 = (num2 <= 0) ? KeyCode.LeftArrow : KeyCode.RightArrow;
  1367. if (UICamera.onKey != null)
  1368. {
  1369. UICamera.onKey(UICamera.mCurrentSelection, keyCode2);
  1370. }
  1371. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode2);
  1372. }
  1373. if (this.useKeyboard && UICamera.GetKeyDown(KeyCode.Tab))
  1374. {
  1375. UICamera.currentKey = KeyCode.Tab;
  1376. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1377. if (UICamera.onKey != null)
  1378. {
  1379. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Tab);
  1380. }
  1381. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Tab);
  1382. }
  1383. if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0))
  1384. {
  1385. UICamera.currentKey = this.cancelKey0;
  1386. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1387. if (UICamera.onKey != null)
  1388. {
  1389. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
  1390. }
  1391. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
  1392. }
  1393. if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1))
  1394. {
  1395. UICamera.currentKey = this.cancelKey1;
  1396. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1397. if (UICamera.onKey != null)
  1398. {
  1399. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
  1400. }
  1401. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
  1402. }
  1403. UICamera.currentTouch = null;
  1404. UICamera.currentKey = KeyCode.None;
  1405. }
  1406. public void ProcessTouch(bool pressed, bool unpressed)
  1407. {
  1408. bool flag = UICamera.currentScheme == UICamera.ControlScheme.Mouse;
  1409. float num = (!flag) ? this.touchDragThreshold : this.mouseDragThreshold;
  1410. float num2 = (!flag) ? this.touchClickThreshold : this.mouseClickThreshold;
  1411. num *= num;
  1412. num2 *= num2;
  1413. if (pressed)
  1414. {
  1415. if (this.mTooltip != null)
  1416. {
  1417. this.ShowTooltip(false);
  1418. }
  1419. UICamera.currentTouch.pressStarted = true;
  1420. if (UICamera.onPress != null && UICamera.currentTouch.pressed)
  1421. {
  1422. UICamera.onPress(UICamera.currentTouch.pressed, false);
  1423. }
  1424. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
  1425. UICamera.currentTouch.pressed = UICamera.currentTouch.current;
  1426. UICamera.currentTouch.dragged = UICamera.currentTouch.current;
  1427. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.BasedOnDelta;
  1428. UICamera.currentTouch.totalDelta = Vector2.zero;
  1429. UICamera.currentTouch.dragStarted = false;
  1430. if (UICamera.onPress != null && UICamera.currentTouch.pressed)
  1431. {
  1432. UICamera.onPress(UICamera.currentTouch.pressed, true);
  1433. }
  1434. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", true);
  1435. if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
  1436. {
  1437. if (this.mTooltip != null)
  1438. {
  1439. this.ShowTooltip(false);
  1440. }
  1441. UICamera.currentScheme = UICamera.ControlScheme.Touch;
  1442. UICamera.selectedObject = UICamera.currentTouch.pressed;
  1443. }
  1444. }
  1445. else if (UICamera.currentTouch.pressed != null && (UICamera.currentTouch.delta.sqrMagnitude != 0f || UICamera.currentTouch.current != UICamera.currentTouch.last))
  1446. {
  1447. UICamera.currentTouch.totalDelta += UICamera.currentTouch.delta;
  1448. float sqrMagnitude = UICamera.currentTouch.totalDelta.sqrMagnitude;
  1449. bool flag2 = false;
  1450. if (!UICamera.currentTouch.dragStarted && UICamera.currentTouch.last != UICamera.currentTouch.current)
  1451. {
  1452. UICamera.currentTouch.dragStarted = true;
  1453. UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
  1454. UICamera.isDragging = true;
  1455. if (UICamera.onDragStart != null)
  1456. {
  1457. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1458. }
  1459. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
  1460. if (UICamera.onDragOver != null)
  1461. {
  1462. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1463. }
  1464. UICamera.Notify(UICamera.currentTouch.last, "OnDragOver", UICamera.currentTouch.dragged);
  1465. UICamera.isDragging = false;
  1466. }
  1467. else if (!UICamera.currentTouch.dragStarted && num < sqrMagnitude)
  1468. {
  1469. flag2 = true;
  1470. UICamera.currentTouch.dragStarted = true;
  1471. UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
  1472. }
  1473. if (UICamera.currentTouch.dragStarted)
  1474. {
  1475. if (this.mTooltip != null)
  1476. {
  1477. this.ShowTooltip(false);
  1478. }
  1479. UICamera.isDragging = true;
  1480. bool flag3 = UICamera.currentTouch.clickNotification == UICamera.ClickNotification.None;
  1481. if (flag2)
  1482. {
  1483. if (UICamera.onDragStart != null)
  1484. {
  1485. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1486. }
  1487. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
  1488. if (UICamera.onDragOver != null)
  1489. {
  1490. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1491. }
  1492. UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
  1493. }
  1494. else if (UICamera.currentTouch.last != UICamera.currentTouch.current)
  1495. {
  1496. if (UICamera.onDragStart != null)
  1497. {
  1498. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1499. }
  1500. UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
  1501. if (UICamera.onDragOver != null)
  1502. {
  1503. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1504. }
  1505. UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
  1506. }
  1507. if (UICamera.onDrag != null)
  1508. {
  1509. UICamera.onDrag(UICamera.currentTouch.dragged, UICamera.currentTouch.delta);
  1510. }
  1511. UICamera.Notify(UICamera.currentTouch.dragged, "OnDrag", UICamera.currentTouch.delta);
  1512. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1513. UICamera.isDragging = false;
  1514. if (flag3)
  1515. {
  1516. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1517. }
  1518. else if (UICamera.currentTouch.clickNotification == UICamera.ClickNotification.BasedOnDelta && num2 < sqrMagnitude)
  1519. {
  1520. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1521. }
  1522. }
  1523. }
  1524. if (unpressed)
  1525. {
  1526. UICamera.currentTouch.pressStarted = false;
  1527. if (this.mTooltip != null)
  1528. {
  1529. this.ShowTooltip(false);
  1530. }
  1531. if (UICamera.currentTouch.pressed != null)
  1532. {
  1533. if (UICamera.currentTouch.dragStarted)
  1534. {
  1535. if (UICamera.onDragOut != null)
  1536. {
  1537. UICamera.onDragOut(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1538. }
  1539. UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
  1540. if (UICamera.onDragEnd != null)
  1541. {
  1542. UICamera.onDragEnd(UICamera.currentTouch.dragged);
  1543. }
  1544. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragEnd", null);
  1545. }
  1546. if (UICamera.onPress != null)
  1547. {
  1548. UICamera.onPress(UICamera.currentTouch.pressed, false);
  1549. }
  1550. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
  1551. if (flag)
  1552. {
  1553. if (UICamera.onHover != null)
  1554. {
  1555. UICamera.onHover(UICamera.currentTouch.current, true);
  1556. }
  1557. UICamera.Notify(UICamera.currentTouch.current, "OnHover", true);
  1558. }
  1559. UICamera.mHover = UICamera.currentTouch.current;
  1560. if (UICamera.currentTouch.dragged == UICamera.currentTouch.current || (UICamera.currentScheme != UICamera.ControlScheme.Controller && UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.totalDelta.sqrMagnitude < num))
  1561. {
  1562. if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
  1563. {
  1564. UICamera.mNextSelection = null;
  1565. UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
  1566. if (UICamera.onSelect != null)
  1567. {
  1568. UICamera.onSelect(UICamera.currentTouch.pressed, true);
  1569. }
  1570. UICamera.Notify(UICamera.currentTouch.pressed, "OnSelect", true);
  1571. }
  1572. else
  1573. {
  1574. UICamera.mNextSelection = null;
  1575. UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
  1576. }
  1577. if (UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.pressed == UICamera.currentTouch.current)
  1578. {
  1579. float time = RealTime.time;
  1580. if (UICamera.onClick != null)
  1581. {
  1582. UICamera.onClick(UICamera.currentTouch.pressed);
  1583. }
  1584. UICamera.Notify(UICamera.currentTouch.pressed, "OnClick", null);
  1585. if (UICamera.currentTouch.clickTime + 0.35f > time)
  1586. {
  1587. if (UICamera.onDoubleClick != null)
  1588. {
  1589. UICamera.onDoubleClick(UICamera.currentTouch.pressed);
  1590. }
  1591. UICamera.Notify(UICamera.currentTouch.pressed, "OnDoubleClick", null);
  1592. }
  1593. UICamera.currentTouch.clickTime = time;
  1594. }
  1595. }
  1596. else if (UICamera.currentTouch.dragStarted)
  1597. {
  1598. if (UICamera.onDrop != null)
  1599. {
  1600. UICamera.onDrop(UICamera.currentTouch.current, UICamera.currentTouch.dragged);
  1601. }
  1602. UICamera.Notify(UICamera.currentTouch.current, "OnDrop", UICamera.currentTouch.dragged);
  1603. }
  1604. }
  1605. UICamera.currentTouch.dragStarted = false;
  1606. UICamera.currentTouch.pressed = null;
  1607. UICamera.currentTouch.dragged = null;
  1608. }
  1609. }
  1610. public void ShowTooltip(bool val)
  1611. {
  1612. this.mTooltipTime = 0f;
  1613. if (UICamera.onTooltip != null)
  1614. {
  1615. UICamera.onTooltip(this.mTooltip, val);
  1616. }
  1617. UICamera.Notify(this.mTooltip, "OnTooltip", val);
  1618. if (!val)
  1619. {
  1620. this.mTooltip = null;
  1621. }
  1622. }
  1623. private void OnApplicationPause()
  1624. {
  1625. UICamera.MouseOrTouch mouseOrTouch = UICamera.currentTouch;
  1626. if (this.useTouch)
  1627. {
  1628. BetterList<int> betterList = new BetterList<int>();
  1629. foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
  1630. {
  1631. if (keyValuePair.Value != null && keyValuePair.Value.pressed)
  1632. {
  1633. UICamera.currentTouch = keyValuePair.Value;
  1634. UICamera.currentTouchID = keyValuePair.Key;
  1635. UICamera.currentScheme = UICamera.ControlScheme.Touch;
  1636. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1637. this.ProcessTouch(false, true);
  1638. betterList.Add(UICamera.currentTouchID);
  1639. }
  1640. }
  1641. for (int i = 0; i < betterList.size; i++)
  1642. {
  1643. UICamera.RemoveTouch(betterList[i]);
  1644. }
  1645. }
  1646. if (this.useMouse)
  1647. {
  1648. for (int j = 0; j < 3; j++)
  1649. {
  1650. if (UICamera.mMouse[j].pressed)
  1651. {
  1652. UICamera.currentTouch = UICamera.mMouse[j];
  1653. UICamera.currentTouchID = -1 - j;
  1654. UICamera.currentKey = KeyCode.Mouse0 + j;
  1655. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1656. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1657. this.ProcessTouch(false, true);
  1658. }
  1659. }
  1660. }
  1661. if (this.useController && UICamera.controller.pressed)
  1662. {
  1663. UICamera.currentTouch = UICamera.controller;
  1664. UICamera.currentTouchID = -100;
  1665. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1666. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1667. UICamera.currentTouch.current = UICamera.mCurrentSelection;
  1668. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1669. this.ProcessTouch(false, true);
  1670. UICamera.currentTouch.last = null;
  1671. }
  1672. UICamera.currentTouch = mouseOrTouch;
  1673. }
  1674. // Note: this type is marked as 'beforefieldinit'.
  1675. static UICamera()
  1676. {
  1677. if (UICamera.<>f__mg$cache1 == null)
  1678. {
  1679. UICamera.<>f__mg$cache1 = new UICamera.GetKeyStateFunc(Input.GetKeyDown);
  1680. }
  1681. UICamera.GetKeyDown = UICamera.<>f__mg$cache1;
  1682. if (UICamera.<>f__mg$cache2 == null)
  1683. {
  1684. UICamera.<>f__mg$cache2 = new UICamera.GetKeyStateFunc(Input.GetKeyUp);
  1685. }
  1686. UICamera.GetKeyUp = UICamera.<>f__mg$cache2;
  1687. if (UICamera.<>f__mg$cache3 == null)
  1688. {
  1689. UICamera.<>f__mg$cache3 = new UICamera.GetKeyStateFunc(Input.GetKey);
  1690. }
  1691. UICamera.GetKey = UICamera.<>f__mg$cache3;
  1692. if (UICamera.<>f__mg$cache4 == null)
  1693. {
  1694. UICamera.<>f__mg$cache4 = new UICamera.GetAxisFunc(NInput.GetAxis);
  1695. }
  1696. UICamera.GetAxis = UICamera.<>f__mg$cache4;
  1697. UICamera.showTooltips = true;
  1698. UICamera.lastTouchPosition = Vector2.zero;
  1699. UICamera.lastWorldPosition = Vector3.zero;
  1700. UICamera.current = null;
  1701. UICamera.currentCamera = null;
  1702. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1703. UICamera.currentTouchID = -100;
  1704. UICamera.currentKey = KeyCode.None;
  1705. UICamera.currentTouch = null;
  1706. UICamera.inputHasFocus = false;
  1707. UICamera.mCurrentSelection = null;
  1708. UICamera.mNextSelection = null;
  1709. UICamera.mNextScheme = UICamera.ControlScheme.Controller;
  1710. UICamera.mMouse = new UICamera.MouseOrTouch[]
  1711. {
  1712. new UICamera.MouseOrTouch(),
  1713. new UICamera.MouseOrTouch(),
  1714. new UICamera.MouseOrTouch()
  1715. };
  1716. UICamera.controller = new UICamera.MouseOrTouch();
  1717. UICamera.mNextEvent = 0f;
  1718. UICamera.mTouches = new Dictionary<int, UICamera.MouseOrTouch>();
  1719. UICamera.mWidth = 0;
  1720. UICamera.mHeight = 0;
  1721. UICamera.isDragging = false;
  1722. UICamera.isFallThrough = false;
  1723. UICamera.isDisableRightClick = false;
  1724. UICamera.mHit = default(UICamera.DepthEntry);
  1725. UICamera.mHits = new BetterList<UICamera.DepthEntry>();
  1726. UICamera.m2DPlane = new Plane(Vector3.back, 0f);
  1727. UICamera.mNotifying = false;
  1728. UICamera.m_unInputEnableFlag = 0U;
  1729. UICamera.InputEnable = true;
  1730. UICamera.mUsingTouchEvents = true;
  1731. }
  1732. public static BetterList<UICamera> list = new BetterList<UICamera>();
  1733. public static UICamera.GetKeyStateFunc GetKeyDown;
  1734. public static UICamera.GetKeyStateFunc GetKeyUp;
  1735. public static UICamera.GetKeyStateFunc GetKey;
  1736. public static UICamera.GetAxisFunc GetAxis;
  1737. public static UICamera.OnScreenResize onScreenResize;
  1738. public UICamera.EventType eventType = UICamera.EventType.UI_3D;
  1739. public bool eventsGoToColliders;
  1740. public LayerMask eventReceiverMask = -1;
  1741. public bool debug;
  1742. public bool useMouse = true;
  1743. public bool useTouch = true;
  1744. public bool allowMultiTouch = true;
  1745. public bool useKeyboard = true;
  1746. public bool useController = true;
  1747. public bool stickyTooltip = true;
  1748. public float tooltipDelay = 1f;
  1749. public float mouseDragThreshold = 4f;
  1750. public float mouseClickThreshold = 10f;
  1751. public float touchDragThreshold = 40f;
  1752. public float touchClickThreshold = 40f;
  1753. public float rangeDistance = -1f;
  1754. public string scrollAxisName = "Mouse ScrollWheel";
  1755. public string verticalAxisName = "Vertical";
  1756. public string horizontalAxisName = "Horizontal";
  1757. public KeyCode submitKey0 = KeyCode.Return;
  1758. public KeyCode submitKey1 = KeyCode.JoystickButton0;
  1759. public KeyCode cancelKey0 = KeyCode.Escape;
  1760. public KeyCode cancelKey1 = KeyCode.JoystickButton1;
  1761. public static UICamera.OnCustomInput onCustomInput;
  1762. public static bool showTooltips;
  1763. public static Vector2 lastTouchPosition;
  1764. public static Vector3 lastWorldPosition;
  1765. public static RaycastHit lastHit;
  1766. public static UICamera current;
  1767. public static Camera currentCamera;
  1768. public static UICamera.ControlScheme currentScheme;
  1769. public static int currentTouchID;
  1770. public static KeyCode currentKey;
  1771. public static UICamera.MouseOrTouch currentTouch;
  1772. public static bool inputHasFocus;
  1773. private static GameObject mGenericHandler;
  1774. public static GameObject fallThrough;
  1775. public static UICamera.VoidDelegate onClick;
  1776. public static UICamera.VoidDelegate onDoubleClick;
  1777. public static UICamera.BoolDelegate onHover;
  1778. public static UICamera.BoolDelegate onPress;
  1779. public static UICamera.BoolDelegate onSelect;
  1780. public static UICamera.FloatDelegate onScroll;
  1781. public static UICamera.VectorDelegate onDrag;
  1782. public static UICamera.VoidDelegate onDragStart;
  1783. public static UICamera.ObjectDelegate onDragOver;
  1784. public static UICamera.ObjectDelegate onDragOut;
  1785. public static UICamera.VoidDelegate onDragEnd;
  1786. public static UICamera.ObjectDelegate onDrop;
  1787. public static UICamera.KeyCodeDelegate onKey;
  1788. public static UICamera.BoolDelegate onTooltip;
  1789. public static UICamera.MoveDelegate onMouseMove;
  1790. private static GameObject mCurrentSelection;
  1791. private static GameObject mNextSelection;
  1792. private static UICamera.ControlScheme mNextScheme;
  1793. private static UICamera.MouseOrTouch[] mMouse;
  1794. private static GameObject mHover;
  1795. public static UICamera.MouseOrTouch controller;
  1796. private static float mNextEvent;
  1797. private static Dictionary<int, UICamera.MouseOrTouch> mTouches;
  1798. private static int mWidth;
  1799. private static int mHeight;
  1800. private GameObject mTooltip;
  1801. private Camera mCam;
  1802. private float mTooltipTime;
  1803. private float mNextRaycast;
  1804. public static bool isDragging;
  1805. public static GameObject hoveredObject;
  1806. public static bool isFallThrough;
  1807. public static bool isDisableRightClick;
  1808. private bool m_bHover;
  1809. private bool m_bProcessEnable = true;
  1810. public bool VRExclusionUI;
  1811. private Vector3[] m_vVirtualMousePos = new Vector3[2];
  1812. private GameObject[] m_goVirtualCursor = new GameObject[2];
  1813. private UI2DSprite[] m_spriteVirtualCursor = new UI2DSprite[2];
  1814. private bool[] m_bVirtualDummyActive = new bool[2];
  1815. private UICamera.VCURSOR m_eCurrentCursorSide = UICamera.VCURSOR.RIGHT;
  1816. private static UICamera.DepthEntry mHit;
  1817. private static BetterList<UICamera.DepthEntry> mHits;
  1818. private static Plane m2DPlane;
  1819. private static bool mNotifying;
  1820. private static uint m_unInputEnableFlag;
  1821. public static bool InputEnable;
  1822. private const float VIRTUAL_SCREEN_SIZE_W = 1920f;
  1823. private const float VIRTUAL_SCREEN_SIZE_H = 1080f;
  1824. private static bool mUsingTouchEvents;
  1825. [CompilerGenerated]
  1826. private static BetterList<UICamera>.CompareFunc <>f__mg$cache0;
  1827. [CompilerGenerated]
  1828. private static UICamera.GetKeyStateFunc <>f__mg$cache1;
  1829. [CompilerGenerated]
  1830. private static UICamera.GetKeyStateFunc <>f__mg$cache2;
  1831. [CompilerGenerated]
  1832. private static UICamera.GetKeyStateFunc <>f__mg$cache3;
  1833. [CompilerGenerated]
  1834. private static UICamera.GetAxisFunc <>f__mg$cache4;
  1835. public enum ControlScheme
  1836. {
  1837. Mouse,
  1838. Touch,
  1839. Controller
  1840. }
  1841. public enum ClickNotification
  1842. {
  1843. None,
  1844. Always,
  1845. BasedOnDelta
  1846. }
  1847. public class MouseOrTouch
  1848. {
  1849. public float deltaTime
  1850. {
  1851. get
  1852. {
  1853. return (!this.touchBegan) ? 0f : (RealTime.time - this.pressTime);
  1854. }
  1855. }
  1856. public bool isOverUI
  1857. {
  1858. get
  1859. {
  1860. return this.current != null && this.current != UICamera.fallThrough && NGUITools.FindInParents<UIRoot>(this.current) != null;
  1861. }
  1862. }
  1863. public Vector2 pos;
  1864. public Vector2 lastPos;
  1865. public Vector2 delta;
  1866. public Vector2 totalDelta;
  1867. public Camera pressedCam;
  1868. public GameObject last;
  1869. public GameObject current;
  1870. public GameObject pressed;
  1871. public GameObject dragged;
  1872. public float pressTime;
  1873. public float clickTime;
  1874. public UICamera.ClickNotification clickNotification = UICamera.ClickNotification.Always;
  1875. public bool touchBegan = true;
  1876. public bool pressStarted;
  1877. public bool dragStarted;
  1878. }
  1879. public enum EventType
  1880. {
  1881. World_3D,
  1882. UI_3D,
  1883. World_2D,
  1884. UI_2D
  1885. }
  1886. public delegate bool GetKeyStateFunc(KeyCode key);
  1887. public delegate float GetAxisFunc(string name);
  1888. public delegate void OnScreenResize();
  1889. public delegate void OnCustomInput();
  1890. public delegate void MoveDelegate(Vector2 delta);
  1891. public delegate void VoidDelegate(GameObject go);
  1892. public delegate void BoolDelegate(GameObject go, bool state);
  1893. public delegate void FloatDelegate(GameObject go, float delta);
  1894. public delegate void VectorDelegate(GameObject go, Vector2 delta);
  1895. public delegate void ObjectDelegate(GameObject go, GameObject obj);
  1896. public delegate void KeyCodeDelegate(GameObject go, KeyCode key);
  1897. public enum VCURSOR
  1898. {
  1899. LEFT,
  1900. RIGHT,
  1901. MAX
  1902. }
  1903. private struct DepthEntry
  1904. {
  1905. public int depth;
  1906. public RaycastHit hit;
  1907. public Vector3 point;
  1908. public GameObject go;
  1909. }
  1910. public enum INPUT_CTRL_TYPE
  1911. {
  1912. FADE = 1,
  1913. EDIT,
  1914. SAVE_LOAD = 4,
  1915. SCHEDULE = 8
  1916. }
  1917. }