first commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(201)]
|
||||
public abstract class Absolute<TInput> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The value to make positive.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueInput input { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The positive value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput output { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
input = ValueInput<TInput>(nameof(input));
|
||||
output = ValueOutput(nameof(output), Operation).Predictable();
|
||||
|
||||
Requirement(input, output);
|
||||
}
|
||||
|
||||
protected abstract TInput Operation(TInput input);
|
||||
|
||||
public TInput Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<TInput>(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77c25c2bc8cf0466b9bc9b3abff5d11b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(101)]
|
||||
public abstract class Add<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sum of A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A + B")]
|
||||
public ValueOutput sum { get; private set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultB => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput(nameof(b), defaultB);
|
||||
|
||||
sum = ValueOutput(nameof(sum), Operation).Predictable();
|
||||
|
||||
Requirement(a, sum);
|
||||
Requirement(b, sum);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e690d92c6a6094c218b950b910edb21a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(403)]
|
||||
public abstract class Angle<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The angle between A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput angle { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput<T>(nameof(b));
|
||||
angle = ValueOutput(nameof(angle), Operation).Predictable();
|
||||
|
||||
Requirement(a, angle);
|
||||
Requirement(b, angle);
|
||||
}
|
||||
|
||||
private float Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract float Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7bc539a4cf334d588b5c72b9e3831ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(304)]
|
||||
public abstract class Average<T> : MultiInputUnit<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The average.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput average { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
|
||||
average = ValueOutput(nameof(average), Operation).Predictable();
|
||||
|
||||
foreach (var multiInput in multiInputs)
|
||||
{
|
||||
Requirement(multiInput, average);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
public abstract T Operation(IEnumerable<T> values);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
if (inputCount == 2)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(multiInputs[0]), flow.GetValue<T>(multiInputs[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Operation(multiInputs.Select(flow.GetValue<T>));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56b542bbc53e849d48aaa938b56cad94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(405)]
|
||||
[TypeIcon(typeof(Multiply<>))]
|
||||
public abstract class CrossProduct<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The cross product of A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A \u00D7 B")]
|
||||
public ValueOutput crossProduct { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput<T>(nameof(b));
|
||||
crossProduct = ValueOutput(nameof(crossProduct), Operation).Predictable();
|
||||
|
||||
Requirement(a, crossProduct);
|
||||
Requirement(b, crossProduct);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbb8929676d4f4af093f06971d7cc051
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(402)]
|
||||
public abstract class Distance<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The distance between A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput distance { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput<T>(nameof(b));
|
||||
distance = ValueOutput(nameof(distance), Operation).Predictable();
|
||||
|
||||
Requirement(a, distance);
|
||||
Requirement(b, distance);
|
||||
}
|
||||
|
||||
private float Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract float Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 715413cdba8ac4cec8843061e37e032f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(104)]
|
||||
public abstract class Divide<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The dividend (or numerator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A")]
|
||||
public ValueInput dividend { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The divisor (or denominator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("B")]
|
||||
public ValueInput divisor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The quotient of the dividend and divisor (numerator / denominator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A \u00F7 B")]
|
||||
public ValueOutput quotient { get; private set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultDivisor => default(T);
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultDividend => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
dividend = ValueInput(nameof(dividend), defaultDividend);
|
||||
divisor = ValueInput(nameof(divisor), defaultDivisor);
|
||||
quotient = ValueOutput(nameof(quotient), Operation).Predictable();
|
||||
|
||||
Requirement(dividend, quotient);
|
||||
Requirement(divisor, quotient);
|
||||
}
|
||||
|
||||
public abstract T Operation(T divident, T divisor);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(dividend), flow.GetValue<T>(divisor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19e33d0193ab84820855fc989cb9d7eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(404)]
|
||||
public abstract class DotProduct<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The dot product of A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A\u2219B")]
|
||||
public ValueOutput dotProduct { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput<T>(nameof(b));
|
||||
dotProduct = ValueOutput(nameof(dotProduct), Operation).Predictable();
|
||||
|
||||
Requirement(a, dotProduct);
|
||||
Requirement(b, dotProduct);
|
||||
}
|
||||
|
||||
private float Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract float Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d0aa9041a7ab49c7a011932cbf111ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea27efbe8c1b4ede9eda4df7f6c3898
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the sum of two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Add")]
|
||||
[RenamedFrom("Bolt.GenericAdd")]
|
||||
[RenamedFrom("Unity.VisualScripting.GenericAdd")]
|
||||
[Obsolete("Use the new \"Add (Math/Generic)\" node instead.")]
|
||||
public sealed class DeprecatedGenericAdd : Add<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Add(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 499a8bf0618a245dab78d3dc2d0dceca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the quotient of two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Divide")]
|
||||
public sealed class GenericDivide : Divide<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Divide(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b03b4b42811a4d7e9bc0818ec219441
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the remainder of the division of two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Modulo")]
|
||||
public sealed class GenericModulo : Modulo<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Modulo(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0c6067d02e96482bb3220423798537c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the product of two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Multiply")]
|
||||
public sealed class GenericMultiply : Multiply<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Multiply(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c0466a3f6c794ba99744554b7540055
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the difference between two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Subtract")]
|
||||
public sealed class GenericSubtract : Subtract<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Subtract(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 094b4f8978345452997167b2f818dc47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the sum of two objects.
|
||||
/// </summary>
|
||||
[UnitCategory("Math/Generic")]
|
||||
[UnitTitle("Add")]
|
||||
public sealed class GenericSum : Sum<object>
|
||||
{
|
||||
public override object Operation(object a, object b)
|
||||
{
|
||||
return OperatorUtility.Add(a, b);
|
||||
}
|
||||
|
||||
public override object Operation(IEnumerable<object> values)
|
||||
{
|
||||
var valueList = values.ToList();
|
||||
var result = OperatorUtility.Add(valueList[0], valueList[1]);
|
||||
|
||||
for (int i = 2; i < valueList.Count; i++)
|
||||
{
|
||||
result = OperatorUtility.Add(result, valueList[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3508507419da443f94b1446800b20db9
|
||||
timeCreated: 1604500592
|
||||
@@ -0,0 +1,56 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(501)]
|
||||
public abstract class Lerp<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The interpolation value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput t { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The linear interpolation between A and B at T.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput interpolation { get; private set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultA => default(T);
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultB => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput(nameof(a), defaultA);
|
||||
b = ValueInput(nameof(b), defaultB);
|
||||
t = ValueInput<float>(nameof(t), 0);
|
||||
interpolation = ValueOutput(nameof(interpolation), Operation).Predictable();
|
||||
|
||||
Requirement(a, interpolation);
|
||||
Requirement(b, interpolation);
|
||||
Requirement(t, interpolation);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b), flow.GetValue<float>(t));
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b, float t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e93461aec6b434e33b8f3b1ce909f94f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(302)]
|
||||
public abstract class Maximum<T> : MultiInputUnit<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput maximum { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
|
||||
maximum = ValueOutput(nameof(maximum), Operation).Predictable();
|
||||
|
||||
foreach (var multiInput in multiInputs)
|
||||
{
|
||||
Requirement(multiInput, maximum);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
public abstract T Operation(IEnumerable<T> values);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
if (inputCount == 2)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(multiInputs[0]), flow.GetValue<T>(multiInputs[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Operation(multiInputs.Select(flow.GetValue<T>));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32dca6adb07ad4626be264766bb6bb52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(301)]
|
||||
public abstract class Minimum<T> : MultiInputUnit<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput minimum { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
|
||||
minimum = ValueOutput(nameof(minimum), Operation).Predictable();
|
||||
|
||||
foreach (var multiInput in multiInputs)
|
||||
{
|
||||
Requirement(multiInput, minimum);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
public abstract T Operation(IEnumerable<T> values);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
if (inputCount == 2)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(multiInputs[0]), flow.GetValue<T>(multiInputs[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Operation(multiInputs.Select(flow.GetValue<T>));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38e5d402f42bb4c47ab7cca54454af7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(105)]
|
||||
public abstract class Modulo<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The dividend (or numerator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A")]
|
||||
public ValueInput dividend { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The divisor (or denominator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("B")]
|
||||
public ValueInput divisor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The remainder of the division of dividend and divison (numerator / denominator).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A % B")]
|
||||
public ValueOutput remainder { get; private set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultDivisor => default(T);
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultDividend => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
dividend = ValueInput(nameof(dividend), defaultDividend);
|
||||
divisor = ValueInput(nameof(divisor), defaultDivisor);
|
||||
remainder = ValueOutput(nameof(remainder), Operation).Predictable();
|
||||
|
||||
Requirement(dividend, remainder);
|
||||
Requirement(divisor, remainder);
|
||||
}
|
||||
|
||||
public abstract T Operation(T divident, T divisor);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(dividend), flow.GetValue<T>(divisor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20232477594504d2ebc0ad8288de4d5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(502)]
|
||||
public abstract class MoveTowards<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The current value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The target value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput target { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum scalar increment between values.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput maxDelta { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The incremented value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput result { get; private set; }
|
||||
|
||||
[Serialize, Inspectable, UnitHeaderInspectable("Per Second"), InspectorToggleLeft]
|
||||
public bool perSecond { get; set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultCurrent => default(T);
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultTarget => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
current = ValueInput(nameof(current), defaultCurrent);
|
||||
target = ValueInput(nameof(target), defaultTarget);
|
||||
maxDelta = ValueInput<float>(nameof(maxDelta), 0);
|
||||
result = ValueOutput(nameof(result), Operation);
|
||||
|
||||
Requirement(current, result);
|
||||
Requirement(target, result);
|
||||
Requirement(maxDelta, result);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(current), flow.GetValue<T>(target), flow.GetValue<float>(maxDelta) * (perSecond ? Time.deltaTime : 1));
|
||||
}
|
||||
|
||||
public abstract T Operation(T current, T target, float maxDelta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b821313717eb047e5a54728b020594af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(103)]
|
||||
public abstract class Multiply<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The first value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The second value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The product of A and B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabel("A \u00D7 B")]
|
||||
public ValueOutput product { get; private set; }
|
||||
|
||||
[DoNotSerialize]
|
||||
protected virtual T defaultB => default(T);
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput(nameof(b), defaultB);
|
||||
product = ValueOutput(nameof(product), Operation).Predictable();
|
||||
|
||||
Requirement(a, product);
|
||||
Requirement(b, product);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c0792cd863dd4234ba2e204dc4a83e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(401)]
|
||||
public abstract class Normalize<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector to normalize.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueInput input { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The normalized vector.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput output { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
input = ValueInput<T>(nameof(input));
|
||||
output = ValueOutput(nameof(output), Operation).Predictable();
|
||||
|
||||
Requirement(input, output);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(input));
|
||||
}
|
||||
|
||||
public abstract T Operation(T input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10429c7f27ad94c7cb1499b5a5163207
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(601)]
|
||||
public abstract class PerSecond<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The input value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueInput input { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The framerate-normalized value (multiplied by delta time).
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput output { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
input = ValueInput(nameof(input), default(T));
|
||||
output = ValueOutput(nameof(output), Operation);
|
||||
|
||||
Requirement(input, output);
|
||||
}
|
||||
|
||||
public abstract T Operation(T input);
|
||||
|
||||
public T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 380330ce527bc45faaec6132f11b2fe6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(406)]
|
||||
public abstract class Project<T> : Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector to project.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput a { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The vector on which to project.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
public ValueInput b { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The projection of A on B.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput projection { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
a = ValueInput<T>(nameof(a));
|
||||
b = ValueInput<T>(nameof(b));
|
||||
projection = ValueOutput(nameof(projection), Operation).Predictable();
|
||||
|
||||
Requirement(a, projection);
|
||||
Requirement(b, projection);
|
||||
}
|
||||
|
||||
private T Operation(Flow flow)
|
||||
{
|
||||
return Operation(flow.GetValue<T>(a), flow.GetValue<T>(b));
|
||||
}
|
||||
|
||||
public abstract T Operation(T a, T b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 534413c3fdaa04b5597bcb93bde48b49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[UnitOrder(202)]
|
||||
public abstract class Round<TInput, TOutput> : Unit
|
||||
{
|
||||
public enum Rounding
|
||||
{
|
||||
Floor = 0,
|
||||
Ceiling = 1,
|
||||
AwayFromZero = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rounding mode.
|
||||
/// </summary>
|
||||
[Inspectable, UnitHeaderInspectable, Serialize]
|
||||
public Rounding rounding { get; set; } = Rounding.AwayFromZero;
|
||||
|
||||
/// <summary>
|
||||
/// The value to round.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueInput input { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The rounded value.
|
||||
/// </summary>
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ValueOutput output { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
input = ValueInput<TInput>(nameof(input));
|
||||
output = ValueOutput(nameof(output), Operation).Predictable();
|
||||
|
||||
Requirement(input, output);
|
||||
}
|
||||
|
||||
protected abstract TOutput Floor(TInput input);
|
||||
protected abstract TOutput AwayFromZero(TInput input);
|
||||
protected abstract TOutput Ceiling(TInput input);
|
||||
|
||||
public TOutput Operation(Flow flow)
|
||||
{
|
||||
switch (rounding)
|
||||
{
|
||||
case Rounding.Floor:
|
||||
return Floor(flow.GetValue<TInput>(input));
|
||||
case Rounding.AwayFromZero:
|
||||
return AwayFromZero(flow.GetValue<TInput>(input));
|
||||
case Rounding.Ceiling:
|
||||
return Ceiling(flow.GetValue<TInput>(input));
|
||||
default:
|
||||
throw new UnexpectedEnumValueException<Rounding>(rounding);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce9bcdc8594234a6b81f4f195a2664de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f38e841c0fbf340d2a3cc021bf487c71
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user