-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REG-2194] Improved SDK UI on mobile #362
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment/conversation on when this should be applied - TLDR I want to make sure that portrait mode in the editor is still usable?
// </summary> | ||
public static bool IsMobile() | ||
{ | ||
return Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind this, but this won't solve the problem for developers making mobile games in the editor. I suppose my biggest concern is more "portrait mode" than mobile specifically (i.e. just making sure our UI is usable for vertical devices)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to assume that they're using portrait mode on mobile, but many games work in landscape mode as well.
Let's evaluate how we trigger this functionality.
You can also use the 'simulator' function in the Unity IDE to test out various tablet/phones/etc and rotate them back and forth. There are APIs for detecting said rotations and positions available.
@@ -91,6 +94,11 @@ public void Awake() | |||
|
|||
public void Start() | |||
{ | |||
if (RGUtils.IsMobile()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In relation to the comment I make at the end of this file, I suppose what I am thinking might be if (RGUtils.IsMobile() && is in portrait mode, i.e. screen height is larger than screen width)
// </summary> | ||
public static bool IsMobile() | ||
{ | ||
return Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to assume that they're using portrait mode on mobile, but many games work in landscape mode as well.
Let's evaluate how we trigger this functionality.
You can also use the 'simulator' function in the Unity IDE to test out various tablet/phones/etc and rotate them back and forth. There are APIs for detecting said rotations and positions available.
{ | ||
SetMobileView(); | ||
} | ||
else if (RGUtils.IsPortraitView()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here @addisonbgross , I think this should be an if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped a comment below that will hopefully address this comment 🤞🏻
*/ | ||
public void SetMobileView() | ||
{ | ||
GetComponent<CanvasScaler>().referenceResolution = new Vector2(800, 600); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobile does not imply portrait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still don't understand why mobile and portrait are being tied together, they aren't related
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity regarding clarity on portrait vs mobile concerns, and since the first operation of this function is identical to that of SetPortraitView, I wonder if it may be better to instead do the following:
- Rename
SetPortraitView()
to "UpscaleUI" or something just to represent the operation of making things better. - Then in this
SetMobileView()
function, you deactivate things
Not something I'm too worried about so this is a nit, but it could make things more clear wrt to the comments that Zack had
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vontell good call on the function rename, done 👍🏻
@RG-nAmKcAz the portrait and mobile connection is that I'm making it so that the UI is scaled to be larger in both scenarios. When running a build on mobile, scale the UI up (and change a few other small things). When running a game in Unity + the viewport is in a portrait orientation, scale the UI up.
The overall goal is just to make the UI a bit larger in situations where it becomes harder to use (eg: on a small screen). Hopefully I've made some sense
@vontell @RG-nAmKcAz, I've made some changes. Please let me know if these 'rules' make sense: When on mobile or using the Unity Device Simulator:
When the Unity viewport is in a portrait orientation:
I don't think we should disable anything if the game isn't running on mobile, but is in a portrait orientation. Curious to hear what you both think |
*/ | ||
public void SetMobileView() | ||
{ | ||
GetComponent<CanvasScaler>().referenceResolution = new Vector2(800, 600); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity regarding clarity on portrait vs mobile concerns, and since the first operation of this function is identical to that of SetPortraitView, I wonder if it may be better to instead do the following:
- Rename
SetPortraitView()
to "UpscaleUI" or something just to represent the operation of making things better. - Then in this
SetMobileView()
function, you deactivate things
Not something I'm too worried about so this is a nit, but it could make things more clear wrt to the comments that Zack had
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't make sense, but just merge it
Mobile does not in any way imply that my screen is in portrait layout. So having code that says.. if mobile, scale UI in a way that implies portrait wouldn't work out well
If you want to 'upscale' the UI on mobile, the code should do so in a way that explicitly maintains the current aspect ratio of the mobile device, not sets a portrait aspect ratio.
If you want to 'upscale' only when the screen layout is portrait mode, then the code should do so only when the layout is portrait mode.
@RG-nAmKcAz I see your point. I've made the scaling code more explicit, and so that it doesn't imply an incorrect aspect ratio |
In an effort to improve our demos to potential clients building mobile games, I've made the UI a bit larger when running on a mobile device. This is definitely not a comprehensive solution, but it is a small win.
What has been done
Screenshots
These were taken on my old OnePlus 7. Tested with both our Match3Example game, and the Vampire Survivors Clone I was testing out recently