Toggle Is On#
UI / Interaction / Toggle / Toggle Is On
Can Read
Can Write
Description#
The Is On property of the Toggle 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("Toggle Is On")]
[Category("UI/Interaction/Toggle/Is On")]
[Description("The Is On property of the Toggle component")]
[Image(typeof(IconToggleOn), ColorTheme.Type.TextLight)]
[Keywords("UI, User, Interface, Checkbox")]
[Serializable]
public class GenTypeBool_Toggle_IsOn : TypeBool
{
[SerializeField] private GetGameObject m_Toggle = new GetGameObject(
new GenTypeGameObject_Toggle()
);
public override bool GetPreview(GameObject source)
{
GameObject instance = this.m_Toggle.GetPreview(source);
if (instance == null) return default;
Toggle component = instance.GetComponent<Toggle>();
return component != null ? component.isOn : default;
}
public override bool Get(Args args)
{
Toggle instance = this.m_Toggle.Get<Toggle>(args);
return instance != null
? instance.isOn
: default;
}
public override void Set(bool value, Args args)
{
Toggle component = this.m_Toggle.Get<Toggle>(args);
if (component != null) component.isOn = (bool) value;
}
public override string ToString()
{
return $"{this.m_Toggle} Is On";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}