1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- [ExecuteInEditMode]
- [AddComponentMenu("NGUI/UI/NGUI Event System (UICamera)")]
- [RequireComponent(typeof(Camera))]
- public class UICamera : MonoBehaviour
- {
- [Obsolete("Use new OnDragStart / OnDragOver / OnDragOut / OnDragEnd events instead")]
- public bool stickyPress
- {
- get
- {
- return true;
- }
- }
- public static Ray currentRay
- {
- get
- {
- return (!(UICamera.currentCamera != null) || UICamera.currentTouch == null) ? default(Ray) : UICamera.currentCamera.ScreenPointToRay(UICamera.currentTouch.pos);
- }
- }
- [Obsolete("Use delegates instead such as UICamera.onClick, UICamera.onHover, etc.")]
- public static GameObject genericEventHandler
- {
- get
- {
- return UICamera.mGenericHandler;
- }
- set
- {
- UICamera.mGenericHandler = value;
- }
- }
- private bool handlesEvents
- {
- get
- {
- return UICamera.eventHandler == this;
- }
- }
- public Camera cachedCamera
- {
- get
- {
- if (this.mCam == null)
- {
- this.mCam = base.GetComponent<Camera>();
- }
- return this.mCam;
- }
- }
- public bool Hover
- {
- get
- {
- return this.m_bHover;
- }
- private set
- {
- this.m_bHover = value;
- }
- }
- public bool EnableProcess
- {
- get
- {
- return this.m_bProcessEnable;
- }
- set
- {
- this.m_bProcessEnable = value;
- }
- }
- public void SetOvrVirtualMousePos(bool f_bHandL, Vector3 v)
- {
- v.x = Mathf.Min(Mathf.Max(v.x, 3f), 1277f);
- v.y = Mathf.Min(Mathf.Max(v.y, 3f), 717f);
- v.z = 0f;
- this.m_vVirtualMousePos[(!f_bHandL) ? 1 : 0] = v;
- }
- public Vector3 GetOvrVirtualMousePos(bool f_bHandL)
- {
- return this.m_vVirtualMousePos[(!f_bHandL) ? 1 : 0];
- }
- public Vector3 GetOvrVirtualMouseCurrentSidePos()
- {
- return this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide];
- }
- public void CreateVirtualCursorObj()
- {
- if (this.m_goVirtualCursor != null)
- {
- this.m_goVirtualCursor = new GameObject[2];
- }
- if (this.m_spriteVirtualCursor != null)
- {
- this.m_spriteVirtualCursor = new UI2DSprite[2];
- }
- GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("OVR/PanelVCursor")) as GameObject;
- gameObject.transform.parent = base.transform.parent;
- gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
- gameObject.SetActive(true);
- this.m_goVirtualCursor[0] = gameObject;
- this.m_spriteVirtualCursor[0] = gameObject.GetComponentInChildren<UI2DSprite>();
- gameObject = UnityEngine.Object.Instantiate<GameObject>(gameObject);
- gameObject.transform.parent = base.transform.parent;
- gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
- gameObject.SetActive(true);
- this.m_goVirtualCursor[1] = gameObject;
- this.m_spriteVirtualCursor[1] = gameObject.GetComponentInChildren<UI2DSprite>();
- }
- public void HideVirtualCursorObj()
- {
- for (int i = 0; i < 2; i++)
- {
- this.SetActiveVirtualCursorObj((UICamera.VCURSOR)i, false);
- }
- }
- public void SetActiveVirtualCursorObjByNocurrent(UICamera.VCURSOR f_eCursor, bool f_bActive)
- {
- if (this.m_goVirtualCursor[(int)f_eCursor] != null)
- {
- UICamera.VCURSOR vcursor = (f_eCursor != UICamera.VCURSOR.LEFT) ? UICamera.VCURSOR.LEFT : UICamera.VCURSOR.RIGHT;
- if (!f_bActive)
- {
- if (f_eCursor == this.m_eCurrentCursorSide)
- {
- if (this.m_goVirtualCursor[(int)vcursor].activeInHierarchy)
- {
- this.SetCurrentCursorSide(vcursor);
- this.m_goVirtualCursor[(int)f_eCursor].SetActive(false);
- this.m_bVirtualDummyActive[(int)f_eCursor] = false;
- }
- else
- {
- this.m_bVirtualDummyActive[(int)f_eCursor] = true;
- }
- }
- else
- {
- this.m_goVirtualCursor[(int)f_eCursor].SetActive(false);
- this.m_bVirtualDummyActive[(int)f_eCursor] = false;
- }
- }
- else
- {
- this.m_goVirtualCursor[(int)f_eCursor].SetActive(true);
- this.m_bVirtualDummyActive[(int)f_eCursor] = false;
- if (this.m_bVirtualDummyActive[(int)vcursor])
- {
- this.m_goVirtualCursor[(int)vcursor].SetActive(false);
- this.m_bVirtualDummyActive[(int)vcursor] = false;
- this.SetCurrentCursorSide(f_eCursor);
- }
- }
- }
- }
- public void SetActiveVirtualCursorObj(UICamera.VCURSOR f_eCursor, bool f_bActive)
- {
- if (this.m_goVirtualCursor[(int)f_eCursor] != null)
- {
- this.m_goVirtualCursor[(int)f_eCursor].SetActive(f_bActive);
- }
- }
- public void DeleteVirtualCursorObj()
- {
- for (int i = 0; i < 2; i++)
- {
- if (this.m_goVirtualCursor[i] != null)
- {
- UnityEngine.Object.DestroyImmediate(this.m_goVirtualCursor[i]);
- this.m_goVirtualCursor[i] = null;
- }
- }
- }
- public void SetCurrentCursorSide(UICamera.VCURSOR f_eCursor)
- {
- this.m_eCurrentCursorSide = f_eCursor;
- }
- public static bool isOverUI
- {
- get
- {
- if (UICamera.currentTouch != null)
- {
- return UICamera.currentTouch.isOverUI;
- }
- return !(UICamera.hoveredObject == null) && !(UICamera.hoveredObject == UICamera.fallThrough) && NGUITools.FindInParents<UIRoot>(UICamera.hoveredObject) != null;
- }
- }
- public static GameObject selectedObject
- {
- get
- {
- return UICamera.mCurrentSelection;
- }
- set
- {
- UICamera.SetSelection(value, UICamera.currentScheme);
- }
- }
- public static bool IsPressed(GameObject go)
- {
- for (int i = 0; i < 3; i++)
- {
- if (UICamera.mMouse[i].pressed == go)
- {
- return true;
- }
- }
- foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
- {
- if (keyValuePair.Value.pressed == go)
- {
- return true;
- }
- }
- return UICamera.controller.pressed == go;
- }
- protected static void SetSelection(GameObject go, UICamera.ControlScheme scheme)
- {
- if (UICamera.mNextSelection != null)
- {
- UICamera.mNextSelection = go;
- }
- else if (UICamera.mCurrentSelection != go)
- {
- UICamera.mNextSelection = go;
- UICamera.mNextScheme = scheme;
- if (UICamera.list.size > 0)
- {
- UICamera uicamera = (!(UICamera.mNextSelection != null)) ? UICamera.list[0] : UICamera.FindCameraForLayer(UICamera.mNextSelection.layer);
- if (uicamera != null)
- {
- uicamera.StartCoroutine(uicamera.ChangeSelection());
- }
- }
- }
- }
- private IEnumerator ChangeSelection()
- {
- yield return new WaitForEndOfFrame();
- if (UICamera.onSelect != null)
- {
- UICamera.onSelect(UICamera.mCurrentSelection, false);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnSelect", false);
- UICamera.mCurrentSelection = UICamera.mNextSelection;
- UICamera.mNextSelection = null;
- if (UICamera.mCurrentSelection != null)
- {
- UICamera.current = this;
- UICamera.currentCamera = this.mCam;
- UICamera.currentScheme = UICamera.mNextScheme;
- UICamera.inputHasFocus = (UICamera.mCurrentSelection.GetComponent<UIInput>() != null);
- if (UICamera.onSelect != null)
- {
- UICamera.onSelect(UICamera.mCurrentSelection, true);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnSelect", true);
- UICamera.current = null;
- }
- else
- {
- UICamera.inputHasFocus = false;
- }
- yield break;
- }
- public static int touchCount
- {
- get
- {
- int num = 0;
- foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
- {
- if (keyValuePair.Value.pressed != null)
- {
- num++;
- }
- }
- for (int i = 0; i < UICamera.mMouse.Length; i++)
- {
- if (UICamera.mMouse[i].pressed != null)
- {
- num++;
- }
- }
- if (UICamera.controller.pressed != null)
- {
- num++;
- }
- return num;
- }
- }
- public static int dragCount
- {
- get
- {
- int num = 0;
- foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
- {
- if (keyValuePair.Value.dragged != null)
- {
- num++;
- }
- }
- for (int i = 0; i < UICamera.mMouse.Length; i++)
- {
- if (UICamera.mMouse[i].dragged != null)
- {
- num++;
- }
- }
- if (UICamera.controller.dragged != null)
- {
- num++;
- }
- return num;
- }
- }
- public static Camera mainCamera
- {
- get
- {
- UICamera eventHandler = UICamera.eventHandler;
- return (!(eventHandler != null)) ? null : eventHandler.cachedCamera;
- }
- }
- public static UICamera eventHandler
- {
- get
- {
- for (int i = 0; i < UICamera.list.size; i++)
- {
- UICamera uicamera = UICamera.list.buffer[i];
- if (!(uicamera == null) && uicamera.enabled && NGUITools.GetActive(uicamera.gameObject))
- {
- return uicamera;
- }
- }
- return null;
- }
- }
- private static int CompareFunc(UICamera a, UICamera b)
- {
- if (a.cachedCamera.depth < b.cachedCamera.depth)
- {
- return 1;
- }
- if (a.cachedCamera.depth > b.cachedCamera.depth)
- {
- return -1;
- }
- return 0;
- }
- private static Rigidbody FindRootRigidbody(Transform trans)
- {
- while (trans != null)
- {
- if (trans.GetComponent<UIPanel>() != null)
- {
- return null;
- }
- Rigidbody component = trans.GetComponent<Rigidbody>();
- if (component != null)
- {
- return component;
- }
- trans = trans.parent;
- }
- return null;
- }
- private static Rigidbody2D FindRootRigidbody2D(Transform trans)
- {
- while (trans != null)
- {
- if (trans.GetComponent<UIPanel>() != null)
- {
- return null;
- }
- Rigidbody2D component = trans.GetComponent<Rigidbody2D>();
- if (component != null)
- {
- return component;
- }
- trans = trans.parent;
- }
- return null;
- }
- public static bool Raycast(Vector3 inPos)
- {
- for (int i = 0; i < UICamera.list.size; i++)
- {
- UICamera.list.buffer[i].Hover = false;
- }
- for (int j = 0; j < UICamera.list.size; j++)
- {
- UICamera uicamera = UICamera.list.buffer[j];
- if (uicamera.enabled && NGUITools.GetActive(uicamera.gameObject) && uicamera.EnableProcess)
- {
- UICamera.currentCamera = uicamera.cachedCamera;
- Vector3 vector = UICamera.currentCamera.ScreenToViewportPoint(inPos);
- if (!float.IsNaN(vector.x) && !float.IsNaN(vector.y))
- {
- if (vector.x >= 0f && vector.x <= 1f && vector.y >= 0f && vector.y <= 1f)
- {
- Ray ray = UICamera.currentCamera.ScreenPointToRay(inPos);
- int layerMask = UICamera.currentCamera.cullingMask & uicamera.eventReceiverMask;
- float num = (uicamera.rangeDistance <= 0f) ? (UICamera.currentCamera.farClipPlane - UICamera.currentCamera.nearClipPlane) : uicamera.rangeDistance;
- if (uicamera.eventType == UICamera.EventType.World_3D)
- {
- if (Physics.Raycast(ray, out UICamera.lastHit, num, layerMask))
- {
- UICamera.lastWorldPosition = UICamera.lastHit.point;
- UICamera.hoveredObject = UICamera.lastHit.collider.gameObject;
- if (!UICamera.list[0].eventsGoToColliders)
- {
- Rigidbody rigidbody = UICamera.FindRootRigidbody(UICamera.hoveredObject.transform);
- if (rigidbody != null)
- {
- UICamera.hoveredObject = rigidbody.gameObject;
- }
- }
- uicamera.Hover = true;
- return true;
- }
- }
- else if (uicamera.eventType == UICamera.EventType.UI_3D)
- {
- RaycastHit[] array = Physics.RaycastAll(ray, num, layerMask);
- if (array.Length > 1)
- {
- int k = 0;
- while (k < array.Length)
- {
- GameObject gameObject = array[k].collider.gameObject;
- UIWidget component = gameObject.GetComponent<UIWidget>();
- if (component != null)
- {
- if (component.isVisible)
- {
- if (component.hitCheck == null || component.hitCheck(array[k].point))
- {
- goto IL_2A2;
- }
- }
- }
- else
- {
- UIRect uirect = NGUITools.FindInParents<UIRect>(gameObject);
- if (!(uirect != null) || uirect.finalAlpha >= 0.001f)
- {
- goto IL_2A2;
- }
- }
- IL_323:
- k++;
- continue;
- IL_2A2:
- UICamera.mHit.depth = NGUITools.CalculateRaycastDepth(gameObject);
- if (UICamera.mHit.depth != 2147483647)
- {
- UICamera.mHit.hit = array[k];
- UICamera.mHit.point = array[k].point;
- UICamera.mHit.go = array[k].collider.gameObject;
- UICamera.mHits.Add(UICamera.mHit);
- goto IL_323;
- }
- goto IL_323;
- }
- UICamera.mHits.Sort((UICamera.DepthEntry r1, UICamera.DepthEntry r2) => r2.depth.CompareTo(r1.depth));
- for (int l = 0; l < UICamera.mHits.size; l++)
- {
- if (UICamera.IsVisible(ref UICamera.mHits.buffer[l]))
- {
- UICamera.lastHit = UICamera.mHits[l].hit;
- UICamera.hoveredObject = UICamera.mHits[l].go;
- UICamera.lastWorldPosition = UICamera.mHits[l].point;
- UICamera.mHits.Clear();
- uicamera.Hover = true;
- return true;
- }
- }
- UICamera.mHits.Clear();
- }
- else if (array.Length == 1)
- {
- GameObject gameObject2 = array[0].collider.gameObject;
- UIWidget component2 = gameObject2.GetComponent<UIWidget>();
- if (component2 != null)
- {
- if (!component2.isVisible)
- {
- goto IL_849;
- }
- if (component2.hitCheck != null && !component2.hitCheck(array[0].point))
- {
- goto IL_849;
- }
- }
- else
- {
- UIRect uirect2 = NGUITools.FindInParents<UIRect>(gameObject2);
- if (uirect2 != null && uirect2.finalAlpha < 0.001f)
- {
- goto IL_849;
- }
- }
- if (UICamera.IsVisible(array[0].point, array[0].collider.gameObject))
- {
- UICamera.lastHit = array[0];
- UICamera.lastWorldPosition = array[0].point;
- UICamera.hoveredObject = UICamera.lastHit.collider.gameObject;
- uicamera.Hover = true;
- return true;
- }
- }
- }
- else if (uicamera.eventType == UICamera.EventType.World_2D)
- {
- if (UICamera.m2DPlane.Raycast(ray, out num))
- {
- Vector3 point = ray.GetPoint(num);
- Collider2D collider2D = Physics2D.OverlapPoint(point, layerMask);
- if (collider2D)
- {
- UICamera.lastWorldPosition = point;
- UICamera.hoveredObject = collider2D.gameObject;
- if (!uicamera.eventsGoToColliders)
- {
- Rigidbody2D rigidbody2D = UICamera.FindRootRigidbody2D(UICamera.hoveredObject.transform);
- if (rigidbody2D != null)
- {
- UICamera.hoveredObject = rigidbody2D.gameObject;
- }
- }
- uicamera.Hover = true;
- return true;
- }
- }
- }
- else if (uicamera.eventType == UICamera.EventType.UI_2D)
- {
- if (UICamera.m2DPlane.Raycast(ray, out num))
- {
- UICamera.lastWorldPosition = ray.GetPoint(num);
- Collider2D[] array2 = Physics2D.OverlapPointAll(UICamera.lastWorldPosition, layerMask);
- if (array2.Length > 1)
- {
- int m = 0;
- while (m < array2.Length)
- {
- GameObject gameObject3 = array2[m].gameObject;
- UIWidget component3 = gameObject3.GetComponent<UIWidget>();
- if (component3 != null)
- {
- if (component3.isVisible)
- {
- if (component3.hitCheck == null || component3.hitCheck(UICamera.lastWorldPosition))
- {
- goto IL_692;
- }
- }
- }
- else
- {
- UIRect uirect3 = NGUITools.FindInParents<UIRect>(gameObject3);
- if (!(uirect3 != null) || uirect3.finalAlpha >= 0.001f)
- {
- goto IL_692;
- }
- }
- IL_6E1:
- m++;
- continue;
- IL_692:
- UICamera.mHit.depth = NGUITools.CalculateRaycastDepth(gameObject3);
- if (UICamera.mHit.depth != 2147483647)
- {
- UICamera.mHit.go = gameObject3;
- UICamera.mHit.point = UICamera.lastWorldPosition;
- UICamera.mHits.Add(UICamera.mHit);
- goto IL_6E1;
- }
- goto IL_6E1;
- }
- UICamera.mHits.Sort((UICamera.DepthEntry r1, UICamera.DepthEntry r2) => r2.depth.CompareTo(r1.depth));
- for (int n = 0; n < UICamera.mHits.size; n++)
- {
- if (UICamera.IsVisible(ref UICamera.mHits.buffer[n]))
- {
- UICamera.hoveredObject = UICamera.mHits[n].go;
- UICamera.mHits.Clear();
- uicamera.Hover = true;
- return true;
- }
- }
- UICamera.mHits.Clear();
- }
- else if (array2.Length == 1)
- {
- GameObject gameObject4 = array2[0].gameObject;
- UIWidget component4 = gameObject4.GetComponent<UIWidget>();
- if (component4 != null)
- {
- if (!component4.isVisible)
- {
- goto IL_849;
- }
- if (component4.hitCheck != null && !component4.hitCheck(UICamera.lastWorldPosition))
- {
- goto IL_849;
- }
- }
- else
- {
- UIRect uirect4 = NGUITools.FindInParents<UIRect>(gameObject4);
- if (uirect4 != null && uirect4.finalAlpha < 0.001f)
- {
- goto IL_849;
- }
- }
- if (UICamera.IsVisible(UICamera.lastWorldPosition, gameObject4))
- {
- UICamera.hoveredObject = gameObject4;
- uicamera.Hover = true;
- return true;
- }
- }
- }
- }
- }
- }
- }
- IL_849:;
- }
- return false;
- }
- private static bool IsVisible(Vector3 worldPoint, GameObject go)
- {
- UIPanel uipanel = NGUITools.FindInParents<UIPanel>(go);
- while (uipanel != null)
- {
- if (!uipanel.IsVisible(worldPoint))
- {
- return false;
- }
- uipanel = uipanel.parentPanel;
- }
- return true;
- }
- private static bool IsVisible(ref UICamera.DepthEntry de)
- {
- UIPanel uipanel = NGUITools.FindInParents<UIPanel>(de.go);
- while (uipanel != null)
- {
- if (!uipanel.IsVisible(de.point))
- {
- return false;
- }
- uipanel = uipanel.parentPanel;
- }
- return true;
- }
- public static bool IsHighlighted(GameObject go)
- {
- if (UICamera.currentScheme == UICamera.ControlScheme.Mouse)
- {
- return UICamera.hoveredObject == go;
- }
- return UICamera.currentScheme == UICamera.ControlScheme.Controller && UICamera.selectedObject == go;
- }
- public static UICamera FindCameraForLayer(int layer)
- {
- int num = 1 << layer;
- for (int i = 0; i < UICamera.list.size; i++)
- {
- UICamera uicamera = UICamera.list.buffer[i];
- Camera cachedCamera = uicamera.cachedCamera;
- if (cachedCamera != null && (cachedCamera.cullingMask & num) != 0)
- {
- return uicamera;
- }
- }
- return null;
- }
- private static int GetDirection(KeyCode up, KeyCode down)
- {
- if (UICamera.GetKeyDown(up))
- {
- return 1;
- }
- if (UICamera.GetKeyDown(down))
- {
- return -1;
- }
- return 0;
- }
- private static int GetDirection(KeyCode up0, KeyCode up1, KeyCode down0, KeyCode down1)
- {
- if (UICamera.GetKeyDown(up0) || UICamera.GetKeyDown(up1))
- {
- return 1;
- }
- if (UICamera.GetKeyDown(down0) || UICamera.GetKeyDown(down1))
- {
- return -1;
- }
- return 0;
- }
- private static int GetDirection(string axis)
- {
- float time = RealTime.time;
- if (UICamera.mNextEvent < time && !string.IsNullOrEmpty(axis))
- {
- float num = UICamera.GetAxis(axis);
- if (num > 0.75f)
- {
- UICamera.mNextEvent = time + 0.25f;
- return 1;
- }
- if (num < -0.75f)
- {
- UICamera.mNextEvent = time + 0.25f;
- return -1;
- }
- }
- return 0;
- }
- public static void Notify(GameObject go, string funcName, object obj)
- {
- if (UICamera.mNotifying)
- {
- return;
- }
- UICamera.mNotifying = true;
- if (NGUITools.GetActive(go))
- {
- go.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
- if (UICamera.mGenericHandler != null && UICamera.mGenericHandler != go)
- {
- UICamera.mGenericHandler.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
- }
- }
- UICamera.mNotifying = false;
- }
- public static UICamera.MouseOrTouch GetMouse(int button)
- {
- return UICamera.mMouse[button];
- }
- public static UICamera.MouseOrTouch GetTouch(int id)
- {
- UICamera.MouseOrTouch mouseOrTouch = null;
- if (id < 0)
- {
- return UICamera.GetMouse(-id - 1);
- }
- if (!UICamera.mTouches.TryGetValue(id, out mouseOrTouch))
- {
- mouseOrTouch = new UICamera.MouseOrTouch();
- mouseOrTouch.pressTime = RealTime.time;
- mouseOrTouch.touchBegan = true;
- UICamera.mTouches.Add(id, mouseOrTouch);
- }
- return mouseOrTouch;
- }
- public static void RemoveTouch(int id)
- {
- UICamera.mTouches.Remove(id);
- }
- public static int ScreenWidth
- {
- get
- {
- if (Application.isPlaying && (GameMain.Instance != null && GameMain.Instance.VRMode))
- {
- return 1280;
- }
- return Screen.width;
- }
- }
- public static int ScreenHeight
- {
- get
- {
- if (Application.isPlaying && (GameMain.Instance != null && GameMain.Instance.VRMode))
- {
- return 720;
- }
- return Screen.height;
- }
- }
- private void Awake()
- {
- if (GameMain.Instance != null && GameMain.Instance.VRMode)
- {
- this.VRUpdateCamDepth();
- }
- UICamera.mWidth = UICamera.ScreenWidth;
- UICamera.mHeight = UICamera.ScreenHeight;
- if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WP8Player || Application.platform == RuntimePlatform.BlackBerryPlayer)
- {
- this.useTouch = true;
- if (Application.platform == RuntimePlatform.IPhonePlayer)
- {
- this.useMouse = false;
- this.useKeyboard = false;
- this.useController = false;
- }
- }
- else if (Application.platform == RuntimePlatform.PS3 || Application.platform == RuntimePlatform.XBOX360)
- {
- this.useMouse = false;
- this.useTouch = false;
- this.useKeyboard = false;
- this.useController = true;
- }
- UICamera.mMouse[0].pos = Input.mousePosition;
- for (int i = 1; i < 3; i++)
- {
- UICamera.mMouse[i].pos = UICamera.mMouse[0].pos;
- UICamera.mMouse[i].lastPos = UICamera.mMouse[0].pos;
- }
- UICamera.lastTouchPosition = UICamera.mMouse[0].pos;
- }
- private void OnEnable()
- {
- UICamera.list.Add(this);
- BetterList<UICamera> betterList = UICamera.list;
- if (UICamera.<>f__mg$cache0 == null)
- {
- UICamera.<>f__mg$cache0 = new BetterList<UICamera>.CompareFunc(UICamera.CompareFunc);
- }
- betterList.Sort(UICamera.<>f__mg$cache0);
- if (GameMain.Instance != null && GameMain.Instance.VRMode)
- {
- this.VRUpdateCamDepth();
- }
- }
- private void OnDisable()
- {
- UICamera.list.Remove(this);
- if (GameMain.Instance != null && GameMain.Instance.VRMode)
- {
- this.VRUpdateCamDepth();
- }
- }
- private void Start()
- {
- if (this.eventType != UICamera.EventType.World_3D && this.cachedCamera.transparencySortMode != TransparencySortMode.Orthographic)
- {
- this.cachedCamera.transparencySortMode = TransparencySortMode.Orthographic;
- }
- if (Application.isPlaying)
- {
- if (UICamera.fallThrough == null)
- {
- UIRoot uiroot = NGUITools.FindInParents<UIRoot>(base.gameObject);
- if (uiroot != null)
- {
- UICamera.fallThrough = uiroot.gameObject;
- }
- else
- {
- Transform transform = base.transform;
- UICamera.fallThrough = ((!(transform.parent != null)) ? base.gameObject : transform.parent.gameObject);
- }
- }
- this.cachedCamera.eventMask = 0;
- }
- if (this.handlesEvents)
- {
- NGUIDebug.debugRaycast = this.debug;
- }
- }
- private void VRUpdateCamDepth()
- {
- if (this.VRExclusionUI)
- {
- return;
- }
- UICamera[] array = (from a in UnityEngine.Object.FindObjectsOfType<UICamera>()
- where !a.VRExclusionUI
- select a).ToArray<UICamera>();
- if (array.Length == 0)
- {
- return;
- }
- Camera camera = array[0].cachedCamera;
- for (int i = 0; i < array.Length; i++)
- {
- Camera cachedCamera = array[i].cachedCamera;
- cachedCamera.clearFlags = CameraClearFlags.Depth;
- if (cachedCamera.depth < camera.depth)
- {
- camera = cachedCamera;
- }
- }
- camera.clearFlags = CameraClearFlags.Color;
- this.cachedCamera.targetTexture = GameMain.Instance.OvrMgr.UIRTarget;
- if (base.transform.parent.name == "SystemUI Root")
- {
- this.cachedCamera.clearFlags = CameraClearFlags.Depth;
- }
- }
- public static void InputEnableFlag(UICamera.INPUT_CTRL_TYPE flag, bool bEnable)
- {
- if (bEnable)
- {
- UICamera.m_unInputEnableFlag |= (uint)flag;
- }
- else
- {
- UICamera.m_unInputEnableFlag &= (uint)(~(uint)flag);
- }
- }
- private void Update()
- {
- if (!this.handlesEvents)
- {
- return;
- }
- if (!UICamera.InputEnable)
- {
- return;
- }
- UICamera.current = this;
- if (GameMain.Instance.VRMode && Application.isPlaying)
- {
- for (int i = 0; i < 2; i++)
- {
- if (!GameMain.Instance.VRDummyMode)
- {
- Vector3[] vVirtualMousePos = this.m_vVirtualMousePos;
- int num = i;
- vVirtualMousePos[num].x = vVirtualMousePos[num].x + NInput.GetAxis("Mouse X") * Time.deltaTime * 100f * 10f;
- Vector3[] vVirtualMousePos2 = this.m_vVirtualMousePos;
- int num2 = i;
- vVirtualMousePos2[num2].y = vVirtualMousePos2[num2].y + NInput.GetAxis("Mouse Y") * Time.deltaTime * 100f * 10f;
- }
- this.m_vVirtualMousePos[i].x = Mathf.Min(Mathf.Max(this.m_vVirtualMousePos[i].x, 3f), 1277f);
- this.m_vVirtualMousePos[i].y = Mathf.Min(Mathf.Max(this.m_vVirtualMousePos[i].y, 3f), 717f);
- this.m_vVirtualMousePos[i].z = 0f;
- if (this.m_goVirtualCursor[i] != null)
- {
- this.m_goVirtualCursor[i].transform.position = base.GetComponent<Camera>().ScreenToWorldPoint(this.m_vVirtualMousePos[i]);
- }
- if (this.m_spriteVirtualCursor[i] != null)
- {
- this.m_spriteVirtualCursor[i].color = ((i != (int)this.m_eCurrentCursorSide) ? new Color(1f, 1f, 1f, 0.5f) : new Color(1f, 1f, 1f, 1f));
- }
- }
- }
- if (this.useTouch)
- {
- this.ProcessTouches();
- }
- else if (this.useMouse)
- {
- this.ProcessMouse();
- }
- if (UICamera.onCustomInput != null)
- {
- UICamera.onCustomInput();
- }
- if (this.useMouse && UICamera.mCurrentSelection != null)
- {
- if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0))
- {
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- UICamera.currentKey = this.cancelKey0;
- UICamera.selectedObject = null;
- }
- else if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1))
- {
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- UICamera.currentKey = this.cancelKey1;
- UICamera.selectedObject = null;
- }
- }
- if (UICamera.mCurrentSelection == null)
- {
- UICamera.inputHasFocus = false;
- }
- if (UICamera.mCurrentSelection != null)
- {
- this.ProcessOthers();
- }
- if (this.useMouse && UICamera.mHover != null)
- {
- float num3 = string.IsNullOrEmpty(this.scrollAxisName) ? 0f : UICamera.GetAxis(this.scrollAxisName);
- if (num3 != 0f)
- {
- if (UICamera.onScroll != null)
- {
- UICamera.onScroll(UICamera.mHover, num3);
- }
- UICamera.Notify(UICamera.mHover, "OnScroll", num3);
- }
- if (UICamera.showTooltips && this.mTooltipTime != 0f && (this.mTooltipTime < RealTime.time || UICamera.GetKey(KeyCode.LeftShift) || UICamera.GetKey(KeyCode.RightShift)))
- {
- this.mTooltip = UICamera.mHover;
- this.ShowTooltip(true);
- }
- }
- UICamera.current = null;
- UICamera.currentTouchID = -100;
- }
- private void LateUpdate()
- {
- if (!this.handlesEvents)
- {
- return;
- }
- int screenWidth = UICamera.ScreenWidth;
- int screenHeight = UICamera.ScreenHeight;
- if (screenWidth != UICamera.mWidth || screenHeight != UICamera.mHeight)
- {
- UICamera.mWidth = screenWidth;
- UICamera.mHeight = screenHeight;
- UIRoot.Broadcast("UpdateAnchors");
- if (UICamera.onScreenResize != null)
- {
- UICamera.onScreenResize();
- }
- }
- }
- public void ProcessMouse()
- {
- if (GameMain.Instance.VRMode && Application.isPlaying)
- {
- if (GameMain.Instance.MainCamera.IsFadeOut())
- {
- return;
- }
- UICamera.lastTouchPosition = new Vector2(this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].x, this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].y);
- }
- else
- {
- UICamera.lastTouchPosition = Input.mousePosition;
- }
- UICamera.mMouse[0].delta = UICamera.lastTouchPosition - UICamera.mMouse[0].pos;
- UICamera.mMouse[0].pos = UICamera.lastTouchPosition;
- bool flag = UICamera.mMouse[0].delta.sqrMagnitude > 0.001f;
- for (int i = 1; i < 3; i++)
- {
- UICamera.mMouse[i].pos = UICamera.mMouse[0].pos;
- UICamera.mMouse[i].delta = UICamera.mMouse[0].delta;
- }
- bool flag2 = false;
- bool flag3 = false;
- if (UICamera.isDisableRightClick && (NInput.GetMouseButtonDown(1) || NInput.GetMouseButton(1) || NInput.GetMouseButtonUp(1)))
- {
- return;
- }
- for (int j = 0; j < 3; j++)
- {
- if (NInput.GetMouseButtonDown(j))
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- flag3 = true;
- flag2 = true;
- }
- else if (NInput.GetMouseButton(j))
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- flag2 = true;
- }
- }
- if (flag2 || flag || this.mNextRaycast < RealTime.time)
- {
- this.mNextRaycast = RealTime.time + 0.02f;
- Vector3 inPos;
- if (GameMain.Instance.VRMode && Application.isPlaying)
- {
- inPos = this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide];
- }
- else
- {
- inPos = Input.mousePosition;
- }
- if (!UICamera.Raycast(inPos))
- {
- UICamera.hoveredObject = UICamera.fallThrough;
- UICamera.isFallThrough = true;
- }
- else
- {
- UICamera.isFallThrough = false;
- }
- if (UICamera.hoveredObject == null)
- {
- UICamera.hoveredObject = UICamera.mGenericHandler;
- }
- for (int k = 0; k < 3; k++)
- {
- UICamera.mMouse[k].current = UICamera.hoveredObject;
- }
- }
- bool flag4 = UICamera.mMouse[0].last != UICamera.mMouse[0].current;
- if (flag4)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- }
- if (flag2)
- {
- this.mTooltipTime = 0f;
- }
- else if (flag && (!this.stickyTooltip || flag4))
- {
- if (this.mTooltipTime != 0f)
- {
- this.mTooltipTime = RealTime.time + this.tooltipDelay;
- }
- else if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- }
- if (flag && UICamera.onMouseMove != null)
- {
- UICamera.currentTouch = UICamera.mMouse[0];
- UICamera.onMouseMove(UICamera.currentTouch.delta);
- UICamera.currentTouch = null;
- }
- if ((flag3 || !flag2) && UICamera.mHover != null && flag4)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- UICamera.currentTouch = UICamera.mMouse[0];
- if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- if (UICamera.onHover != null)
- {
- UICamera.onHover(UICamera.mHover, false);
- }
- UICamera.Notify(UICamera.mHover, "OnHover", false);
- UICamera.mHover = null;
- }
- for (int l = 0; l < 3; l++)
- {
- bool mouseButtonDown = NInput.GetMouseButtonDown(l);
- bool mouseButtonUp = NInput.GetMouseButtonUp(l);
- if (mouseButtonDown || mouseButtonUp)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- }
- UICamera.currentTouch = UICamera.mMouse[l];
- UICamera.currentTouchID = -1 - l;
- UICamera.currentKey = KeyCode.Mouse0 + l;
- if (mouseButtonDown)
- {
- UICamera.currentTouch.pressedCam = UICamera.currentCamera;
- }
- else if (UICamera.currentTouch.pressed != null)
- {
- UICamera.currentCamera = UICamera.currentTouch.pressedCam;
- }
- this.ProcessTouch(mouseButtonDown, mouseButtonUp);
- UICamera.currentKey = KeyCode.None;
- }
- if (!flag2 && flag4)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- this.mTooltipTime = RealTime.time + this.tooltipDelay;
- UICamera.mHover = UICamera.mMouse[0].current;
- UICamera.currentTouch = UICamera.mMouse[0];
- if (UICamera.onHover != null)
- {
- UICamera.onHover(UICamera.mHover, true);
- }
- UICamera.Notify(UICamera.mHover, "OnHover", true);
- }
- UICamera.currentTouch = null;
- UICamera.mMouse[0].last = UICamera.mMouse[0].current;
- for (int m = 1; m < 3; m++)
- {
- UICamera.mMouse[m].last = UICamera.mMouse[0].last;
- }
- }
- public void ProcessTouches()
- {
- UICamera.currentScheme = UICamera.ControlScheme.Touch;
- for (int i = 0; i < Input.touchCount; i++)
- {
- Touch touch = Input.GetTouch(i);
- UICamera.currentTouchID = ((!this.allowMultiTouch) ? 1 : touch.fingerId);
- UICamera.currentTouch = UICamera.GetTouch(UICamera.currentTouchID);
- bool flag = touch.phase == TouchPhase.Began || UICamera.currentTouch.touchBegan;
- bool flag2 = touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended;
- UICamera.currentTouch.touchBegan = false;
- UICamera.currentTouch.delta = ((!flag) ? (touch.position - UICamera.currentTouch.pos) : Vector2.zero);
- UICamera.currentTouch.pos = touch.position;
- if (!UICamera.Raycast(UICamera.currentTouch.pos))
- {
- UICamera.hoveredObject = UICamera.fallThrough;
- }
- if (UICamera.hoveredObject == null)
- {
- UICamera.hoveredObject = UICamera.mGenericHandler;
- }
- UICamera.currentTouch.last = UICamera.currentTouch.current;
- UICamera.currentTouch.current = UICamera.hoveredObject;
- UICamera.lastTouchPosition = UICamera.currentTouch.pos;
- if (flag)
- {
- UICamera.currentTouch.pressedCam = UICamera.currentCamera;
- }
- else if (UICamera.currentTouch.pressed != null)
- {
- UICamera.currentCamera = UICamera.currentTouch.pressedCam;
- }
- if (touch.tapCount > 1)
- {
- UICamera.currentTouch.clickTime = RealTime.time;
- }
- this.ProcessTouch(flag, flag2);
- if (flag2)
- {
- UICamera.RemoveTouch(UICamera.currentTouchID);
- }
- UICamera.currentTouch.last = null;
- UICamera.currentTouch = null;
- if (!this.allowMultiTouch)
- {
- break;
- }
- }
- if (Input.touchCount == 0)
- {
- if (UICamera.mUsingTouchEvents)
- {
- UICamera.mUsingTouchEvents = false;
- return;
- }
- if (this.useMouse)
- {
- this.ProcessMouse();
- }
- }
- else
- {
- UICamera.mUsingTouchEvents = true;
- }
- }
- private void ProcessFakeTouches()
- {
- bool mouseButtonDown = NInput.GetMouseButtonDown(0);
- bool mouseButtonUp = NInput.GetMouseButtonUp(0);
- bool mouseButton = NInput.GetMouseButton(0);
- if (mouseButtonDown || mouseButtonUp || mouseButton)
- {
- UICamera.currentTouchID = 1;
- UICamera.currentTouch = UICamera.mMouse[0];
- UICamera.currentTouch.touchBegan = mouseButtonDown;
- if (mouseButtonDown)
- {
- UICamera.currentTouch.pressTime = RealTime.time;
- }
- Vector2 vector;
- if (GameMain.Instance.VRMode && Application.isPlaying)
- {
- vector = new Vector2(this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].x, this.m_vVirtualMousePos[(int)this.m_eCurrentCursorSide].y);
- }
- else
- {
- vector = Input.mousePosition;
- }
- UICamera.currentTouch.delta = ((!mouseButtonDown) ? (vector - UICamera.currentTouch.pos) : Vector2.zero);
- UICamera.currentTouch.pos = vector;
- if (!UICamera.Raycast(UICamera.currentTouch.pos))
- {
- UICamera.hoveredObject = UICamera.fallThrough;
- }
- if (UICamera.hoveredObject == null)
- {
- UICamera.hoveredObject = UICamera.mGenericHandler;
- }
- UICamera.currentTouch.last = UICamera.currentTouch.current;
- UICamera.currentTouch.current = UICamera.hoveredObject;
- UICamera.lastTouchPosition = UICamera.currentTouch.pos;
- if (mouseButtonDown)
- {
- UICamera.currentTouch.pressedCam = UICamera.currentCamera;
- }
- else if (UICamera.currentTouch.pressed != null)
- {
- UICamera.currentCamera = UICamera.currentTouch.pressedCam;
- }
- this.ProcessTouch(mouseButtonDown, mouseButtonUp);
- if (mouseButtonUp)
- {
- UICamera.RemoveTouch(UICamera.currentTouchID);
- }
- UICamera.currentTouch.last = null;
- UICamera.currentTouch = null;
- }
- }
- public void ProcessOthers()
- {
- UICamera.currentTouchID = -100;
- UICamera.currentTouch = UICamera.controller;
- bool flag = false;
- bool flag2 = false;
- if (this.submitKey0 != KeyCode.None && UICamera.GetKeyDown(this.submitKey0))
- {
- UICamera.currentKey = this.submitKey0;
- flag = true;
- }
- if (this.submitKey1 != KeyCode.None && UICamera.GetKeyDown(this.submitKey1))
- {
- UICamera.currentKey = this.submitKey1;
- flag = true;
- }
- if (this.submitKey0 != KeyCode.None && UICamera.GetKeyUp(this.submitKey0))
- {
- UICamera.currentKey = this.submitKey0;
- flag2 = true;
- }
- if (this.submitKey1 != KeyCode.None && UICamera.GetKeyUp(this.submitKey1))
- {
- UICamera.currentKey = this.submitKey1;
- flag2 = true;
- }
- if (flag || flag2)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- UICamera.currentTouch.last = UICamera.currentTouch.current;
- UICamera.currentTouch.current = UICamera.mCurrentSelection;
- UICamera.currentTouch.last = null;
- }
- int num = 0;
- int num2 = 0;
- if (this.useKeyboard)
- {
- if (UICamera.inputHasFocus)
- {
- num += UICamera.GetDirection(KeyCode.UpArrow, KeyCode.DownArrow);
- num2 += UICamera.GetDirection(KeyCode.RightArrow, KeyCode.LeftArrow);
- }
- else
- {
- num += UICamera.GetDirection(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow);
- num2 += UICamera.GetDirection(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow);
- }
- }
- if (num != 0)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- KeyCode keyCode = (num <= 0) ? KeyCode.DownArrow : KeyCode.UpArrow;
- if (UICamera.onKey != null)
- {
- UICamera.onKey(UICamera.mCurrentSelection, keyCode);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode);
- }
- if (num2 != 0)
- {
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- KeyCode keyCode2 = (num2 <= 0) ? KeyCode.LeftArrow : KeyCode.RightArrow;
- if (UICamera.onKey != null)
- {
- UICamera.onKey(UICamera.mCurrentSelection, keyCode2);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnKey", keyCode2);
- }
- if (this.useKeyboard && UICamera.GetKeyDown(KeyCode.Tab))
- {
- UICamera.currentKey = KeyCode.Tab;
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- if (UICamera.onKey != null)
- {
- UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Tab);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Tab);
- }
- if (this.cancelKey0 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey0))
- {
- UICamera.currentKey = this.cancelKey0;
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- if (UICamera.onKey != null)
- {
- UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
- }
- if (this.cancelKey1 != KeyCode.None && UICamera.GetKeyDown(this.cancelKey1))
- {
- UICamera.currentKey = this.cancelKey1;
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- if (UICamera.onKey != null)
- {
- UICamera.onKey(UICamera.mCurrentSelection, KeyCode.Escape);
- }
- UICamera.Notify(UICamera.mCurrentSelection, "OnKey", KeyCode.Escape);
- }
- UICamera.currentTouch = null;
- UICamera.currentKey = KeyCode.None;
- }
- public void ProcessTouch(bool pressed, bool unpressed)
- {
- bool flag = UICamera.currentScheme == UICamera.ControlScheme.Mouse;
- float num = (!flag) ? this.touchDragThreshold : this.mouseDragThreshold;
- float num2 = (!flag) ? this.touchClickThreshold : this.mouseClickThreshold;
- num *= num;
- num2 *= num2;
- if (pressed)
- {
- if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- UICamera.currentTouch.pressStarted = true;
- if (UICamera.onPress != null && UICamera.currentTouch.pressed)
- {
- UICamera.onPress(UICamera.currentTouch.pressed, false);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
- UICamera.currentTouch.pressed = UICamera.currentTouch.current;
- UICamera.currentTouch.dragged = UICamera.currentTouch.current;
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.BasedOnDelta;
- UICamera.currentTouch.totalDelta = Vector2.zero;
- UICamera.currentTouch.dragStarted = false;
- if (UICamera.onPress != null && UICamera.currentTouch.pressed)
- {
- UICamera.onPress(UICamera.currentTouch.pressed, true);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", true);
- if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
- {
- if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- UICamera.currentScheme = UICamera.ControlScheme.Touch;
- UICamera.selectedObject = UICamera.currentTouch.pressed;
- }
- }
- else if (UICamera.currentTouch.pressed != null && (UICamera.currentTouch.delta.sqrMagnitude != 0f || UICamera.currentTouch.current != UICamera.currentTouch.last))
- {
- UICamera.currentTouch.totalDelta += UICamera.currentTouch.delta;
- float sqrMagnitude = UICamera.currentTouch.totalDelta.sqrMagnitude;
- bool flag2 = false;
- if (!UICamera.currentTouch.dragStarted && UICamera.currentTouch.last != UICamera.currentTouch.current)
- {
- UICamera.currentTouch.dragStarted = true;
- UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
- UICamera.isDragging = true;
- if (UICamera.onDragStart != null)
- {
- UICamera.onDragStart(UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
- if (UICamera.onDragOver != null)
- {
- UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.last, "OnDragOver", UICamera.currentTouch.dragged);
- UICamera.isDragging = false;
- }
- else if (!UICamera.currentTouch.dragStarted && num < sqrMagnitude)
- {
- flag2 = true;
- UICamera.currentTouch.dragStarted = true;
- UICamera.currentTouch.delta = UICamera.currentTouch.totalDelta;
- }
- if (UICamera.currentTouch.dragStarted)
- {
- if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- UICamera.isDragging = true;
- bool flag3 = UICamera.currentTouch.clickNotification == UICamera.ClickNotification.None;
- if (flag2)
- {
- if (UICamera.onDragStart != null)
- {
- UICamera.onDragStart(UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.dragged, "OnDragStart", null);
- if (UICamera.onDragOver != null)
- {
- UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
- }
- else if (UICamera.currentTouch.last != UICamera.currentTouch.current)
- {
- if (UICamera.onDragStart != null)
- {
- UICamera.onDragStart(UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
- if (UICamera.onDragOver != null)
- {
- UICamera.onDragOver(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.current, "OnDragOver", UICamera.currentTouch.dragged);
- }
- if (UICamera.onDrag != null)
- {
- UICamera.onDrag(UICamera.currentTouch.dragged, UICamera.currentTouch.delta);
- }
- UICamera.Notify(UICamera.currentTouch.dragged, "OnDrag", UICamera.currentTouch.delta);
- UICamera.currentTouch.last = UICamera.currentTouch.current;
- UICamera.isDragging = false;
- if (flag3)
- {
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
- }
- else if (UICamera.currentTouch.clickNotification == UICamera.ClickNotification.BasedOnDelta && num2 < sqrMagnitude)
- {
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
- }
- }
- }
- if (unpressed)
- {
- UICamera.currentTouch.pressStarted = false;
- if (this.mTooltip != null)
- {
- this.ShowTooltip(false);
- }
- if (UICamera.currentTouch.pressed != null)
- {
- if (UICamera.currentTouch.dragStarted)
- {
- if (UICamera.onDragOut != null)
- {
- UICamera.onDragOut(UICamera.currentTouch.last, UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.last, "OnDragOut", UICamera.currentTouch.dragged);
- if (UICamera.onDragEnd != null)
- {
- UICamera.onDragEnd(UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.dragged, "OnDragEnd", null);
- }
- if (UICamera.onPress != null)
- {
- UICamera.onPress(UICamera.currentTouch.pressed, false);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);
- if (flag)
- {
- if (UICamera.onHover != null)
- {
- UICamera.onHover(UICamera.currentTouch.current, true);
- }
- UICamera.Notify(UICamera.currentTouch.current, "OnHover", true);
- }
- UICamera.mHover = UICamera.currentTouch.current;
- if (UICamera.currentTouch.dragged == UICamera.currentTouch.current || (UICamera.currentScheme != UICamera.ControlScheme.Controller && UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.totalDelta.sqrMagnitude < num))
- {
- if (UICamera.currentTouch.pressed != UICamera.mCurrentSelection)
- {
- UICamera.mNextSelection = null;
- UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
- if (UICamera.onSelect != null)
- {
- UICamera.onSelect(UICamera.currentTouch.pressed, true);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnSelect", true);
- }
- else
- {
- UICamera.mNextSelection = null;
- UICamera.mCurrentSelection = UICamera.currentTouch.pressed;
- }
- if (UICamera.currentTouch.clickNotification != UICamera.ClickNotification.None && UICamera.currentTouch.pressed == UICamera.currentTouch.current)
- {
- float time = RealTime.time;
- if (UICamera.onClick != null)
- {
- UICamera.onClick(UICamera.currentTouch.pressed);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnClick", null);
- if (UICamera.currentTouch.clickTime + 0.35f > time)
- {
- if (UICamera.onDoubleClick != null)
- {
- UICamera.onDoubleClick(UICamera.currentTouch.pressed);
- }
- UICamera.Notify(UICamera.currentTouch.pressed, "OnDoubleClick", null);
- }
- UICamera.currentTouch.clickTime = time;
- }
- }
- else if (UICamera.currentTouch.dragStarted)
- {
- if (UICamera.onDrop != null)
- {
- UICamera.onDrop(UICamera.currentTouch.current, UICamera.currentTouch.dragged);
- }
- UICamera.Notify(UICamera.currentTouch.current, "OnDrop", UICamera.currentTouch.dragged);
- }
- }
- UICamera.currentTouch.dragStarted = false;
- UICamera.currentTouch.pressed = null;
- UICamera.currentTouch.dragged = null;
- }
- }
- public void ShowTooltip(bool val)
- {
- this.mTooltipTime = 0f;
- if (UICamera.onTooltip != null)
- {
- UICamera.onTooltip(this.mTooltip, val);
- }
- UICamera.Notify(this.mTooltip, "OnTooltip", val);
- if (!val)
- {
- this.mTooltip = null;
- }
- }
- private void OnApplicationPause()
- {
- UICamera.MouseOrTouch mouseOrTouch = UICamera.currentTouch;
- if (this.useTouch)
- {
- BetterList<int> betterList = new BetterList<int>();
- foreach (KeyValuePair<int, UICamera.MouseOrTouch> keyValuePair in UICamera.mTouches)
- {
- if (keyValuePair.Value != null && keyValuePair.Value.pressed)
- {
- UICamera.currentTouch = keyValuePair.Value;
- UICamera.currentTouchID = keyValuePair.Key;
- UICamera.currentScheme = UICamera.ControlScheme.Touch;
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
- this.ProcessTouch(false, true);
- betterList.Add(UICamera.currentTouchID);
- }
- }
- for (int i = 0; i < betterList.size; i++)
- {
- UICamera.RemoveTouch(betterList[i]);
- }
- }
- if (this.useMouse)
- {
- for (int j = 0; j < 3; j++)
- {
- if (UICamera.mMouse[j].pressed)
- {
- UICamera.currentTouch = UICamera.mMouse[j];
- UICamera.currentTouchID = -1 - j;
- UICamera.currentKey = KeyCode.Mouse0 + j;
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
- this.ProcessTouch(false, true);
- }
- }
- }
- if (this.useController && UICamera.controller.pressed)
- {
- UICamera.currentTouch = UICamera.controller;
- UICamera.currentTouchID = -100;
- UICamera.currentScheme = UICamera.ControlScheme.Controller;
- UICamera.currentTouch.last = UICamera.currentTouch.current;
- UICamera.currentTouch.current = UICamera.mCurrentSelection;
- UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
- this.ProcessTouch(false, true);
- UICamera.currentTouch.last = null;
- }
- UICamera.currentTouch = mouseOrTouch;
- }
- // Note: this type is marked as 'beforefieldinit'.
- static UICamera()
- {
- if (UICamera.<>f__mg$cache1 == null)
- {
- UICamera.<>f__mg$cache1 = new UICamera.GetKeyStateFunc(Input.GetKeyDown);
- }
- UICamera.GetKeyDown = UICamera.<>f__mg$cache1;
- if (UICamera.<>f__mg$cache2 == null)
- {
- UICamera.<>f__mg$cache2 = new UICamera.GetKeyStateFunc(Input.GetKeyUp);
- }
- UICamera.GetKeyUp = UICamera.<>f__mg$cache2;
- if (UICamera.<>f__mg$cache3 == null)
- {
- UICamera.<>f__mg$cache3 = new UICamera.GetKeyStateFunc(Input.GetKey);
- }
- UICamera.GetKey = UICamera.<>f__mg$cache3;
- if (UICamera.<>f__mg$cache4 == null)
- {
- UICamera.<>f__mg$cache4 = new UICamera.GetAxisFunc(NInput.GetAxis);
- }
- UICamera.GetAxis = UICamera.<>f__mg$cache4;
- UICamera.showTooltips = true;
- UICamera.lastTouchPosition = Vector2.zero;
- UICamera.lastWorldPosition = Vector3.zero;
- UICamera.current = null;
- UICamera.currentCamera = null;
- UICamera.currentScheme = UICamera.ControlScheme.Mouse;
- UICamera.currentTouchID = -100;
- UICamera.currentKey = KeyCode.None;
- UICamera.currentTouch = null;
- UICamera.inputHasFocus = false;
- UICamera.mCurrentSelection = null;
- UICamera.mNextSelection = null;
- UICamera.mNextScheme = UICamera.ControlScheme.Controller;
- UICamera.mMouse = new UICamera.MouseOrTouch[]
- {
- new UICamera.MouseOrTouch(),
- new UICamera.MouseOrTouch(),
- new UICamera.MouseOrTouch()
- };
- UICamera.controller = new UICamera.MouseOrTouch();
- UICamera.mNextEvent = 0f;
- UICamera.mTouches = new Dictionary<int, UICamera.MouseOrTouch>();
- UICamera.mWidth = 0;
- UICamera.mHeight = 0;
- UICamera.isDragging = false;
- UICamera.isFallThrough = false;
- UICamera.isDisableRightClick = false;
- UICamera.mHit = default(UICamera.DepthEntry);
- UICamera.mHits = new BetterList<UICamera.DepthEntry>();
- UICamera.m2DPlane = new Plane(Vector3.back, 0f);
- UICamera.mNotifying = false;
- UICamera.m_unInputEnableFlag = 0U;
- UICamera.InputEnable = true;
- UICamera.mUsingTouchEvents = true;
- }
- public static BetterList<UICamera> list = new BetterList<UICamera>();
- public static UICamera.GetKeyStateFunc GetKeyDown;
- public static UICamera.GetKeyStateFunc GetKeyUp;
- public static UICamera.GetKeyStateFunc GetKey;
- public static UICamera.GetAxisFunc GetAxis;
- public static UICamera.OnScreenResize onScreenResize;
- public UICamera.EventType eventType = UICamera.EventType.UI_3D;
- public bool eventsGoToColliders;
- public LayerMask eventReceiverMask = -1;
- public bool debug;
- public bool useMouse = true;
- public bool useTouch = true;
- public bool allowMultiTouch = true;
- public bool useKeyboard = true;
- public bool useController = true;
- public bool stickyTooltip = true;
- public float tooltipDelay = 1f;
- public float mouseDragThreshold = 4f;
- public float mouseClickThreshold = 10f;
- public float touchDragThreshold = 40f;
- public float touchClickThreshold = 40f;
- public float rangeDistance = -1f;
- public string scrollAxisName = "Mouse ScrollWheel";
- public string verticalAxisName = "Vertical";
- public string horizontalAxisName = "Horizontal";
- public KeyCode submitKey0 = KeyCode.Return;
- public KeyCode submitKey1 = KeyCode.JoystickButton0;
- public KeyCode cancelKey0 = KeyCode.Escape;
- public KeyCode cancelKey1 = KeyCode.JoystickButton1;
- public static UICamera.OnCustomInput onCustomInput;
- public static bool showTooltips;
- public static Vector2 lastTouchPosition;
- public static Vector3 lastWorldPosition;
- public static RaycastHit lastHit;
- public static UICamera current;
- public static Camera currentCamera;
- public static UICamera.ControlScheme currentScheme;
- public static int currentTouchID;
- public static KeyCode currentKey;
- public static UICamera.MouseOrTouch currentTouch;
- public static bool inputHasFocus;
- private static GameObject mGenericHandler;
- public static GameObject fallThrough;
- public static UICamera.VoidDelegate onClick;
- public static UICamera.VoidDelegate onDoubleClick;
- public static UICamera.BoolDelegate onHover;
- public static UICamera.BoolDelegate onPress;
- public static UICamera.BoolDelegate onSelect;
- public static UICamera.FloatDelegate onScroll;
- public static UICamera.VectorDelegate onDrag;
- public static UICamera.VoidDelegate onDragStart;
- public static UICamera.ObjectDelegate onDragOver;
- public static UICamera.ObjectDelegate onDragOut;
- public static UICamera.VoidDelegate onDragEnd;
- public static UICamera.ObjectDelegate onDrop;
- public static UICamera.KeyCodeDelegate onKey;
- public static UICamera.BoolDelegate onTooltip;
- public static UICamera.MoveDelegate onMouseMove;
- private static GameObject mCurrentSelection;
- private static GameObject mNextSelection;
- private static UICamera.ControlScheme mNextScheme;
- private static UICamera.MouseOrTouch[] mMouse;
- private static GameObject mHover;
- public static UICamera.MouseOrTouch controller;
- private static float mNextEvent;
- private static Dictionary<int, UICamera.MouseOrTouch> mTouches;
- private static int mWidth;
- private static int mHeight;
- private GameObject mTooltip;
- private Camera mCam;
- private float mTooltipTime;
- private float mNextRaycast;
- public static bool isDragging;
- public static GameObject hoveredObject;
- public static bool isFallThrough;
- public static bool isDisableRightClick;
- private bool m_bHover;
- private bool m_bProcessEnable = true;
- public bool VRExclusionUI;
- private Vector3[] m_vVirtualMousePos = new Vector3[2];
- private GameObject[] m_goVirtualCursor = new GameObject[2];
- private UI2DSprite[] m_spriteVirtualCursor = new UI2DSprite[2];
- private bool[] m_bVirtualDummyActive = new bool[2];
- private UICamera.VCURSOR m_eCurrentCursorSide = UICamera.VCURSOR.RIGHT;
- private static UICamera.DepthEntry mHit;
- private static BetterList<UICamera.DepthEntry> mHits;
- private static Plane m2DPlane;
- private static bool mNotifying;
- private static uint m_unInputEnableFlag;
- public static bool InputEnable;
- private const float VIRTUAL_SCREEN_SIZE_W = 1920f;
- private const float VIRTUAL_SCREEN_SIZE_H = 1080f;
- private static bool mUsingTouchEvents;
- [CompilerGenerated]
- private static BetterList<UICamera>.CompareFunc <>f__mg$cache0;
- [CompilerGenerated]
- private static UICamera.GetKeyStateFunc <>f__mg$cache1;
- [CompilerGenerated]
- private static UICamera.GetKeyStateFunc <>f__mg$cache2;
- [CompilerGenerated]
- private static UICamera.GetKeyStateFunc <>f__mg$cache3;
- [CompilerGenerated]
- private static UICamera.GetAxisFunc <>f__mg$cache4;
- public enum ControlScheme
- {
- Mouse,
- Touch,
- Controller
- }
- public enum ClickNotification
- {
- None,
- Always,
- BasedOnDelta
- }
- public class MouseOrTouch
- {
- public float deltaTime
- {
- get
- {
- return (!this.touchBegan) ? 0f : (RealTime.time - this.pressTime);
- }
- }
- public bool isOverUI
- {
- get
- {
- return this.current != null && this.current != UICamera.fallThrough && NGUITools.FindInParents<UIRoot>(this.current) != null;
- }
- }
- public Vector2 pos;
- public Vector2 lastPos;
- public Vector2 delta;
- public Vector2 totalDelta;
- public Camera pressedCam;
- public GameObject last;
- public GameObject current;
- public GameObject pressed;
- public GameObject dragged;
- public float pressTime;
- public float clickTime;
- public UICamera.ClickNotification clickNotification = UICamera.ClickNotification.Always;
- public bool touchBegan = true;
- public bool pressStarted;
- public bool dragStarted;
- }
- public enum EventType
- {
- World_3D,
- UI_3D,
- World_2D,
- UI_2D
- }
- public delegate bool GetKeyStateFunc(KeyCode key);
- public delegate float GetAxisFunc(string name);
- public delegate void OnScreenResize();
- public delegate void OnCustomInput();
- public delegate void MoveDelegate(Vector2 delta);
- public delegate void VoidDelegate(GameObject go);
- public delegate void BoolDelegate(GameObject go, bool state);
- public delegate void FloatDelegate(GameObject go, float delta);
- public delegate void VectorDelegate(GameObject go, Vector2 delta);
- public delegate void ObjectDelegate(GameObject go, GameObject obj);
- public delegate void KeyCodeDelegate(GameObject go, KeyCode key);
- public enum VCURSOR
- {
- LEFT,
- RIGHT,
- MAX
- }
- private struct DepthEntry
- {
- public int depth;
- public RaycastHit hit;
- public Vector3 point;
- public GameObject go;
- }
- public enum INPUT_CTRL_TYPE
- {
- FADE = 1,
- EDIT,
- SAVE_LOAD = 4,
- SCHEDULE = 8
- }
- }
|