Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UnityUI Joystick appear on touch

Discussion in 'UGUI & TextMesh Pro' started by Manusharian, Sep 19, 2015.

  1. Manusharian

    Manusharian

    Joined:
    Feb 22, 2014
    Posts:
    1
    Hello everyone,

    I am new in Unity world and I am facing some problems. Basically what I want to accomplish is a joystick and a button. I have already used the StandardAssets CrossPlatform example and the joystick and button works ok.

    After that I was trying to make them to appear where you have a pointer down. So at the beginning I was calling setActive to false on the joystick and button and they disappeared. After that I found out that I could not call OnPointerDown method because the object is not visible.

    I want the joystick to appear in the position where a pointer down appear and from there to work like a joystick. Also the button to appear only when the player touch and to trigger the action. At pointer up I want them to be invisible again.

    Have anyone done something like this? Can someone point out what hierarchy to use?
     
  2. felsi

    felsi

    Joined:
    Jul 3, 2013
    Posts:
    15
    Create an empty panel and attach the joystick script to it.
    Modify the script to update the position of the original image.
    Then you could enable the image in OnPointerDown and disable it in OnPointerUp