Checking the TV Safe Zone...

JLAlexander86JLAlexander86 Your MindPosts: 58Member
edited August 2013 in Unity on OUYA
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.
Post edited by JLAlexander86 on

Comments

  • StoicHamsterStoicHamster Posts: 113Member
    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.
    Jarcas Studios - Check out our latest Ludum Dare game: The Vengeful Baby-Men

    Take some time and learn Designer-Friendly Programming 101.
  • AyrikAyrik Posts: 429Member
    edited August 2013
    Taken directly from the OUYA documentation:

    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:

    1. Type adb shell, press Enter
      (this opens the shell prompt connected to the device)

      adb shell
      
    2. Type su, press Enter (grant super-user access to the activity manager)

      su
      
    3. 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
      
    4. 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
      
    5. Type am display-size 1920x1080, press Enter to switch to 1080p (changes the resolution back to 1080p)

      am display-size 1920x1080
      

    Post edited by Ayrik on
    Saga Heroes - Adventure RPG
    image image
  • JLAlexander86JLAlexander86 Your MindPosts: 58Member
    Yeah I got all that but I wanted to see the safe zone in Unity.

    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?
  • JLAlexander86JLAlexander86 Your MindPosts: 58Member
    I figured it out by doing this

        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.

  • AyrikAyrik Posts: 429Member
    Oh sorry I missed the Unity specifics. Thanks for posting your code.
    Saga Heroes - Adventure RPG
    image image
Sign In or Register to comment.