UnityGame/Library/PackageCache/com.unity.visualscripting/Editor/VisualScripting.State/Flow/UnitBaseStateExtensions.cs
2024-10-27 10:53:47 +03:00

37 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace Unity.VisualScripting
{
[InitializeAfterPlugins]
public static class UnitBaseStateExtensions
{
static UnitBaseStateExtensions()
{
UnitBase.staticUnitsExtensions.Add(GetStaticOptions);
UnitBase.dynamicUnitsExtensions.Add(GetDynamicOptions);
UnitBase.contextualUnitsExtensions.Add(GetContextualOptions);
}
private static IEnumerable<IUnitOption> GetStaticOptions()
{
yield return StateUnit.WithStart().Option();
}
private static IEnumerable<IUnitOption> GetDynamicOptions()
{
var stateMacros = UnityAPI.Await(() => AssetUtility.GetAllAssetsOfType<StateGraphAsset>().ToArray());
foreach (var stateUnit in stateMacros.Select(statemacro => new StateUnit(statemacro)))
{
yield return stateUnit.Option();
}
}
private static IEnumerable<IUnitOption> GetContextualOptions(GraphReference reference)
{
yield break;
}
}
}