Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(CreateStruct))]
|
||||
public class CreateStructDescriptor : UnitDescriptor<CreateStruct>
|
||||
{
|
||||
public CreateStructDescriptor(CreateStruct unit) : base(unit) { }
|
||||
|
||||
protected override string DefinedTitle()
|
||||
{
|
||||
if (BoltCore.Configuration.humanNaming)
|
||||
{
|
||||
return $"Create {unit.type.HumanName()}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"new {unit.type.CSharpName()}";
|
||||
}
|
||||
}
|
||||
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
return BoltCore.Configuration.humanNaming ? "Create" : "new";
|
||||
}
|
||||
|
||||
protected override string DefinedSurtitle()
|
||||
{
|
||||
return unit.type.DisplayName();
|
||||
}
|
||||
|
||||
protected override string DefinedSummary()
|
||||
{
|
||||
return unit.type.Summary();
|
||||
}
|
||||
|
||||
protected override EditorTexture DefinedIcon()
|
||||
{
|
||||
return unit.type.Icon();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4eda0cc90c769438e8a22e872e15bf9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(CreateStruct))]
|
||||
public class CreateStructOption : UnitOption<CreateStruct>
|
||||
{
|
||||
public CreateStructOption() : base() { }
|
||||
|
||||
public CreateStructOption(CreateStruct unit) : base(unit) { }
|
||||
|
||||
public Type structType { get; private set; }
|
||||
|
||||
protected override void FillFromUnit()
|
||||
{
|
||||
structType = unit.type;
|
||||
base.FillFromUnit();
|
||||
}
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
if (human)
|
||||
{
|
||||
return $"Create {structType.HumanName()} ()";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"new {structType.CSharpName()} ()";
|
||||
}
|
||||
}
|
||||
|
||||
protected override string Haystack(bool human)
|
||||
{
|
||||
if (human)
|
||||
{
|
||||
return $"{structType.HumanName()}: Create {structType.HumanName()}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"new {structType.CSharpName()}";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SearchResultLabel(string query)
|
||||
{
|
||||
return base.SearchResultLabel(query) + " ()";
|
||||
}
|
||||
|
||||
protected override int Order()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override string FavoriteKey()
|
||||
{
|
||||
return $"{structType.FullName}@create";
|
||||
}
|
||||
|
||||
public override void Deserialize(UnitOptionRow row)
|
||||
{
|
||||
base.Deserialize(row);
|
||||
|
||||
structType = Codebase.DeserializeType(row.tag1);
|
||||
}
|
||||
|
||||
public override UnitOptionRow Serialize()
|
||||
{
|
||||
var row = base.Serialize();
|
||||
|
||||
row.tag1 = Codebase.SerializeType(structType);
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f25afcb4762e4dad98e5b628f5f7730
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(Expose))]
|
||||
public class ExposeDescriptor : UnitDescriptor<Expose>
|
||||
{
|
||||
public ExposeDescriptor(Expose unit) : base(unit) { }
|
||||
|
||||
protected override string DefinedTitle()
|
||||
{
|
||||
return $"Expose {unit.type.DisplayName()}";
|
||||
}
|
||||
|
||||
protected override string DefinedSurtitle()
|
||||
{
|
||||
return "Expose";
|
||||
}
|
||||
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
return unit.type.DisplayName();
|
||||
}
|
||||
|
||||
protected override EditorTexture DefinedIcon()
|
||||
{
|
||||
return unit.type.Icon();
|
||||
}
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
if (port is ValueOutput && unit.members.TryGetValue((ValueOutput)port, out Member member))
|
||||
{
|
||||
description.label = member.info.HumanName();
|
||||
description.summary = member.info.Summary();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 61b4830f444214043a3097b099a3bfaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(Expose))]
|
||||
public class ExposeOption : UnitOption<Expose>
|
||||
{
|
||||
public ExposeOption() : base() { }
|
||||
|
||||
public ExposeOption(Expose unit) : base(unit)
|
||||
{
|
||||
sourceScriptGuids = UnitBase.GetScriptGuids(unit.type).ToHashSet();
|
||||
}
|
||||
|
||||
public Type exposedType { get; private set; }
|
||||
|
||||
protected override string FavoriteKey()
|
||||
{
|
||||
return $"{exposedType.FullName}@expose";
|
||||
}
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
return $"Expose {unit.type.SelectedName(human)}";
|
||||
}
|
||||
|
||||
protected override bool ShowValueOutputsInFooter()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void FillFromUnit()
|
||||
{
|
||||
exposedType = unit.type;
|
||||
|
||||
base.FillFromUnit();
|
||||
}
|
||||
|
||||
public override void Deserialize(UnitOptionRow row)
|
||||
{
|
||||
base.Deserialize(row);
|
||||
|
||||
exposedType = Codebase.DeserializeType(row.tag1);
|
||||
}
|
||||
|
||||
public override UnitOptionRow Serialize()
|
||||
{
|
||||
var row = base.Serialize();
|
||||
|
||||
row.tag1 = Codebase.SerializeType(exposedType);
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e5deae2e654bb4bc086635b77b883b36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(GetMember))]
|
||||
public class GetMemberDescriptor : MemberUnitDescriptor<GetMember>
|
||||
{
|
||||
public GetMemberDescriptor(GetMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Get;
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
if (port == unit.value)
|
||||
{
|
||||
description.summary = unit.member.info.Summary();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c029e370a4c824cee82a576fb7ea9ce3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(GetMember))]
|
||||
public class GetMemberOption : MemberUnitOption<GetMember>
|
||||
{
|
||||
public GetMemberOption() : base() { }
|
||||
|
||||
public GetMemberOption(GetMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Get;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 34c129757dd604677b0cf9b116a6a788
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,77 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(InvokeMember))]
|
||||
public class InvokeMemberDescriptor : MemberUnitDescriptor<InvokeMember>
|
||||
{
|
||||
public InvokeMemberDescriptor(InvokeMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Any;
|
||||
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
if (member.isConstructor)
|
||||
{
|
||||
return BoltCore.Configuration.humanNaming ? "Create" : "new";
|
||||
}
|
||||
|
||||
return base.DefinedShortTitle();
|
||||
}
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
var documentation = member.info.Documentation();
|
||||
|
||||
if (port == unit.enter)
|
||||
{
|
||||
description.label = "Invoke";
|
||||
description.summary = "The entry point to invoke the method.";
|
||||
|
||||
if (member.isGettable)
|
||||
{
|
||||
description.summary += " You can still get the return value without connecting this port.";
|
||||
}
|
||||
}
|
||||
else if (port == unit.exit)
|
||||
{
|
||||
description.summary = "The action to call once the method has been invoked.";
|
||||
}
|
||||
else if (port == unit.result)
|
||||
{
|
||||
if (member.isGettable)
|
||||
{
|
||||
description.summary = documentation?.returns;
|
||||
}
|
||||
|
||||
if (unit.supportsChaining && unit.chainable)
|
||||
{
|
||||
description.showLabel = true;
|
||||
}
|
||||
}
|
||||
else if (port == unit.targetOutput)
|
||||
{
|
||||
if (member.isGettable)
|
||||
{
|
||||
description.showLabel = true;
|
||||
}
|
||||
}
|
||||
else if (port is ValueInput && unit.inputParameters.ContainsValue((ValueInput)port))
|
||||
{
|
||||
var parameter = member.GetParameterInfos().Single(p => "%" + p.Name == port.key);
|
||||
|
||||
description.label = parameter.DisplayName();
|
||||
description.summary = documentation?.ParameterSummary(parameter);
|
||||
}
|
||||
else if (port is ValueOutput && unit.outputParameters.ContainsValue((ValueOutput)port))
|
||||
{
|
||||
var parameter = member.GetParameterInfos().Single(p => "&" + p.Name == port.key);
|
||||
|
||||
description.label = parameter.DisplayName();
|
||||
description.summary = documentation?.ParameterSummary(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: efe957c61ae624ee2bfbcccad6c40b02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(InvokeMember))]
|
||||
public class InvokeMemberOption : MemberUnitOption<InvokeMember>
|
||||
{
|
||||
public InvokeMemberOption() : base() { }
|
||||
|
||||
public InvokeMemberOption(InvokeMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Any;
|
||||
|
||||
public override string SearchResultLabel(string query)
|
||||
{
|
||||
return base.SearchResultLabel(query) + $" ({unit.member.methodBase.DisplayParameterString(unit.member.targetType)})";
|
||||
}
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
return base.Label(human) + $" ({unit.member.methodBase.SelectedParameterString(unit.member.targetType, human)})";
|
||||
}
|
||||
|
||||
protected override string Haystack(bool human)
|
||||
{
|
||||
if (!human && member.isConstructor)
|
||||
{
|
||||
return base.Label(human);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{targetType.SelectedName(human)}{(human ? ": " : ".")}{base.Label(human)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be41f1ddb0e95454fa0e4bb3e51018d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(Literal))]
|
||||
public class LiteralDescriptor : UnitDescriptor<Literal>
|
||||
{
|
||||
public LiteralDescriptor(Literal unit) : base(unit) { }
|
||||
|
||||
protected override string DefinedTitle()
|
||||
{
|
||||
return unit.type.DisplayName() + " Literal";
|
||||
}
|
||||
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
return unit.type.DisplayName();
|
||||
}
|
||||
|
||||
protected override string DefinedSummary()
|
||||
{
|
||||
return unit.type.Summary();
|
||||
}
|
||||
|
||||
protected override EditorTexture DefinedIcon()
|
||||
{
|
||||
return unit.type.Icon();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8860fae1979174c008fe0d7a3e525089
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(Literal))]
|
||||
public sealed class LiteralInspector : Inspector
|
||||
{
|
||||
public LiteralInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
private Metadata typeMetadata => metadata[nameof(Literal.type)];
|
||||
private Metadata valueMetadata => metadata[nameof(Literal.value)];
|
||||
private Metadata typedValueMetadata => valueMetadata.Cast((Type)typeMetadata.value);
|
||||
|
||||
private bool hasType => typeMetadata.value != null;
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
if (hasType)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, typedValueMetadata, width, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, typeMetadata, width, label);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool cacheHeight => false;
|
||||
|
||||
protected override void OnGUI(Rect position, GUIContent label)
|
||||
{
|
||||
if (hasType)
|
||||
{
|
||||
LudiqGUI.Inspector(typedValueMetadata, position, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
LudiqGUI.Inspector(typeMetadata, position, label);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetAdaptiveWidth()
|
||||
{
|
||||
if (hasType)
|
||||
{
|
||||
return typedValueMetadata.Inspector().GetAdaptiveWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
return typeMetadata.Inspector().GetAdaptiveWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0de8b1e3472c14ae99456cce529e933c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(Literal))]
|
||||
public class LiteralOption : UnitOption<Literal>
|
||||
{
|
||||
public LiteralOption() : base() { }
|
||||
|
||||
public LiteralOption(Literal unit) : base(unit)
|
||||
{
|
||||
sourceScriptGuids = UnitBase.GetScriptGuids(unit.type).ToHashSet();
|
||||
}
|
||||
|
||||
public Type literalType { get; private set; }
|
||||
|
||||
protected override void FillFromUnit()
|
||||
{
|
||||
literalType = unit.type;
|
||||
base.FillFromUnit();
|
||||
}
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
if (unit.value is UnityObject uo && !uo.IsUnityNull())
|
||||
{
|
||||
return UnityAPI.Await(() => uo.name);
|
||||
}
|
||||
|
||||
return unit.type.SelectedName(human) + " Literal";
|
||||
}
|
||||
|
||||
protected override EditorTexture Icon()
|
||||
{
|
||||
if (unit.value is UnityObject uo && !uo.IsUnityNull())
|
||||
{
|
||||
return uo.Icon();
|
||||
}
|
||||
|
||||
return base.Icon();
|
||||
}
|
||||
|
||||
protected override string FavoriteKey()
|
||||
{
|
||||
return $"{literalType.FullName}@literal";
|
||||
}
|
||||
|
||||
public override void Deserialize(UnitOptionRow row)
|
||||
{
|
||||
base.Deserialize(row);
|
||||
|
||||
literalType = Codebase.DeserializeType(row.tag1);
|
||||
}
|
||||
|
||||
public override UnitOptionRow Serialize()
|
||||
{
|
||||
var row = base.Serialize();
|
||||
|
||||
row.tag1 = Codebase.SerializeType(literalType);
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d936f8125cf8482d829541d222e3f17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,56 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(Literal))]
|
||||
public sealed class LiteralWidget : UnitWidget<Literal>
|
||||
{
|
||||
public LiteralWidget(FlowCanvas canvas, Literal unit) : base(canvas, unit) { }
|
||||
|
||||
protected override bool showHeaderAddon => unit.isDefined;
|
||||
|
||||
public override bool foregroundRequiresInput => true;
|
||||
|
||||
protected override float GetHeaderAddonWidth()
|
||||
{
|
||||
var adaptiveWidthAttribute = unit.type.GetAttribute<InspectorAdaptiveWidthAttribute>();
|
||||
|
||||
return Mathf.Min(metadata.Inspector().GetAdaptiveWidth(), adaptiveWidthAttribute?.width ?? Styles.maxSettingsWidth);
|
||||
}
|
||||
|
||||
protected override float GetHeaderAddonHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(null, metadata, width, GUIContent.none);
|
||||
}
|
||||
|
||||
public override void BeforeFrame()
|
||||
{
|
||||
base.BeforeFrame();
|
||||
|
||||
if (showHeaderAddon &&
|
||||
GetHeaderAddonWidth() != headerAddonPosition.width ||
|
||||
GetHeaderAddonHeight(headerAddonPosition.width) != headerAddonPosition.height)
|
||||
{
|
||||
Reposition();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawHeaderAddon()
|
||||
{
|
||||
using (LudiqGUIUtility.labelWidth.Override(75)) // For reflected inspectors / custom property drawers
|
||||
using (Inspector.adaptiveWidth.Override(true))
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
LudiqGUI.Inspector(metadata, headerAddonPosition, GUIContent.none);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
unit.EnsureDefined();
|
||||
Reposition();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04c08655b26284f21b41bddeec3acd2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Analyser(typeof(MemberUnit))]
|
||||
public class MemberUnitAnalyser : UnitAnalyser<MemberUnit>
|
||||
{
|
||||
public MemberUnitAnalyser(GraphReference reference, MemberUnit target) : base(reference, target) { }
|
||||
|
||||
protected override IEnumerable<Warning> Warnings()
|
||||
{
|
||||
foreach (var baseWarning in base.Warnings())
|
||||
{
|
||||
yield return baseWarning;
|
||||
}
|
||||
|
||||
if (target.member != null && target.member.isReflected)
|
||||
{
|
||||
var obsoleteAttribute = target.member.info.GetAttribute<ObsoleteAttribute>();
|
||||
|
||||
if (obsoleteAttribute != null)
|
||||
{
|
||||
if (obsoleteAttribute.Message != null)
|
||||
{
|
||||
Debug.LogWarning($"\"{target.member.name}\" unit member is deprecated: {obsoleteAttribute.Message}");
|
||||
yield return Warning.Caution("Deprecated: " + obsoleteAttribute.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"\"{target.member.name}\" unit member is deprecated.");
|
||||
yield return Warning.Caution($"Member {target.member.name} is deprecated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be8bdd9b815a74b98927b0f862dfd0b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting.AssemblyQualifiedNameParser;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class MemberUnitDescriptor<TMemberUnit> : UnitDescriptor<TMemberUnit> where TMemberUnit : MemberUnit
|
||||
{
|
||||
protected MemberUnitDescriptor(TMemberUnit unit) : base(unit)
|
||||
{
|
||||
}
|
||||
|
||||
protected Member member => unit.member;
|
||||
|
||||
protected abstract ActionDirection direction { get; }
|
||||
|
||||
private string Name()
|
||||
{
|
||||
return unit.member.info.DisplayName(direction);
|
||||
}
|
||||
|
||||
protected override string DefinedTitle()
|
||||
{
|
||||
return Name();
|
||||
}
|
||||
|
||||
protected override string ErrorSurtitle(Exception exception)
|
||||
{
|
||||
if (member?.targetType != null)
|
||||
{
|
||||
return member.targetType.DisplayName();
|
||||
}
|
||||
else if (member?.targetTypeName != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var parsedName = new ParsedAssemblyQualifiedName(member.targetTypeName).TypeName.Split('.').Last();
|
||||
|
||||
if (BoltCore.Configuration.humanNaming)
|
||||
{
|
||||
return parsedName.Prettify();
|
||||
}
|
||||
else
|
||||
{
|
||||
return parsedName;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Malformed Type Name";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Missing Type";
|
||||
}
|
||||
}
|
||||
|
||||
protected override string ErrorTitle(Exception exception)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(member?.name))
|
||||
{
|
||||
if (BoltCore.Configuration.humanNaming)
|
||||
{
|
||||
return member.name.Prettify();
|
||||
}
|
||||
else
|
||||
{
|
||||
return member.name;
|
||||
}
|
||||
}
|
||||
|
||||
return base.ErrorTitle(exception);
|
||||
}
|
||||
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
return Name();
|
||||
}
|
||||
|
||||
protected override EditorTexture DefinedIcon()
|
||||
{
|
||||
return member.targetType.Icon();
|
||||
}
|
||||
|
||||
protected override EditorTexture ErrorIcon(Exception exception)
|
||||
{
|
||||
if (member.targetType != null)
|
||||
{
|
||||
return member.targetType.Icon();
|
||||
}
|
||||
|
||||
return base.ErrorIcon(exception);
|
||||
}
|
||||
|
||||
protected override string DefinedSurtitle()
|
||||
{
|
||||
return member.targetType.DisplayName();
|
||||
}
|
||||
|
||||
protected override string DefinedSummary()
|
||||
{
|
||||
return member.info.Summary();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cbba72664e24a4752a7ca4a3352735a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,130 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IMemberUnitOption : IUnitOption
|
||||
{
|
||||
Type targetType { get; }
|
||||
Member member { get; }
|
||||
Member pseudoDeclarer { get; }
|
||||
}
|
||||
|
||||
public abstract class MemberUnitOption<TMemberUnit> : UnitOption<TMemberUnit>, IMemberUnitOption where TMemberUnit : MemberUnit
|
||||
{
|
||||
protected MemberUnitOption() : base() { }
|
||||
|
||||
protected MemberUnitOption(TMemberUnit unit) : base(unit)
|
||||
{
|
||||
sourceScriptGuids = UnitBase.GetScriptGuids(unit.member.targetType).ToHashSet();
|
||||
}
|
||||
|
||||
private Member _member;
|
||||
|
||||
private Member _pseudoDeclarer;
|
||||
|
||||
public Member member
|
||||
{
|
||||
get => _member ?? unit.member;
|
||||
set => _member = value;
|
||||
}
|
||||
|
||||
public Member pseudoDeclarer
|
||||
{
|
||||
get => _pseudoDeclarer ?? member.ToPseudoDeclarer();
|
||||
set => _pseudoDeclarer = value;
|
||||
}
|
||||
|
||||
public bool isPseudoInherited => member == pseudoDeclarer;
|
||||
|
||||
protected abstract ActionDirection direction { get; }
|
||||
|
||||
public Type targetType { get; private set; }
|
||||
|
||||
protected override GUIStyle Style()
|
||||
{
|
||||
if (unit.member.isPseudoInherited)
|
||||
{
|
||||
return FuzzyWindow.Styles.optionWithIconDim;
|
||||
}
|
||||
|
||||
return base.Style();
|
||||
}
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
return unit.member.info.SelectedName(human, direction);
|
||||
}
|
||||
|
||||
protected override string FavoriteKey()
|
||||
{
|
||||
return $"{member.ToUniqueString()}@{direction.ToString().ToLower()}";
|
||||
}
|
||||
|
||||
protected override int Order()
|
||||
{
|
||||
if (member.isConstructor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return base.Order();
|
||||
}
|
||||
|
||||
protected override string Haystack(bool human)
|
||||
{
|
||||
return $"{targetType.SelectedName(human)}{(human ? ": " : ".")}{Label(human)}";
|
||||
}
|
||||
|
||||
protected override void FillFromUnit()
|
||||
{
|
||||
targetType = unit.member.targetType;
|
||||
member = unit.member;
|
||||
pseudoDeclarer = member.ToPseudoDeclarer();
|
||||
|
||||
base.FillFromUnit();
|
||||
}
|
||||
|
||||
public override void Deserialize(UnitOptionRow row)
|
||||
{
|
||||
base.Deserialize(row);
|
||||
|
||||
targetType = Codebase.DeserializeType(row.tag1);
|
||||
|
||||
if (!string.IsNullOrEmpty(row.tag2))
|
||||
{
|
||||
member = Codebase.DeserializeMember(row.tag2);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(row.tag3))
|
||||
{
|
||||
pseudoDeclarer = Codebase.DeserializeMember(row.tag3);
|
||||
}
|
||||
}
|
||||
|
||||
public override UnitOptionRow Serialize()
|
||||
{
|
||||
var row = base.Serialize();
|
||||
|
||||
row.tag1 = Codebase.SerializeType(targetType);
|
||||
row.tag2 = Codebase.SerializeMember(member);
|
||||
row.tag3 = Codebase.SerializeMember(pseudoDeclarer);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
public override void OnPopulate()
|
||||
{
|
||||
// Members are late-reflected to speed up loading and search
|
||||
// We only reflect them when we're just about to populate their node
|
||||
// By doing it in OnPopulate instead of on-demand later, we ensure
|
||||
// any error will be gracefully catched and shown as a warning by
|
||||
// the fuzzy window
|
||||
|
||||
member.EnsureReflected();
|
||||
pseudoDeclarer.EnsureReflected();
|
||||
|
||||
base.OnPopulate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 430f66f37f2454fe5988a7e2d6fa9d62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
#if PACKAGE_INPUT_SYSTEM_EXISTS
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting.InputSystem;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Analyser(typeof(OnInputSystemEvent))]
|
||||
public class OnInputSystemEventAnalyser : UnitAnalyser<OnInputSystemEvent>
|
||||
{
|
||||
public OnInputSystemEventAnalyser(GraphReference reference, OnInputSystemEvent target) : base(reference, target) {}
|
||||
|
||||
protected override IEnumerable<Warning> Warnings()
|
||||
{
|
||||
foreach (var baseWarning in base.Warnings())
|
||||
yield return baseWarning;
|
||||
|
||||
if (target.InputActionChangeType == InputActionChangeOption.OnHold ||
|
||||
target.InputActionChangeType == InputActionChangeOption.OnReleased)
|
||||
{
|
||||
if (Flow.CanPredict(target.InputAction, reference))
|
||||
{
|
||||
var inputAction = Flow.Predict<InputAction>(target.InputAction, reference);
|
||||
if (inputAction.type == InputActionType.PassThrough)
|
||||
yield return Warning.Caution($"Input action '{inputAction.name}' is of type 'Passthrough', which do not support 'On Hold' or 'On Released' events");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9727fece7d044b6181ce06541a835205
|
||||
timeCreated: 1611858574
|
|
@ -0,0 +1,30 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(SetMember))]
|
||||
public class SetMemberDescriptor : MemberUnitDescriptor<SetMember>
|
||||
{
|
||||
public SetMemberDescriptor(SetMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Set;
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
if (port == unit.assign)
|
||||
{
|
||||
description.label = "Set";
|
||||
description.summary = "The entry point to set the value.";
|
||||
}
|
||||
else if (port == unit.assigned)
|
||||
{
|
||||
description.label = "On Set";
|
||||
description.summary = "The action to call once the value has been set.";
|
||||
}
|
||||
else if (port == unit.output)
|
||||
{
|
||||
description.summary = unit.member.info.Summary();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1b3cccc8cd40a4a1f8d96eace91116a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(SetMember))]
|
||||
public class SetMemberOption : MemberUnitOption<SetMember>
|
||||
{
|
||||
public SetMemberOption() : base() { }
|
||||
|
||||
public SetMemberOption(SetMember unit) : base(unit) { }
|
||||
|
||||
protected override ActionDirection direction => ActionDirection.Set;
|
||||
|
||||
protected override bool ShowValueOutputsInFooter()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ec01c3e522a8243d49d3b709fbefa311
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue