简体   繁体   中英

Unity 3d Android when turn phone problems

i have 2 problems with my project.

My joystick and text (canvas items) are in wrong positions after i build my project. And items more little than before i build. (they are become small) (ps: im using anchor)

My second problem is when i turn phone, background has become black. (not all black but black sides are seems)

i will add two photo from game.

from game 1

when turn phone

I need really help for these problems.

It looks like your UI elements does not scale correctly with different screens. To solve this you can use the Canvas-Scaler .

Read it for better understanding, but in general, you have to do something like that:

  1. On your project, select your Canvas.
  2. Change the UI Scale Mode to Scale With Screen Size .
  3. Choose the Reference Resolution to your liking. I also suggest to choose Screen Match Mode of: Match Width or Height .
  4. Set the Match slider all the way to either Width or Height, depends on which one is more important on your game. From the attached images I feel like your game is based on Height, but you'll have to see what feels better for you.

The resulting settings should look something like that: IMAGE (suggested canvas settings)

Now you have to test different extreme aspect-ratios AND different resolutions. Luckily, the editor let you do it via the first tab on the Game screen: IMAGE (aspect ratio tab)

So you can adjust your canvas settings and specific UI elements accordingly. If you still have problems with a specific element, check it's Rect-Trunsform settings.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM