Search Unity

Make the cursor stay on the selected objects

Discussion in 'Scripting' started by fuhans1992, Jul 25, 2014.

  1. fuhans1992

    fuhans1992

    Joined:
    Jul 25, 2014
    Posts:
    4
    Hi guys, I don't know if the title wrong as I don't know how to describe my question, so I leave it like that.

    Anyway, I want to ask a question regarding the mouse cursor selection objects like what you found in many games in console, such as PlayStation 1, etc.

    What I mean is for example when the main menu selection in the game appear, we won't see the cursor and the cursor stay on the left side of the selection menu, when we press down arrow on the console, the cursor move also, but of course I want this on the computer and not in the console. To be more detail on my question, I have made the GIF Image using Photoshop.

    Animated-Cursor.gif

    As you can see in the above image, the cursor is move down from the "new game" to the "load game" and so on, the cursor will moving down when we press down the down arrow on the keyboard and when the cursor stay either on the "new game", "load game", "options", or "exit" and user press enter, it will respond to where the cursor pointed to, and when it reach the "exit", and user press down arrow, the cursor will move to the "new game"

    How do I can achieve this?

    Thank you very much!

    Your answer will be much appreciated.
     
  2. Hunter_W

    Hunter_W

    Joined:
    May 5, 2014
    Posts:
    57
    When you create the collider for the button, make it span the screen width. Then you could create a custom invisible cursor. This is how I would do it.

    The GIF was very helpful :)


    -> For the arrow keys just cycle through an array to select boxes.

    -> For the moving arrow on the left, translate a sprite down to each box when selected.
    or
    Create a new texture for each button with the arrow and cycle through.
    or
    Create the texture for only arrow and make it appear as you select the buttons.
     
    Last edited: Jul 25, 2014
  3. fuhans1992

    fuhans1992

    Joined:
    Jul 25, 2014
    Posts:
    4
    Thank you for your answer :) And thanks also for commenting the GIF :D
     
  4. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Screen.showCursor = false;

    Will hide the mouse then just havecode that'd move the arrow and button based on key presses