Search Unity

Android Cursor enable

Discussion in 'Scripting' started by lyn2010xu, Dec 29, 2016.

  1. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    How can i show my cursor on android build? I want show a cursor on my touched point, but neither i create a Gameobject or call GUI.Drawtexture that the texture can not be exactly on my touched point, when i move my finger very fast, so i need cursor... Help... :(

    I called Cursor.SetCursor, it work well on win build, but not on my android build...
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Android doesn't have a built-in cursor (unless you plug in a mouse). I don't understand why you would want a cursor though, but moving a gui image is your best bet
     
  3. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    Thx.
    I used the GUI image, but the problem is, when i move my finger very very fast, the image is slower than my finger, that can not be endured in my game, because i need show a “jet” under my finger exactly, no delay for one frame. GUI DrawTexture or set a gameobject position will always delay so they could not do this.
    Forgive my poor english.
     
  4. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    Why do you even want to have a cursor in Android at all?
     
  5. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    I need show a texture on the point which my finger touched, i used "this.gameobject.posion = Camera.main.screentoworldpos" and "GUI.drawTexture(Camera.screentoviewpoint)" but they all delay for one frame(maybe 2 or 3 or more...), it is not that correctly to my game, as a player, they all could find the texture move slower than his/her finger, and in my game, the texture must always follow the finger, otherwise it would not have a good experience.
    Is there any other solutions to take this?
     
  6. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    I'm not asking how you want the cursor to be rendered, but what you need the cursor for at all. Mobile touch screen devices should not have a cursor at all since a cursor is a hinderance to a touch interface. The user's finger is the cursor in the context of a touch screen device. So I ask again, why do you want a cursor in Android at all?
     
  7. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    Thx.
    I do not must have a cursor, but i must solve this problem that the image i rendered move slower than user's finger.
    I create a ui image gameobjct in my game, and call "this.gameobject.posion = Camera.main.screentoworldpos", the game object moves slower than my finger.
    I found in pc, if i use cursor, i can show that image exactly under my finger, so i ask how can i show cursor on android...
     
  8. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    You can't
    The reason:
    In a mobile device the movement is limited to the fps count, and because it's not infinite (actually it's quite low) it wont ever reach the speed you move your finger at
    This problem exist in the computer too, but because the cursor is already late compared to the mouse (just test it, you'll see), you wont see the image lag behind
     
  9. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    Thx.
    What does " the cursor is already late compared to the mouse" mean? I dont care about the system draw mouse move slower than the hardware mouse, but if i used cursor, i see( use a human eye) the image i want render is clearly at the system mouse on the screen and i have a good experience to no feel of a image lag behind. That is my purpose.
    If cursor can not be used, is there any other solutions to take this problem???
     
  10. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    I mean, that compared to you moving the hardware mouse, the system mouse lags, this is why you see "more than one mice" if you move it fast enough back and forth
     
  11. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    That's not due to a mouse lag, mouse pointer is drawn (if you don't have any extra option enabled) one time per frame, so if you see it twice or ghost pointers is due to your human eye retention and/or bad screen performance.
     
  12. lyn2010xu

    lyn2010xu

    Joined:
    May 21, 2015
    Posts:
    6
    So, is there any other solutions to take this problem??? I just want no image lag behind when i move my finger fast~~
    And i see a game in appstore did this, i think there is a solution. :(
     
  13. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    if you are using a movetowards of some sort to move your image towards the touch position, then the "lag" you experience is due to the move to. Maybe you can circumvent this by making the move amount so fast it's close to instantaneous, although there would be no point of using the movetowards anymore.

    If you are simply teleporting the object and there is this "lag", and assuming the hardware can bear the brunt, then issue is most likely in the order of executions in your update loop.
    1) calculating position and then drawing the image
    2) drawing the image then calculating position
    If you are doing 2, then switching them around might solve our issue.
     
  14. Davon_Allen_AofL

    Davon_Allen_AofL

    Joined:
    Jul 17, 2019
    Posts:
    9
    so as a requirement i must use a mouse cursor within a zone of influence within an app on a chrome book or device using a mouse cursor, it doesn't matter where so long as a cursor is present, is there a solution there?