Set Screen Orientation#
Screen / Set Screen Orientation
Description#
Changes the orientation of the screen on mobile devices
Parameters#
| Name | Description |
|---|---|
| Orientation | Auto Rotation follows the device within the orientations its Autorotate settings allow |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Set Screen Orientation")]
[Category("Screen/Orientation")]
[Description("Changes the orientation of the screen on mobile devices")]
[Image(typeof(IconScreen), ColorTheme.Type.TextLight)]
[Keywords("Display", "Mobile", "Portrait", "Landscape", "Rotation", "Rotate")]
[Parameter("Orientation", "Auto Rotation follows the device within the orientations its Autorotate settings allow")]
[Serializable]
public class InstructionScreenSetOrientation : Instruction
{
[SerializeField] private ScreenOrientation m_Orientation = ScreenOrientation.AutoRotation;
protected override string GetTitle(GameObject source)
{
string className = TextUtils.ThemeAsKeyword("Screen");
string member = TextUtils.ThemeAsKeyword("Orientation");
return $"{className} {member} = {this.m_Orientation}";
}
protected override Awaitable Run(Args args)
{
Screen.orientation = this.m_Orientation;
return Done;
}
}
}