Transform Local Scale Z#
Transform / Transform Local Scale Z
Can Read
Can Write
Description#
The Local Scale Z component of Transform component
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get, Set]
[Title("Transform Local Scale Z")]
[Category("Transform/Local Scale Z")]
[Description("The Local Scale Z component of Transform component")]
[Image(typeof(IconScale), ColorTheme.Type.Lime, typeof(BadgeZ))]
[Keywords("World", "Global", "Location", "Translate")]
[Serializable]
public class TypeNumberTransformLocalScaleZ : TypeNumber
{
[SerializeField] private GetGameObject m_Transform = new GetGameObject(
new GenTypeGameObject_Transform()
);
public override double Get(Args args)
{
Transform transform = this.m_Transform.Get<Transform>(args);
return transform != null ? transform.localScale.z : 0;
}
public override void Set(double value, Args args)
{
Transform transform = this.m_Transform.Get<Transform>(args);
if (transform != null)
{
Vector3 scale =new Vector3(
transform.localScale.x,
transform.localScale.y,
(float) value
);
transform.position = scale;
}
}
public override string ToString()
{
return $"{this.m_Transform} Local Scale.z";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}