Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mobile responsiveness with non-ui objects

Discussion in 'Scripting' started by Pimeko, Jul 22, 2018.

  1. Pimeko

    Pimeko

    Joined:
    Feb 4, 2017
    Posts:
    3
    Hi everyone ! :)

    I have a concern for a time now and I just don't know what is the best option. I'm currently developping a mobile game in which you can control a circle and move around on your screen by dragging your finger.
    However, I would like its size to be responsive, i.e. adapting to the screen size, getting bigger if the screen is bigger, etc.

    My logical approach is to put in inside a UI Canvas whose anchors and sizes are relative to the screen. However, it seems a bit odd to put a gameplay element inside the User Interface, I feel this is not the correct way to do it.

    I have considered applying a size by script with data such as Screen.width & Screen.height, thus letting my circle as a gameobject outside the UI, but I don't think it is the best solution. What do you think is the best thing to do ?

    Thank you very much
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Adapt your camera's orthographic size with the resolution.
     
    Doug_B likes this.
  3. Pimeko

    Pimeko

    Joined:
    Feb 4, 2017
    Posts:
    3
    Hi, thank you for your answer.

    But when I set a fixed size on my gameobject, will it resize automatically thanks to the camera ?
    For instance let's say I have my circle of 300x300px for a 720x1280 resolution. If I change the resolution to a bigger one, it will automatically change the size of the circle ?

    Thank you
     
  4. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
  5. Pimeko

    Pimeko

    Joined:
    Feb 4, 2017
    Posts:
    3
    Thank you very much, I will look into it ! :)