Author Topic: Not Support Samsung S-Pen Plugins?  (Read 11140 times)

Grauw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #15 on: September 04, 2014, 04:09:19 AM »
Our solution which is simple and looks like it works well so far:

  1.         UICamera: Support mouse (pen) on devices.
  2.  
  3.         We tweak NGUI so that in stead of disabling mouse on device,
  4.         it gets a way to disambiguate native from touch-emulated mouse events.
  5.  
  6. ==== NGUI/Scripts/UI/UICamera.cs#12 (text) ====
  7.  
  8. @@ -721,8 +721,9 @@
  9.                 if (Application.platform == RuntimePlatform.Android ||
  10.                         Application.platform == RuntimePlatform.IPhonePlayer)
  11.                 {
  12. -                       useMouse = false;
  13. -                       useTouch = true;
  14. +                       // A method to disambiguate touch / mouse was added to ProcessMouse()
  15. +                       //useMouse = false;
  16. +                       //useTouch = true;
  17.  
  18.                         if (Application.platform == RuntimePlatform.IPhonePlayer
  19. )
  20.                         {
  21. @@ -845,6 +846,10 @@
  22.  
  23.         public void ProcessMouse ()
  24.         {
  25. +               // Disambiguate touch events which are emulating mouse
  26. +               if (Input.touchCount > 0)
  27. +                       return;
  28. +
  29.                 bool updateRaycast = (useMouse && Time.timeScale < 0.9f);
  30.  
  31.                 if (!updateRaycast)
  32.  

WeslomPo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #16 on: January 17, 2017, 02:58:28 AM »
For fix it new NGUI. In UICamera you need to change line:
  1. if (currentScheme == ControlScheme.Touch) return;
On this, and s-pen start working as expected:
  1. if (currentScheme == ControlScheme.Touch && Input.touchCount > 0) return;
You can test it with OTG cable and mouse connected to your tablet/phone.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #17 on: January 18, 2017, 09:15:09 AM »
If anything, it should be:
  1. if (currentScheme == ControlScheme.Touch && activeTouches.Count > 0) return;