Initial Commit

This commit is contained in:
Sebastian Cabrera 2021-08-02 05:44:37 -04:00
parent 53eb92e9af
commit 270ab7d11f
15341 changed files with 700234 additions and 0 deletions

View file

@ -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));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77c25c2bc8cf0466b9bc9b3abff5d11b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e690d92c6a6094c218b950b910edb21a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e7bc539a4cf334d588b5c72b9e3831ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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>));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56b542bbc53e849d48aaa938b56cad94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbb8929676d4f4af093f06971d7cc051
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 715413cdba8ac4cec8843061e37e032f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19e33d0193ab84820855fc989cb9d7eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9d0aa9041a7ab49c7a011932cbf111ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ea27efbe8c1b4ede9eda4df7f6c3898
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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)\" unit instead.")]
public sealed class DeprecatedGenericAdd : Add<object>
{
public override object Operation(object a, object b)
{
return OperatorUtility.Add(a, b);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 499a8bf0618a245dab78d3dc2d0dceca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b03b4b42811a4d7e9bc0818ec219441
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0c6067d02e96482bb3220423798537c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c0466a3f6c794ba99744554b7540055
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 094b4f8978345452997167b2f818dc47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3508507419da443f94b1446800b20db9
timeCreated: 1604500592

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e93461aec6b434e33b8f3b1ce909f94f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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>));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 32dca6adb07ad4626be264766bb6bb52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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>));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38e5d402f42bb4c47ab7cca54454af7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20232477594504d2ebc0ad8288de4d5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b821313717eb047e5a54728b020594af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c0792cd863dd4234ba2e204dc4a83e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10429c7f27ad94c7cb1499b5a5163207
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 380330ce527bc45faaec6132f11b2fe6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 534413c3fdaa04b5597bcb93bde48b49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce9bcdc8594234a6b81f4f195a2664de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f38e841c0fbf340d2a3cc021bf487c71
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
using System;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the sum of two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Add")]
[Obsolete("Use the new \"Add (Math/Scalar)\" unit instead.")]
[RenamedFrom("Bolt.ScalarAdd")]
[RenamedFrom("Unity.VisualScripting.ScalarAdd")]
public sealed class DeprecatedScalarAdd : Add<float>
{
protected override float defaultB => 1;
public override float Operation(float a, float b)
{
return a + b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5dfc14c2e992e43ab996bc6415e0c134
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the positive version of a scalar.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Absolute")]
public sealed class ScalarAbsolute : Absolute<float>
{
protected override float Operation(float input)
{
return Mathf.Abs(input);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ccc4ef618cff4b65a07621143c39af9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.Linq;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the average of two or more scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Average")]
public sealed class ScalarAverage : Average<float>
{
public override float Operation(float a, float b)
{
return (a + b) / 2;
}
public override float Operation(IEnumerable<float> values)
{
return values.Average();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d68c0c38421ef4911ad6c52c05bf17c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the quotient of two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Divide")]
public sealed class ScalarDivide : Divide<float>
{
protected override float defaultDividend => 1;
protected override float defaultDivisor => 1;
public override float Operation(float a, float b)
{
return a / b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8afb399e26dbf4318878d7f4d660027b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,49 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the power of a base and exponent.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Exponentiate")]
[UnitOrder(105)]
public sealed class ScalarExponentiate : Unit
{
/// <summary>
/// The base.
/// </summary>
[DoNotSerialize]
[PortLabel("x")]
public ValueInput @base { get; private set; }
/// <summary>
/// The exponent.
/// </summary>
[DoNotSerialize]
[PortLabel("n")]
public ValueInput exponent { get; private set; }
/// <summary>
/// The power of base elevated to exponent.
/// </summary>
[DoNotSerialize]
[PortLabel("x\u207f")]
public ValueOutput power { get; private set; }
protected override void Definition()
{
@base = ValueInput<float>(nameof(@base), 1);
exponent = ValueInput<float>(nameof(exponent), 2);
power = ValueOutput(nameof(power), Exponentiate);
Requirement(@base, power);
Requirement(exponent, power);
}
public float Exponentiate(Flow flow)
{
return Mathf.Pow(flow.GetValue<float>(@base), flow.GetValue<float>(exponent));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9321123edcf304431887764ab0a6c652
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the linear interpolation between two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Lerp")]
public sealed class ScalarLerp : Lerp<float>
{
protected override float defaultA => 0;
protected override float defaultB => 1;
public override float Operation(float a, float b, float t)
{
return Mathf.Lerp(a, b, t);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d5e230c21f924802bd348a531a85633
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the maximum between two or more scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Maximum")]
public sealed class ScalarMaximum : Maximum<float>
{
public override float Operation(float a, float b)
{
return Mathf.Max(a, b);
}
public override float Operation(IEnumerable<float> values)
{
return values.Max();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3403f9e0addcf4a4d902c0fc3596e7f1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the minimum between two or more scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Minimum")]
public sealed class ScalarMinimum : Minimum<float>
{
public override float Operation(float a, float b)
{
return Mathf.Min(a, b);
}
public override float Operation(IEnumerable<float> values)
{
return values.Min();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9541b23dd8d1d46db9fe9a8d0741ffbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the remainder of the division of two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Modulo")]
public sealed class ScalarModulo : Modulo<float>
{
protected override float defaultDividend => 1;
protected override float defaultDivisor => 1;
public override float Operation(float a, float b)
{
return a % b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3b8e59920a774b3d89b873db0df5ae7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Moves a scalar towards a target.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Move Towards")]
public sealed class ScalarMoveTowards : MoveTowards<float>
{
protected override float defaultCurrent => 0;
protected override float defaultTarget => 1;
public override float Operation(float current, float target, float maxDelta)
{
return Mathf.MoveTowards(current, target, maxDelta);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b4c4e23f5b364a6b80e705ce14c8c4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the product of two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Multiply")]
public sealed class ScalarMultiply : Multiply<float>
{
protected override float defaultB => 1;
public override float Operation(float a, float b)
{
return a * b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76ab6eba2ae2f4239ae83f4cda348612
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the unit length version of a scalar.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Normalize")]
public sealed class ScalarNormalize : Normalize<float>
{
public override float Operation(float input)
{
if (input == 0)
{
return 0;
}
return input / Mathf.Abs(input);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0389410f80e484d5c91978c69536d70e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the framerate-normalized value of a scalar.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Per Second")]
public sealed class ScalarPerSecond : PerSecond<float>
{
public override float Operation(float input)
{
return input * Time.deltaTime;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c1309dd586a34490bf26bf206287b55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,59 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the root at the nth degree of a radicand.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Root")]
[UnitOrder(106)]
public sealed class ScalarRoot : Unit
{
/// <summary>
/// The radicand.
/// </summary>
[DoNotSerialize]
[PortLabel("x")]
public ValueInput radicand { get; private set; }
/// <summary>
/// The degree.
/// </summary>
[DoNotSerialize]
[PortLabel("n")]
public ValueInput degree { get; private set; }
/// <summary>
/// The nth degree root of the radicand.
/// </summary>
[DoNotSerialize]
[PortLabel("\u207f\u221ax")]
public ValueOutput root { get; private set; }
protected override void Definition()
{
radicand = ValueInput<float>(nameof(radicand), 1);
degree = ValueInput<float>(nameof(degree), 2);
root = ValueOutput(nameof(root), Root);
Requirement(radicand, root);
Requirement(degree, root);
}
public float Root(Flow flow)
{
var degree = flow.GetValue<float>(this.degree);
var radicand = flow.GetValue<float>(this.radicand);
if (degree == 2)
{
return Mathf.Sqrt(radicand);
}
else
{
return Mathf.Pow(radicand, 1 / degree);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97770e956456b4837b3d7a2da35f8c23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Rounds a decimal number to return an integer.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Round")]
public sealed class ScalarRound : Round<float, int>
{
protected override int Floor(float input)
{
return Mathf.FloorToInt(input);
}
protected override int AwayFromZero(float input)
{
return Mathf.RoundToInt(input);
}
protected override int Ceiling(float input)
{
return Mathf.CeilToInt(input);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c2edba0ea7a04509b020c73dd56f326
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the difference between two scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Subtract")]
public sealed class ScalarSubtract : Subtract<float>
{
protected override float defaultMinuend => 1;
protected override float defaultSubtrahend => 1;
public override float Operation(float a, float b)
{
return a - b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c67283f54d58842718fdf793bb6a248e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Linq;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the sum of two or more scalars.
/// </summary>
[UnitCategory("Math/Scalar")]
[UnitTitle("Add")]
public sealed class ScalarSum : Sum<float>, IDefaultValue<float>
{
[DoNotSerialize]
public float defaultValue => 1;
public override float Operation(float a, float b)
{
return a + b;
}
public override float Operation(IEnumerable<float> values)
{
return values.Sum();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 09aa72850f12b4933886240b826b65a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,50 @@
namespace Unity.VisualScripting
{
[UnitOrder(102)]
public abstract class Subtract<T> : Unit
{
/// <summary>
/// The first value (minuend).
/// </summary>
[DoNotSerialize]
[PortLabel("A")]
public ValueInput minuend { get; private set; }
/// <summary>
/// The second value (subtrahend).
/// </summary>
[DoNotSerialize]
[PortLabel("B")]
public ValueInput subtrahend { get; private set; }
/// <summary>
/// The difference, that is the minuend minus the subtrahend.
/// </summary>
[DoNotSerialize]
[PortLabel("A \u2212 B")]
public ValueOutput difference { get; private set; }
[DoNotSerialize]
protected virtual T defaultMinuend => default(T);
[DoNotSerialize]
protected virtual T defaultSubtrahend => default(T);
protected override void Definition()
{
minuend = ValueInput(nameof(minuend), defaultMinuend);
subtrahend = ValueInput(nameof(subtrahend), defaultSubtrahend);
difference = ValueOutput(nameof(difference), Operation).Predictable();
Requirement(minuend, difference);
Requirement(subtrahend, difference);
}
public abstract T Operation(T a, T b);
public T Operation(Flow flow)
{
return Operation(flow.GetValue<T>(minuend), flow.GetValue<T>(subtrahend));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1efe947ef683942f98e532c233dfa9d3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,64 @@
using System.Collections.Generic;
using System.Linq;
namespace Unity.VisualScripting
{
[UnitOrder(303)]
[TypeIcon(typeof(Add<>))]
public abstract class Sum<T> : MultiInputUnit<T>
{
/// <summary>
/// The sum.
/// </summary>
[DoNotSerialize]
[PortLabelHidden]
public ValueOutput sum { get; private set; }
protected override void Definition()
{
if (this is IDefaultValue<T> defaultValueUnit)
{
var mi = new List<ValueInput>();
multiInputs = mi.AsReadOnly();
for (var i = 0; i < inputCount; i++)
{
if (i == 0)
{
mi.Add(ValueInput<T>(i.ToString()));
continue;
}
mi.Add(ValueInput(i.ToString(), defaultValueUnit.defaultValue));
}
}
else
{
base.Definition();
}
sum = ValueOutput(nameof(sum), Operation).Predictable();
foreach (var multiInput in multiInputs)
{
Requirement(multiInput, sum);
}
}
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>));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94caeea3697674618a0f62b74280e958
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50e5988621f6449898f4d88ce6841c21
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
using System;
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the sum of two 2D vectors.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Add")]
[Obsolete("Use the new \"Add (Math/Vector 2)\" unit instead.")]
[RenamedFrom("Bolt.Vector2Add")]
[RenamedFrom("Unity.VisualScripting.Vector2Add")]
public sealed class DeprecatedVector2Add : Add<Vector2>
{
protected override Vector2 defaultB => Vector2.zero;
public override Vector2 Operation(Vector2 a, Vector2 b)
{
return a + b;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 089121cc9f7ea42359753ca5889e821b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns a version of a 2D vector where each component is positive.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Absolute")]
public sealed class Vector2Absolute : Absolute<Vector2>
{
protected override Vector2 Operation(Vector2 input)
{
return new Vector2(Mathf.Abs(input.x), Mathf.Abs(input.y));
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a63848f6acf1473999d0e77199c1b71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,15 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the angle between two 2D vectors in degrees.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Angle")]
public sealed class Vector2Angle : Angle<UnityEngine.Vector2>
{
public override float Operation(UnityEngine.Vector2 a, UnityEngine.Vector2 b)
{
return UnityEngine.Vector2.Angle(a, b);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d891cfa0b12b34cc0ac9f9ec7d0f3352
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,32 @@
using System.Collections.Generic;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the average of two or more 2D vectors.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Average")]
public sealed class Vector2Average : Average<UnityEngine.Vector2>
{
public override UnityEngine.Vector2 Operation(UnityEngine.Vector2 a, UnityEngine.Vector2 b)
{
return (a + b) / 2;
}
public override UnityEngine.Vector2 Operation(IEnumerable<UnityEngine.Vector2> values)
{
var average = UnityEngine.Vector2.zero;
var count = 0;
foreach (var value in values)
{
average += value;
count++;
}
average /= count;
return average;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86918d705343f47b1b9d0248715e933d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,15 @@
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the distance between two 2D vectors.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Distance")]
public sealed class Vector2Distance : Distance<UnityEngine.Vector2>
{
public override float Operation(UnityEngine.Vector2 a, UnityEngine.Vector2 b)
{
return UnityEngine.Vector2.Distance(a, b);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77d96d89dd9e24f1fb646f095bea5cda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,25 @@
using UnityEngine;
namespace Unity.VisualScripting
{
/// <summary>
/// Returns the component-wise quotient of two 2D vectors.
/// </summary>
[UnitCategory("Math/Vector 2")]
[UnitTitle("Divide")]
public sealed class Vector2Divide : Divide<Vector2>
{
protected override Vector2 defaultDividend => Vector2.zero;
protected override Vector2 defaultDivisor => Vector2.zero;
public override Vector2 Operation(Vector2 a, Vector2 b)
{
return new Vector2
(
a.x / b.x,
a.y / b.y
);
}
}
}

Some files were not shown because too many files have changed in this diff Show more