Is there a way to perhaps check the safe zone inside Unity? Or without a device like el gato? I ask because I have a Unity GUI element that appears when the player approaches an interactive object and that works in Unity but it doesn't appear when running on Ouya.
I'd just make a simple rectangle sprite. Center it in your screen and size it to be 90% (some would say 95%) of the width/height of your UI resolution. Then, if your GUI element goes outside that rectangle it's outside the safe zone.
This is the exact method they use when they review your game when you submit to the store.
Safe zone issues are is easy to check. In the Terminal or Command Prompt:
Type adb shell, press Enter (this opens the shell prompt connected to the device)
adb shell
Type su, press Enter (grant super-user access to the activity manager)
su
Type am start -n tv.ouya.console/tv.ouya.console.launcher.ToggleSafeZoneActivity, press Enter to toggle (toggles a green visual overlay showing the safe zone)
am start -n tv.ouya.console/tv.ouya.console.launcher.ToggleSafeZoneActivity
Type am display-size 1280x720, press Enter to switch to 720p (changes the TV display to the target resolution, if the resolution is not available emulates with a black area)
am display-size 1280x720
Type am display-size 1920x1080, press Enter to switch to 1080p (changes the resolution back to 1080p)
If
I backup 10% of 720, which i set the res to elsewhere, and then backup
the height of the image shouldn't I be well within the safe area? The prompt appears in the editor but not on the Ouya
Now I'm completely stumped... I tried centering it with
What I got was Screen.width and Screen.height were 1280x720 but my screenW and screenH were 1920x1080 so I was grabbing the width and height before my global controller called for the res change.
Comments
Take some time and learn Designer-Friendly Programming 101.
Safe zone issues are is easy to check. In the Terminal or Command Prompt:
Type adb shell, press Enter
(this opens the shell prompt connected to the device)
Type su, press Enter (grant super-user access to the activity manager)
Type am start -n tv.ouya.console/tv.ouya.console.launcher.ToggleSafeZoneActivity, press Enter to toggle (toggles a green visual overlay showing the safe zone)
Type am display-size 1280x720, press Enter to switch to 720p (changes the TV display to the target resolution, if the resolution is not available emulates with a black area)
Type am display-size 1920x1080, press Enter to switch to 1080p (changes the resolution back to 1080p)
Ok what am I missing?
using UnityEngine;
using System.Collections;
public class PickupPrompt : MonoBehaviour
{
public Transform player;
public float distancePrompt = 5;
public Texture2D button;
public string message;
float screenW = Screen.width;
float screenH = Screen.height;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
if(player)
{
float distToPlayer = Vector3.Distance(transform.position, player.transform.position);
if(distToPlayer <= distancePrompt)
{
if(button) GUI.Label(new Rect((screenW/2)-(button.width/2), (screenH-72)-(button.height+(button.height/2)), (screenW/2)+(button.width/2), (screenH-72)-(button.height/2)), button);
}
}
}
}
If I backup 10% of 720, which i set the res to elsewhere, and then backup the height of the image shouldn't I be well within the safe area?
The prompt appears in the editor but not on the Ouya
Now I'm completely stumped... I tried centering it with
if(button) GUI.Label(new Rect(screenW/2,screenH/2,screenW/2+button.width,screenH/2+button.height), button);
and in Unity it's pretty much center but on the Ouya it's in the bottom right corner of the screen?
void OnGUI()
{
if(player)
{
float distToPlayer = Vector3.Distance(transform.position, player.transform.position);
if(distToPlayer <= distancePrompt)
{
//if(button) GUI.Label(new Rect((screenW/2)-(button.width/2), (screenH-72)-(button.height+(button.height/2)), (screenW/2)+(button.width/2), (screenH-72)-(button.height/2)), button);
//if(button) GUI.Label(new Rect(screenW/2,screenH/2,screenW/2+button.width,screenH/2+button.height), button);
GUI.Label(new Rect(screenW/2,screenH/2,screenW/2+button.width,screenH/2+button.height),"screen.w "+ Screen.width + "screen.h " + Screen.height + "screenW "+ screenW + "screenH " + screenH);
/*Debug.Log(Screen.width);
Debug.Log(Screen.height);
Debug.Log(screenW);
Debug.Log(screenH);*/
}
}
}
What I got was Screen.width and Screen.height were 1280x720 but my screenW and screenH were 1920x1080 so I was grabbing the width and height before my global controller called for the res change.