Reflect Direction#
Math / Reflect Direction
Can Read
Cannot Write
Description#
Reflects a direction onto a surface defined by a normal direction
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Reflect Direction")]
[Category("Math/Reflect Direction")]
[Description("Reflects a direction onto a surface defined by a normal direction")]
[Image(typeof(IconReflect), ColorTheme.Type.Yellow)]
[Keywords("Vector", "Bounce")]
[Serializable]
public class TypeVector2MathReflectDirection : TypeVector2
{
[SerializeField] private GetVector2 m_InDirection = new GetVector2();
[SerializeField] private GetVector2 m_InNormal = new GetVector2();
public override Vector2 GetPreview(GameObject source) =>
Vector2.Reflect(
this.m_InDirection.GetPreview(source),
this.m_InNormal.GetPreview(source)
);
public override Vector2 Get(Args args)
{
return Vector2.Reflect(
this.m_InDirection.Get(args),
this.m_InNormal.Get(args)
);
}
public override string ToString()
{
return $"Reflect {this.m_InDirection} on {this.m_InNormal}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}