Search Unity

Question Canvas and UI button and item

Discussion in 'UGUI & TextMesh Pro' started by PlayerCasual, Mar 26, 2023.

  1. PlayerCasual

    PlayerCasual

    Joined:
    Jan 3, 2023
    Posts:
    274
    Hello everyone!!! I finally finished my game but I notice that when I run the build and install on my smartphone.. all the dimensions and positions of what I have created in the canvas are offset... some images are bigger... some others are more attached to the border and so on... what can i do to solve the problem ??? a solution that I found but very annoying is to create a single panel in the canvas and inside it many small panels so the objects remain where I put them and with the desired dimensions ... my question is... is this solution right??? because it's really annoying and long... aren't there different ways to do this??? because when you enter the editor everything is there where I want it to be and the size I ask for but on the smartphone it's a whole other story thanks to all in advance
     
  2. Filopuk

    Filopuk

    Joined:
    Jul 24, 2015
    Posts:
    10
    Hi! Did you check if the smartphone resolution works well with your UI inside the editor?

    From what you've provided, it seems the issue might be with the anchoring. Can you, please, provide some screenshots presenting the UI elements you've writing about?
     
    PlayerCasual likes this.
  3. PlayerCasual

    PlayerCasual

    Joined:
    Jan 3, 2023
    Posts:
    274
    how can i check or set if the resolution of the smartphone works well with my interface?? where should i go to see?? Could you tell me the path please? I'm new to unity and I don't know many things.. what you say interests me a lot and I would be really grateful if you explain how to do it.... yes it's an anchoring problem even if I can't explain it because I did everything as explained in a tutorial...
     
  4. Filopuk

    Filopuk

    Joined:
    Jul 24, 2015
    Posts:
    10
    No worries :) I don't know what version of Unity you use, but I assume the flow should be the same or similar. First, in the Game window click on the Game button with an arrow down, and switch mode to Simulator. Then, in the next button to the right from that, you will be able to choose between simulated devices. You are even able to add more devices if you need, but I haven't done that before, so I can't help you with that. However, this view mode will help you test out your UI without building it or installing on different smartphones.

    UnityCamera.png

    And in the case of UI anchoring - please, send a screenshot of at least one UI element that needs to be fixed, so I can give a more precise answer. If the issue is what I am guessing, however, you'll just need to click on the UI element, then click on the anchoring presets icon, choose to which side of the screen should the element be anchored, and set its position the way you want.

    UnityCamera2.png
     
    PlayerCasual likes this.
  5. PlayerCasual

    PlayerCasual

    Joined:
    Jan 3, 2023
    Posts:
    274
    oh... absurd... I didn't know about this simulation function... thank you very much... I seem to have solved it ... but I was forced to create a panel that takes up the whole screen and then I created various child panels of that panel and anchored them to the parent panel ... but it seems to me a stupid practice
     
  6. Filopuk

    Filopuk

    Joined:
    Jul 24, 2015
    Posts:
    10
    You can anchor any UI element to the canvas itself, so it was not really necessary to create such panels to do that (I am not sure if I understood you correctly). I personally like having my UI organized into different whole-screen panels, but I understand it might be tedious to set that up. Nonetheless, I am happy the issue is solved, good luck with you game! :)
     
    PlayerCasual likes this.
  7. PlayerCasual

    PlayerCasual

    Joined:
    Jan 3, 2023
    Posts:
    274
    yea you have understund 1 panel whit other panel inside like children
    tnk again for you big help!!