UICamera.cs 55 KB

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