You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

60 lines
1.8 KiB

using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UnityEditor.VFX.Operator
{
[VFXHelpURL("Operator-Pi")]
[VFXInfo(name = "Pi (π)", category = "Math/Constants")]
class Pi : VFXOperator
{
public override string name
{
get
{
int nbLinkedSlots = outputSlots.Count(o => o.HasLink());
if (nbLinkedSlots == 1)
{
if (GetOutputSlot(0).HasLink())
return "Pi (π)";
else if (GetOutputSlot(1).HasLink())
return "Pi (2π)";
else if (GetOutputSlot(2).HasLink())
return "Pi (π/2)";
else
return "Pi (π/3)";
}
return "Pi (π)";
}
}
public class OutputProperties
{
public float Pi = Mathf.PI;
}
protected override IEnumerable<VFXPropertyWithValue> outputProperties
{
get
{
yield return new VFXPropertyWithValue(new VFXProperty(typeof(float), "π"));
yield return new VFXPropertyWithValue(new VFXProperty(typeof(float), "2π"));
yield return new VFXPropertyWithValue(new VFXProperty(typeof(float), "π/2"));
yield return new VFXPropertyWithValue(new VFXProperty(typeof(float), "π/3"));
}
}
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
{
return new[]
{
VFXValue.Constant(Mathf.PI),
VFXValue.Constant(2 * Mathf.PI),
VFXValue.Constant(Mathf.PI / 2.0f),
VFXValue.Constant(Mathf.PI / 3.0f)
};
}
}
}