Screen Aspect#
Screen / Screen Aspect
Can Read
Cannot Write
Description#
The width of the game window divided by its height
Code#
using System;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Screen Aspect")]
[Category("Screen/Screen Aspect")]
[Description("The width of the game window divided by its height")]
[Image(typeof(IconAspectRatioFitter), ColorTheme.Type.Gray)]
[Keywords("Resolution", "Ratio", "Proportion", "Window", "Display", "Wide")]
[Serializable]
public class TypeNumberScreenAspect : TypeNumber
{
public override double Get(Args args)
{
int height = UnityEngine.Screen.height;
return height != 0 ? UnityEngine.Screen.width / (double) height : 0f;
}
public override string ToString()
{
return "Screen Aspect";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}