UICamera.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121
  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 (this.useController)
  1354. {
  1355. if (!string.IsNullOrEmpty(this.verticalAxisName))
  1356. {
  1357. num += UICamera.GetDirection(this.verticalAxisName);
  1358. }
  1359. if (!string.IsNullOrEmpty(this.horizontalAxisName))
  1360. {
  1361. num2 += UICamera.GetDirection(this.horizontalAxisName);
  1362. }
  1363. }
  1364. if (num != 0)
  1365. {
  1366. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1367. KeyCode keyCode = (num <= 0) ? KeyCode.DownArrow : KeyCode.UpArrow;
  1368. if (UICamera.onKey != null)
  1369. {
  1370. UICamera.onKey(UICamera.mCurrentSelection, keyCode);
  1371. }
  1372. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode);
  1373. }
  1374. if (num2 != 0)
  1375. {
  1376. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1377. KeyCode keyCode2 = (num2 <= 0) ? KeyCode.LeftArrow : KeyCode.RightArrow;
  1378. if (UICamera.onKey != null)
  1379. {
  1380. UICamera.onKey(UICamera.mCurrentSelection, keyCode2);
  1381. }
  1382. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode2);
  1383. }
  1384. if (this.useKeyboard && UICamera.GetKeyDown(KeyCode.Tab))
  1385. {
  1386. UICamera.currentKey = KeyCode.Tab;
  1387. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1388. if (UICamera.onKey != null)
  1389. {
  1390. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Tab);
  1391. }
  1392. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Tab);
  1393. }
  1394. if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0))
  1395. {
  1396. UICamera.currentKey = this.cancelKey0;
  1397. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1398. if (UICamera.onKey != null)
  1399. {
  1400. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
  1401. }
  1402. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
  1403. }
  1404. if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1))
  1405. {
  1406. UICamera.currentKey = this.cancelKey1;
  1407. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1408. if (UICamera.onKey != null)
  1409. {
  1410. UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
  1411. }
  1412. UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
  1413. }
  1414. UICamera.currentTouch = null;
  1415. UICamera.currentKey = KeyCode.None;
  1416. }
  1417. public void ProcessTouch(bool pressed, bool unpressed)
  1418. {
  1419. bool flag = UICamera.currentScheme == UICamera.ControlScheme.Mouse;
  1420. float num = (!flag) ? this.touchDragThreshold : this.mouseDragThreshold;
  1421. float num2 = (!flag) ? this.touchClickThreshold : this.mouseClickThreshold;
  1422. num *= num;
  1423. num2 *= num2;
  1424. if (pressed)
  1425. {
  1426. if (this.mTooltip != null)
  1427. {
  1428. this.ShowTooltip(false);
  1429. }
  1430. UICamera.currentTouch.pressStarted = true;
  1431. if (UICamera.onPress != null && UICamera.currentTouch.pressed)
  1432. {
  1433. UICamera.onPress(UICamera.currentTouch.pressed, false);
  1434. }
  1435. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
  1436. UICamera.currentTouch.pressed = UICamera.currentTouch.current;
  1437. UICamera.currentTouch.dragged = UICamera.currentTouch.current;
  1438. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.BasedOnDelta;
  1439. UICamera.currentTouch.totalDelta = Vector2.zero;
  1440. UICamera.currentTouch.dragStarted = false;
  1441. if (UICamera.onPress != null && UICamera.currentTouch.pressed)
  1442. {
  1443. UICamera.onPress(UICamera.currentTouch.pressed, true);
  1444. }
  1445. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", true);
  1446. if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
  1447. {
  1448. if (this.mTooltip != null)
  1449. {
  1450. this.ShowTooltip(false);
  1451. }
  1452. UICamera.currentScheme = UICamera.ControlScheme.Touch;
  1453. UICamera.selectedObject = UICamera.currentTouch.pressed;
  1454. }
  1455. }
  1456. else if (UICamera.currentTouch.pressed != null && (UICamera.currentTouch.delta.sqrMagnitude != 0f || UICamera.currentTouch.current != UICamera.currentTouch.last))
  1457. {
  1458. UICamera.currentTouch.totalDelta += UICamera.currentTouch.delta;
  1459. float sqrMagnitude = UICamera.currentTouch.totalDelta.sqrMagnitude;
  1460. bool flag2 = false;
  1461. if (!UICamera.currentTouch.dragStarted && UICamera.currentTouch.last != UICamera.currentTouch.current)
  1462. {
  1463. UICamera.currentTouch.dragStarted = true;
  1464. UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
  1465. UICamera.isDragging = true;
  1466. if (UICamera.onDragStart != null)
  1467. {
  1468. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1469. }
  1470. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
  1471. if (UICamera.onDragOver != null)
  1472. {
  1473. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1474. }
  1475. UICamera.Notify(UICamera.currentTouch.last, "OnDragOver", UICamera.currentTouch.dragged);
  1476. UICamera.isDragging = false;
  1477. }
  1478. else if (!UICamera.currentTouch.dragStarted && num < sqrMagnitude)
  1479. {
  1480. flag2 = true;
  1481. UICamera.currentTouch.dragStarted = true;
  1482. UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
  1483. }
  1484. if (UICamera.currentTouch.dragStarted)
  1485. {
  1486. if (this.mTooltip != null)
  1487. {
  1488. this.ShowTooltip(false);
  1489. }
  1490. UICamera.isDragging = true;
  1491. bool flag3 = UICamera.currentTouch.clickNotification == UICamera.ClickNotification.None;
  1492. if (flag2)
  1493. {
  1494. if (UICamera.onDragStart != null)
  1495. {
  1496. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1497. }
  1498. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
  1499. if (UICamera.onDragOver != null)
  1500. {
  1501. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1502. }
  1503. UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
  1504. }
  1505. else if (UICamera.currentTouch.last != UICamera.currentTouch.current)
  1506. {
  1507. if (UICamera.onDragStart != null)
  1508. {
  1509. UICamera.onDragStart(UICamera.currentTouch.dragged);
  1510. }
  1511. UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
  1512. if (UICamera.onDragOver != null)
  1513. {
  1514. UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1515. }
  1516. UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
  1517. }
  1518. if (UICamera.onDrag != null)
  1519. {
  1520. UICamera.onDrag(UICamera.currentTouch.dragged, UICamera.currentTouch.delta);
  1521. }
  1522. UICamera.Notify(UICamera.currentTouch.dragged, "OnDrag", UICamera.currentTouch.delta);
  1523. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1524. UICamera.isDragging = false;
  1525. if (flag3)
  1526. {
  1527. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1528. }
  1529. else if (UICamera.currentTouch.clickNotification == UICamera.ClickNotification.BasedOnDelta && num2 < sqrMagnitude)
  1530. {
  1531. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1532. }
  1533. }
  1534. }
  1535. if (unpressed)
  1536. {
  1537. UICamera.currentTouch.pressStarted = false;
  1538. if (this.mTooltip != null)
  1539. {
  1540. this.ShowTooltip(false);
  1541. }
  1542. if (UICamera.currentTouch.pressed != null)
  1543. {
  1544. if (UICamera.currentTouch.dragStarted)
  1545. {
  1546. if (UICamera.onDragOut != null)
  1547. {
  1548. UICamera.onDragOut(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
  1549. }
  1550. UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
  1551. if (UICamera.onDragEnd != null)
  1552. {
  1553. UICamera.onDragEnd(UICamera.currentTouch.dragged);
  1554. }
  1555. UICamera.Notify(UICamera.currentTouch.dragged, "OnDragEnd", null);
  1556. }
  1557. if (UICamera.onPress != null)
  1558. {
  1559. UICamera.onPress(UICamera.currentTouch.pressed, false);
  1560. }
  1561. UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
  1562. if (flag)
  1563. {
  1564. if (UICamera.onHover != null)
  1565. {
  1566. UICamera.onHover(UICamera.currentTouch.current, true);
  1567. }
  1568. UICamera.Notify(UICamera.currentTouch.current, "OnHover", true);
  1569. }
  1570. UICamera.mHover = UICamera.currentTouch.current;
  1571. if (UICamera.currentTouch.dragged == UICamera.currentTouch.current || (UICamera.currentScheme != UICamera.ControlScheme.Controller && UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.totalDelta.sqrMagnitude < num))
  1572. {
  1573. if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
  1574. {
  1575. UICamera.mNextSelection = null;
  1576. UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
  1577. if (UICamera.onSelect != null)
  1578. {
  1579. UICamera.onSelect(UICamera.currentTouch.pressed, true);
  1580. }
  1581. UICamera.Notify(UICamera.currentTouch.pressed, "OnSelect", true);
  1582. }
  1583. else
  1584. {
  1585. UICamera.mNextSelection = null;
  1586. UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
  1587. }
  1588. if (UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.pressed == UICamera.currentTouch.current)
  1589. {
  1590. float time = RealTime.time;
  1591. if (UICamera.onClick != null)
  1592. {
  1593. UICamera.onClick(UICamera.currentTouch.pressed);
  1594. }
  1595. UICamera.Notify(UICamera.currentTouch.pressed, "OnClick", null);
  1596. if (UICamera.currentTouch.clickTime + 0.35f > time)
  1597. {
  1598. if (UICamera.onDoubleClick != null)
  1599. {
  1600. UICamera.onDoubleClick(UICamera.currentTouch.pressed);
  1601. }
  1602. UICamera.Notify(UICamera.currentTouch.pressed, "OnDoubleClick", null);
  1603. }
  1604. UICamera.currentTouch.clickTime = time;
  1605. }
  1606. }
  1607. else if (UICamera.currentTouch.dragStarted)
  1608. {
  1609. if (UICamera.onDrop != null)
  1610. {
  1611. UICamera.onDrop(UICamera.currentTouch.current, UICamera.currentTouch.dragged);
  1612. }
  1613. UICamera.Notify(UICamera.currentTouch.current, "OnDrop", UICamera.currentTouch.dragged);
  1614. }
  1615. }
  1616. UICamera.currentTouch.dragStarted = false;
  1617. UICamera.currentTouch.pressed = null;
  1618. UICamera.currentTouch.dragged = null;
  1619. }
  1620. }
  1621. public void ShowTooltip(bool val)
  1622. {
  1623. this.mTooltipTime = 0f;
  1624. if (UICamera.onTooltip != null)
  1625. {
  1626. UICamera.onTooltip(this.mTooltip, val);
  1627. }
  1628. UICamera.Notify(this.mTooltip, "OnTooltip", val);
  1629. if (!val)
  1630. {
  1631. this.mTooltip = null;
  1632. }
  1633. }
  1634. private void OnApplicationPause()
  1635. {
  1636. UICamera.MouseOrTouch mouseOrTouch = UICamera.currentTouch;
  1637. if (this.useTouch)
  1638. {
  1639. BetterList<int> betterList = new BetterList<int>();
  1640. foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
  1641. {
  1642. if (keyValuePair.Value != null && keyValuePair.Value.pressed)
  1643. {
  1644. UICamera.currentTouch = keyValuePair.Value;
  1645. UICamera.currentTouchID = keyValuePair.Key;
  1646. UICamera.currentScheme = UICamera.ControlScheme.Touch;
  1647. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1648. this.ProcessTouch(false, true);
  1649. betterList.Add(UICamera.currentTouchID);
  1650. }
  1651. }
  1652. for (int i = 0; i < betterList.size; i++)
  1653. {
  1654. UICamera.RemoveTouch(betterList[i]);
  1655. }
  1656. }
  1657. if (this.useMouse)
  1658. {
  1659. for (int j = 0; j < 3; j++)
  1660. {
  1661. if (UICamera.mMouse[j].pressed)
  1662. {
  1663. UICamera.currentTouch = UICamera.mMouse[j];
  1664. UICamera.currentTouchID = -1 - j;
  1665. UICamera.currentKey = KeyCode.Mouse0 + j;
  1666. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1667. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1668. this.ProcessTouch(false, true);
  1669. }
  1670. }
  1671. }
  1672. if (this.useController && UICamera.controller.pressed)
  1673. {
  1674. UICamera.currentTouch = UICamera.controller;
  1675. UICamera.currentTouchID = -100;
  1676. UICamera.currentScheme = UICamera.ControlScheme.Controller;
  1677. UICamera.currentTouch.last = UICamera.currentTouch.current;
  1678. UICamera.currentTouch.current = UICamera.mCurrentSelection;
  1679. UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
  1680. this.ProcessTouch(false, true);
  1681. UICamera.currentTouch.last = null;
  1682. }
  1683. UICamera.currentTouch = mouseOrTouch;
  1684. }
  1685. // Note: this type is marked as 'beforefieldinit'.
  1686. static UICamera()
  1687. {
  1688. if (UICamera.<>f__mg$cache1 == null)
  1689. {
  1690. UICamera.<>f__mg$cache1 = new UICamera.GetKeyStateFunc(Input.GetKeyDown);
  1691. }
  1692. UICamera.GetKeyDown = UICamera.<>f__mg$cache1;
  1693. if (UICamera.<>f__mg$cache2 == null)
  1694. {
  1695. UICamera.<>f__mg$cache2 = new UICamera.GetKeyStateFunc(Input.GetKeyUp);
  1696. }
  1697. UICamera.GetKeyUp = UICamera.<>f__mg$cache2;
  1698. if (UICamera.<>f__mg$cache3 == null)
  1699. {
  1700. UICamera.<>f__mg$cache3 = new UICamera.GetKeyStateFunc(Input.GetKey);
  1701. }
  1702. UICamera.GetKey = UICamera.<>f__mg$cache3;
  1703. if (UICamera.<>f__mg$cache4 == null)
  1704. {
  1705. UICamera.<>f__mg$cache4 = new UICamera.GetAxisFunc(NInput.GetAxis);
  1706. }
  1707. UICamera.GetAxis = UICamera.<>f__mg$cache4;
  1708. UICamera.showTooltips = true;
  1709. UICamera.lastTouchPosition = Vector2.zero;
  1710. UICamera.lastWorldPosition = Vector3.zero;
  1711. UICamera.current = null;
  1712. UICamera.currentCamera = null;
  1713. UICamera.currentScheme = UICamera.ControlScheme.Mouse;
  1714. UICamera.currentTouchID = -100;
  1715. UICamera.currentKey = KeyCode.None;
  1716. UICamera.currentTouch = null;
  1717. UICamera.inputHasFocus = false;
  1718. UICamera.mCurrentSelection = null;
  1719. UICamera.mNextSelection = null;
  1720. UICamera.mNextScheme = UICamera.ControlScheme.Controller;
  1721. UICamera.mMouse = new UICamera.MouseOrTouch[]
  1722. {
  1723. new UICamera.MouseOrTouch(),
  1724. new UICamera.MouseOrTouch(),
  1725. new UICamera.MouseOrTouch()
  1726. };
  1727. UICamera.controller = new UICamera.MouseOrTouch();
  1728. UICamera.mNextEvent = 0f;
  1729. UICamera.mTouches = new Dictionary<int, UICamera.MouseOrTouch>();
  1730. UICamera.mWidth = 0;
  1731. UICamera.mHeight = 0;
  1732. UICamera.isDragging = false;
  1733. UICamera.isFallThrough = false;
  1734. UICamera.isDisableRightClick = false;
  1735. UICamera.mHit = default(UICamera.DepthEntry);
  1736. UICamera.mHits = new BetterList<UICamera.DepthEntry>();
  1737. UICamera.m2DPlane = new Plane(Vector3.back, 0f);
  1738. UICamera.mNotifying = false;
  1739. UICamera.m_unInputEnableFlag = 0u;
  1740. UICamera.InputEnable = true;
  1741. UICamera.mUsingTouchEvents = true;
  1742. }
  1743. public static BetterList<UICamera> list = new BetterList<UICamera>();
  1744. public static UICamera.GetKeyStateFunc GetKeyDown;
  1745. public static UICamera.GetKeyStateFunc GetKeyUp;
  1746. public static UICamera.GetKeyStateFunc GetKey;
  1747. public static UICamera.GetAxisFunc GetAxis;
  1748. public static UICamera.OnScreenResize onScreenResize;
  1749. public UICamera.EventType eventType = UICamera.EventType.UI_3D;
  1750. public bool eventsGoToColliders;
  1751. public LayerMask eventReceiverMask = -1;
  1752. public bool debug;
  1753. public bool useMouse = true;
  1754. public bool useTouch = true;
  1755. public bool allowMultiTouch = true;
  1756. public bool useKeyboard = true;
  1757. public bool useController = true;
  1758. public bool stickyTooltip = true;
  1759. public float tooltipDelay = 1f;
  1760. public float mouseDragThreshold = 4f;
  1761. public float mouseClickThreshold = 10f;
  1762. public float touchDragThreshold = 40f;
  1763. public float touchClickThreshold = 40f;
  1764. public float rangeDistance = -1f;
  1765. public string scrollAxisName = "Mouse ScrollWheel";
  1766. public string verticalAxisName = "Vertical";
  1767. public string horizontalAxisName = "Horizontal";
  1768. public KeyCode submitKey0 = KeyCode.Return;
  1769. public KeyCode submitKey1 = KeyCode.JoystickButton0;
  1770. public KeyCode cancelKey0 = KeyCode.Escape;
  1771. public KeyCode cancelKey1 = KeyCode.JoystickButton1;
  1772. public static UICamera.OnCustomInput onCustomInput;
  1773. public static bool showTooltips;
  1774. public static Vector2 lastTouchPosition;
  1775. public static Vector3 lastWorldPosition;
  1776. public static RaycastHit lastHit;
  1777. public static UICamera current;
  1778. public static Camera currentCamera;
  1779. public static UICamera.ControlScheme currentScheme;
  1780. public static int currentTouchID;
  1781. public static KeyCode currentKey;
  1782. public static UICamera.MouseOrTouch currentTouch;
  1783. public static bool inputHasFocus;
  1784. private static GameObject mGenericHandler;
  1785. public static GameObject fallThrough;
  1786. public static UICamera.VoidDelegate onClick;
  1787. public static UICamera.VoidDelegate onDoubleClick;
  1788. public static UICamera.BoolDelegate onHover;
  1789. public static UICamera.BoolDelegate onPress;
  1790. public static UICamera.BoolDelegate onSelect;
  1791. public static UICamera.FloatDelegate onScroll;
  1792. public static UICamera.VectorDelegate onDrag;
  1793. public static UICamera.VoidDelegate onDragStart;
  1794. public static UICamera.ObjectDelegate onDragOver;
  1795. public static UICamera.ObjectDelegate onDragOut;
  1796. public static UICamera.VoidDelegate onDragEnd;
  1797. public static UICamera.ObjectDelegate onDrop;
  1798. public static UICamera.KeyCodeDelegate onKey;
  1799. public static UICamera.BoolDelegate onTooltip;
  1800. public static UICamera.MoveDelegate onMouseMove;
  1801. private static GameObject mCurrentSelection;
  1802. private static GameObject mNextSelection;
  1803. private static UICamera.ControlScheme mNextScheme;
  1804. private static UICamera.MouseOrTouch[] mMouse;
  1805. private static GameObject mHover;
  1806. public static UICamera.MouseOrTouch controller;
  1807. private static float mNextEvent;
  1808. private static Dictionary<int, UICamera.MouseOrTouch> mTouches;
  1809. private static int mWidth;
  1810. private static int mHeight;
  1811. private GameObject mTooltip;
  1812. private Camera mCam;
  1813. private float mTooltipTime;
  1814. private float mNextRaycast;
  1815. public static bool isDragging;
  1816. public static GameObject hoveredObject;
  1817. public static bool isFallThrough;
  1818. public static bool isDisableRightClick;
  1819. private bool m_bHover;
  1820. private bool m_bProcessEnable = true;
  1821. public bool VRExclusionUI;
  1822. private Vector3[] m_vVirtualMousePos = new Vector3[2];
  1823. private GameObject[] m_goVirtualCursor = new GameObject[2];
  1824. private UI2DSprite[] m_spriteVirtualCursor = new UI2DSprite[2];
  1825. private bool[] m_bVirtualDummyActive = new bool[2];
  1826. private UICamera.VCURSOR m_eCurrentCursorSide = UICamera.VCURSOR.RIGHT;
  1827. private static UICamera.DepthEntry mHit;
  1828. private static BetterList<UICamera.DepthEntry> mHits;
  1829. private static Plane m2DPlane;
  1830. private static bool mNotifying;
  1831. private static uint m_unInputEnableFlag;
  1832. public static bool InputEnable;
  1833. private const float VIRTUAL_SCREEN_SIZE_W = 1920f;
  1834. private const float VIRTUAL_SCREEN_SIZE_H = 1080f;
  1835. private static bool mUsingTouchEvents;
  1836. [CompilerGenerated]
  1837. private static BetterList<UICamera>.CompareFunc <>f__mg$cache0;
  1838. [CompilerGenerated]
  1839. private static UICamera.GetKeyStateFunc <>f__mg$cache1;
  1840. [CompilerGenerated]
  1841. private static UICamera.GetKeyStateFunc <>f__mg$cache2;
  1842. [CompilerGenerated]
  1843. private static UICamera.GetKeyStateFunc <>f__mg$cache3;
  1844. [CompilerGenerated]
  1845. private static UICamera.GetAxisFunc <>f__mg$cache4;
  1846. public enum ControlScheme
  1847. {
  1848. Mouse,
  1849. Touch,
  1850. Controller
  1851. }
  1852. public enum ClickNotification
  1853. {
  1854. None,
  1855. Always,
  1856. BasedOnDelta
  1857. }
  1858. public class MouseOrTouch
  1859. {
  1860. public float deltaTime
  1861. {
  1862. get
  1863. {
  1864. return (!this.touchBegan) ? 0f : (RealTime.time - this.pressTime);
  1865. }
  1866. }
  1867. public bool isOverUI
  1868. {
  1869. get
  1870. {
  1871. return this.current != null && this.current != UICamera.fallThrough && NGUITools.FindInParents<UIRoot>(this.current) != null;
  1872. }
  1873. }
  1874. public Vector2 pos;
  1875. public Vector2 lastPos;
  1876. public Vector2 delta;
  1877. public Vector2 totalDelta;
  1878. public Camera pressedCam;
  1879. public GameObject last;
  1880. public GameObject current;
  1881. public GameObject pressed;
  1882. public GameObject dragged;
  1883. public float pressTime;
  1884. public float clickTime;
  1885. public UICamera.ClickNotification clickNotification = UICamera.ClickNotification.Always;
  1886. public bool touchBegan = true;
  1887. public bool pressStarted;
  1888. public bool dragStarted;
  1889. }
  1890. public enum EventType
  1891. {
  1892. World_3D,
  1893. UI_3D,
  1894. World_2D,
  1895. UI_2D
  1896. }
  1897. public delegate bool GetKeyStateFunc(KeyCode key);
  1898. public delegate float GetAxisFunc(string name);
  1899. public delegate void OnScreenResize();
  1900. public delegate void OnCustomInput();
  1901. public delegate void MoveDelegate(Vector2 delta);
  1902. public delegate void VoidDelegate(GameObject go);
  1903. public delegate void BoolDelegate(GameObject go, bool state);
  1904. public delegate void FloatDelegate(GameObject go, float delta);
  1905. public delegate void VectorDelegate(GameObject go, Vector2 delta);
  1906. public delegate void ObjectDelegate(GameObject go, GameObject obj);
  1907. public delegate void KeyCodeDelegate(GameObject go, KeyCode key);
  1908. public enum VCURSOR
  1909. {
  1910. LEFT,
  1911. RIGHT,
  1912. MAX
  1913. }
  1914. private struct DepthEntry
  1915. {
  1916. public int depth;
  1917. public RaycastHit hit;
  1918. public Vector3 point;
  1919. public GameObject go;
  1920. }
  1921. public enum INPUT_CTRL_TYPE
  1922. {
  1923. FADE = 1,
  1924. EDIT,
  1925. SAVE_LOAD = 4,
  1926. SCHEDULE = 8
  1927. }
  1928. }