示例#1
0
 void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
 {
     if (this.hasFinger || !this.allowMouseControl && TouchJoystickExample.IsMousePointerId(eventData.get_pointerId()))
     {
         return;
     }
     this.hasFinger    = true;
     this.lastFingerId = eventData.get_pointerId();
 }
 private void Initialize()
 {
     ReInput.EditorRecompileEvent += new Action(this.OnEditorRecompile);
     if (SystemInfo.deviceType == DeviceType.Handheld)
     {
         this.allowMouseControl = false;
     }
     this.gui = base.GetComponent <GUITexture>();
     if (this.gui.texture == null)
     {
         Debug.LogError("TouchJoystick object requires a valid texture!");
         base.gameObject.SetActive(false);
         return;
     }
     if (!TouchJoystickExample.enumeratedTouchJoysticks)
     {
         try
         {
             TouchJoystickExample[] array = (TouchJoystickExample[])UnityEngine.Object.FindObjectsOfType(typeof(TouchJoystickExample));
             TouchJoystickExample.joysticks = new List <TouchJoystickExample>(array.Length);
             TouchJoystickExample[] array2 = array;
             for (int i = 0; i < array2.Length; i++)
             {
                 TouchJoystickExample item = array2[i];
                 TouchJoystickExample.joysticks.Add(item);
             }
             TouchJoystickExample.enumeratedTouchJoysticks = true;
         }
         catch (Exception ex)
         {
             Debug.LogError("Error collecting TouchJoystick objects: " + ex.Message);
             throw;
         }
     }
     this.origPixelInset        = this.gui.pixelInset;
     this.origTransformPosition = base.transform.position;
     this.RefreshPosition();
     this.initialized = true;
 }
示例#3
0
 void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
 {
     if (eventData.get_pointerId() != this.lastFingerId || !this.allowMouseControl && TouchJoystickExample.IsMousePointerId(eventData.get_pointerId()))
     {
         return;
     }
     this.Restart();
 }