Canvas Reference Pixels Per Unit#
UI / Layout / Canvas / Canvas Reference Pixels Per Unit
Can Read
Can Write
Description#
The Reference Pixels Per Unit property of the Canvas component
Code#
// <auto-generated>
// This script was automatically generated using the Visual Script Transpiler.
// Do not modify. Changes to this file will be lost when updating the package.
// </auto-generated>
using System;
using UnityEngine;
using VisualScript.Icons;
using UnityEngine.UI;
namespace VisualScript.Runtime
{
[Get]
[Set]
[Title("Canvas Reference Pixels Per Unit")]
[Category("UI/Layout/Canvas/Reference Pixels Per Unit")]
[Description("The Reference Pixels Per Unit property of the Canvas component")]
[Image(typeof(IconCanvas), ColorTheme.Type.TextLight)]
[Keywords("UI, Layout")]
[Serializable]
public class GenTypeNumber_Canvas_ReferencePixelsPerUnit : TypeNumber
{
[SerializeField] private GetGameObject m_Canvas = new GetGameObject(
new GenTypeGameObject_Canvas()
);
public override double GetPreview(GameObject source)
{
GameObject instance = this.m_Canvas.GetPreview(source);
if (instance == null) return default;
Canvas component = instance.GetComponent<Canvas>();
return component != null ? component.referencePixelsPerUnit : default;
}
public override double Get(Args args)
{
Canvas instance = this.m_Canvas.Get<Canvas>(args);
return instance != null
? instance.referencePixelsPerUnit
: default;
}
public override void Set(double value, Args args)
{
Canvas component = this.m_Canvas.Get<Canvas>(args);
if (component != null) component.referencePixelsPerUnit = (float) value;
}
public override string ToString()
{
return $"{this.m_Canvas} Reference Pixels Per Unit";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}