Ejemplo n.º 1
0
 /// <summary>
 /// Sets the current <seealso cref="AllowedOrientation"/>s mask, this does not force it to a valid orientation.
 /// <para/>
 /// Use <seealso cref="SetAllowedOrientation(AllowedOrientation,ScreenOrientation)"/> to
 /// force a change in the orientation.
 /// </summary>
 /// <param name="allowedAutoOrientations"> New mask of <seealso cref="AllowedOrientation"/>. </param>
 public static void SetAllowedOrientation(AllowedOrientation allowedOrientations)
 {
     if (Instance)
     {
         Instance.allowedOrientations_ = allowedOrientations;
         Instance.UpdateAutoRotationSettings();
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Generates the <seealso cref="AllowedOrientation"/>s from the player settings in the editor.
    /// </summary>
    protected new void Awake()
    {
        base.Awake();

        if (Screen.autorotateToPortrait)
        {
            allowedOrientations_ = allowedOrientations_ | AllowedOrientation.kPortrait;
        }
        if (Screen.autorotateToPortraitUpsideDown)
        {
            allowedOrientations_ = allowedOrientations_ | AllowedOrientation.kPortraitUpsideDown;
        }
        if (Screen.autorotateToLandscapeLeft)
        {
            allowedOrientations_ = allowedOrientations_ | AllowedOrientation.kLandscapeLeft;
        }
        if (Screen.autorotateToLandscapeRight)
        {
            allowedOrientations_ = allowedOrientations_ | AllowedOrientation.kLandscapeRight;
        }

        UpdateAutoRotationSettings();
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Checks if the passed in orientation is set in the <seealso cref="allowedOrientations_"/> mask.
 /// </summary>
 /// <param name="allowedOrientation"> The orientation to check is set. </param>
 /// <returns> True if it is set in the mask. </returns>
 private bool IsOrientationAllowed(AllowedOrientation allowedOrientation)
 {
     return((allowedOrientations_ & allowedOrientation) != 0);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the current <seealso cref="AllowedOrientation"/>s mask, and forces it to a specified orientation.
 /// <para/>
 /// Worth noting that when auto-rotate is off on the device, <seealso cref="ScreenOrientation.PortraitUpsideDown"/>
 /// will only allow Portrait, but when they re-enable auto-rotate it will jump to upside down, best
 /// setting newOrientation to standard Landscape or Portrait.
 /// </summary>
 /// <param name="allowedAutoOrientations"> New mask of <seealso cref="AllowedOrientation"/>s. </param>
 /// <param name="newOrientation"> Orientation the device will be forced to</param>
 public static void SetAllowedOrientation(AllowedOrientation allowedOrientations, ScreenOrientation newOrientation)
 {
     Screen.orientation = newOrientation;
     SetAllowedOrientation(allowedOrientations);
 }