Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Analyser(typeof(GraphInput))]
|
||||
public class GraphInputAnalyser : UnitAnalyser<GraphInput>
|
||||
{
|
||||
public GraphInputAnalyser(GraphReference reference, GraphInput unit) : base(reference, unit) { }
|
||||
|
||||
protected override IEnumerable<Warning> Warnings()
|
||||
{
|
||||
foreach (var baseWarning in base.Warnings())
|
||||
{
|
||||
yield return baseWarning;
|
||||
}
|
||||
|
||||
if (unit.graph != null)
|
||||
{
|
||||
foreach (var definitionWarning in UnitPortDefinitionUtility.Warnings(unit.graph, LinqUtility.Concat<IUnitPortDefinition>(unit.graph.controlInputDefinitions, unit.graph.valueInputDefinitions)))
|
||||
{
|
||||
yield return definitionWarning;
|
||||
}
|
||||
|
||||
var inputs = unit.graph.units.Where(u => u is GraphInput).ToList();
|
||||
if (inputs.Count > 1)
|
||||
{
|
||||
var firstInput = inputs[0];
|
||||
if (unit != firstInput)
|
||||
{
|
||||
var graphName = string.IsNullOrEmpty(unit.graph.title) ? nameof(SuperUnit) : unit.graph.title;
|
||||
Debug.LogWarning($"Only one Input node can be used and will execute in {graphName}.");
|
||||
yield return Warning.Caution("Only one Input node can be used and will execute.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d1c94c4f2d57434e9cbca40368ff9b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(GraphInput))]
|
||||
public class GraphInputDescriptor : UnitDescriptor<GraphInput>
|
||||
{
|
||||
public GraphInputDescriptor(GraphInput unit) : base(unit) { }
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
var definition = unit.graph.validPortDefinitions.OfType<IUnitInputPortDefinition>().SingleOrDefault(d => d.key == port.key);
|
||||
|
||||
if (definition != null)
|
||||
{
|
||||
description.label = definition.Label();
|
||||
description.summary = definition.summary;
|
||||
|
||||
if (definition.hideLabel)
|
||||
{
|
||||
description.showLabel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 251904176641146fbb7d16cbe72dbe9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,64 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(GraphInput))]
|
||||
public class GraphInputInspector : Inspector
|
||||
{
|
||||
public GraphInputInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
private Metadata graphMetadata => metadata[nameof(GraphInput.graph)];
|
||||
private Metadata controlInputDefinitionsMetadata => graphMetadata[nameof(FlowGraph.controlInputDefinitions)];
|
||||
private Metadata valueInputDefinitionsMetadata => graphMetadata[nameof(FlowGraph.valueInputDefinitions)];
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
var height = 0f;
|
||||
|
||||
if (graphMetadata.value != null)
|
||||
{
|
||||
height += GetControlInputDefinitionsHeight(width);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetValueInputDefinitionsHeight(width);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected override void OnGUI(Rect position, GUIContent label)
|
||||
{
|
||||
BeginLabeledBlock(metadata, position, label);
|
||||
|
||||
if (graphMetadata.value != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
LudiqGUI.Inspector(controlInputDefinitionsMetadata, position.VerticalSection(ref y, GetControlInputDefinitionsHeight(position.width)));
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
LudiqGUI.Inspector(valueInputDefinitionsMetadata, position.VerticalSection(ref y, GetValueInputDefinitionsHeight(position.width)));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
((FlowGraph)graphMetadata.value).PortDefinitionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
EndBlock(metadata);
|
||||
}
|
||||
|
||||
private float GetControlInputDefinitionsHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, controlInputDefinitionsMetadata, width);
|
||||
}
|
||||
|
||||
private float GetValueInputDefinitionsHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, valueInputDefinitionsMetadata, width);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 61620174ad6604a7cbe0f211462830eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(GraphInput))]
|
||||
public sealed class GraphInputWidget : UnitWidget<GraphInput>
|
||||
{
|
||||
public GraphInputWidget(FlowCanvas canvas, GraphInput unit) : base(canvas, unit) { }
|
||||
|
||||
protected override NodeColorMix baseColor => NodeColorMix.TealReadable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4707fa01fbb6d42e8a05d7d7f83d784f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Analyser(typeof(GraphOutput))]
|
||||
public class GraphOutputAnalyser : UnitAnalyser<GraphOutput>
|
||||
{
|
||||
public GraphOutputAnalyser(GraphReference reference, GraphOutput unit) : base(reference, unit) { }
|
||||
|
||||
protected override IEnumerable<Warning> Warnings()
|
||||
{
|
||||
foreach (var baseWarning in base.Warnings())
|
||||
{
|
||||
yield return baseWarning;
|
||||
}
|
||||
|
||||
if (unit.graph != null)
|
||||
{
|
||||
foreach (var definitionWarning in UnitPortDefinitionUtility.Warnings(unit.graph, LinqUtility.Concat<IUnitPortDefinition>(unit.graph.controlOutputDefinitions, unit.graph.valueOutputDefinitions)))
|
||||
{
|
||||
yield return definitionWarning;
|
||||
}
|
||||
|
||||
if (unit.graph.units.Count(unit => unit is GraphOutput) > 1)
|
||||
{
|
||||
yield return Warning.Caution("Multiple output units in the same graph. Only one of them will be used.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2f934162d2811436eb7a824dfc58a1f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(GraphOutput))]
|
||||
public class GraphOutputDescriptor : UnitDescriptor<GraphOutput>
|
||||
{
|
||||
public GraphOutputDescriptor(GraphOutput unit) : base(unit) { }
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
var definition = unit.graph.validPortDefinitions.OfType<IUnitOutputPortDefinition>().SingleOrDefault(d => d.key == port.key);
|
||||
|
||||
if (definition != null)
|
||||
{
|
||||
description.label = definition.Label();
|
||||
description.summary = definition.summary;
|
||||
|
||||
if (definition.hideLabel)
|
||||
{
|
||||
description.showLabel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 35060e71290cc46ada12a7b97ed06d3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,64 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(GraphOutput))]
|
||||
public class GraphOutputInspector : Inspector
|
||||
{
|
||||
public GraphOutputInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
private Metadata graphMetadata => metadata[nameof(GraphOutput.graph)];
|
||||
private Metadata controlOutputDefinitionsMetadata => graphMetadata[nameof(FlowGraph.controlOutputDefinitions)];
|
||||
private Metadata valueOutputDefinitionsMetadata => graphMetadata[nameof(FlowGraph.valueOutputDefinitions)];
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
var height = 0f;
|
||||
|
||||
if (graphMetadata.value != null)
|
||||
{
|
||||
height += GetControlOutputDefinitionsHeight(width);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetValueOutputDefinitionsHeight(width);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected override void OnGUI(Rect position, GUIContent label)
|
||||
{
|
||||
BeginLabeledBlock(metadata, position, label);
|
||||
|
||||
if (graphMetadata.value != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
LudiqGUI.Inspector(controlOutputDefinitionsMetadata, position.VerticalSection(ref y, GetControlOutputDefinitionsHeight(position.width)));
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
LudiqGUI.Inspector(valueOutputDefinitionsMetadata, position.VerticalSection(ref y, GetValueOutputDefinitionsHeight(position.width)));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
((FlowGraph)graphMetadata.value).PortDefinitionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
EndBlock(metadata);
|
||||
}
|
||||
|
||||
private float GetControlOutputDefinitionsHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, controlOutputDefinitionsMetadata, width);
|
||||
}
|
||||
|
||||
private float GetValueOutputDefinitionsHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, valueOutputDefinitionsMetadata, width);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f131db2d7d34b49aa8a8f3325a83b788
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(GraphOutput))]
|
||||
public sealed class GraphOutputWidget : UnitWidget<GraphOutput>
|
||||
{
|
||||
public GraphOutputWidget(FlowCanvas canvas, GraphOutput unit) : base(canvas, unit) { }
|
||||
|
||||
protected override NodeColorMix baseColor => NodeColorMix.TealReadable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e3b945fe4958447ea2acee2fc137913
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Analyser(typeof(INesterUnit))]
|
||||
public class NesterUnitAnalyser<TNesterUnit> : UnitAnalyser<TNesterUnit> where TNesterUnit : class, INesterUnit
|
||||
{
|
||||
public NesterUnitAnalyser(GraphReference reference, TNesterUnit unit) : base(reference, unit) { }
|
||||
|
||||
protected override IEnumerable<Warning> Warnings()
|
||||
{
|
||||
foreach (var baseWarning in base.Warnings())
|
||||
{
|
||||
yield return baseWarning;
|
||||
}
|
||||
|
||||
if (unit.childGraph == null)
|
||||
{
|
||||
yield return Warning.Caution("Missing nested graph.");
|
||||
}
|
||||
|
||||
if (unit.nest.hasBackgroundEmbed)
|
||||
{
|
||||
yield return Warning.Caution("Background embed graph detected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd31a53fc9e90411694cadcde26058bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
|||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(INesterUnit))]
|
||||
public class NesterUnitDescriptor<TNesterUnit> : UnitDescriptor<TNesterUnit> where TNesterUnit : class, INesterUnit
|
||||
{
|
||||
public NesterUnitDescriptor(TNesterUnit unit) : base(unit) { }
|
||||
|
||||
[RequiresUnityAPI]
|
||||
protected override string DefinedTitle()
|
||||
{
|
||||
return GraphNesterDescriptor.Title(unit);
|
||||
}
|
||||
|
||||
[RequiresUnityAPI]
|
||||
protected override string DefinedSummary()
|
||||
{
|
||||
return GraphNesterDescriptor.Summary(unit);
|
||||
}
|
||||
|
||||
[RequiresUnityAPI]
|
||||
protected override string DefinedShortTitle()
|
||||
{
|
||||
return DefinedTitle();
|
||||
}
|
||||
|
||||
[RequiresUnityAPI]
|
||||
protected override string DefinedSurtitle()
|
||||
{
|
||||
var hasCurrentTitle = !StringUtility.IsNullOrWhiteSpace(unit.nest.graph?.title);
|
||||
var hasMacroTitle = unit.nest.source == GraphSource.Macro && (UnityObject)unit.nest.macro != null;
|
||||
|
||||
if (hasCurrentTitle || hasMacroTitle)
|
||||
{
|
||||
return unit.GetType().HumanName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4aa4ecc37c1a147c1b3658b615afb89a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,30 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Editor(typeof(INesterUnit))]
|
||||
public class NesterUnitEditor : UnitEditor
|
||||
{
|
||||
public NesterUnitEditor(Metadata metadata) : base(metadata) { }
|
||||
|
||||
private Metadata nestMetadata => metadata[nameof(INesterUnit.nest)];
|
||||
|
||||
private Metadata graphMetadata => nestMetadata[nameof(IGraphNest.graph)];
|
||||
|
||||
protected override GraphReference headerReference => reference.ChildReference((INesterUnit)metadata.value, false);
|
||||
|
||||
protected override Metadata headerTitleMetadata => graphMetadata[nameof(IGraph.title)];
|
||||
|
||||
protected override Metadata headerSummaryMetadata => graphMetadata[nameof(IGraph.summary)];
|
||||
|
||||
protected override float GetInspectorHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetEditorHeight(this, nestMetadata, width);
|
||||
}
|
||||
|
||||
protected override void OnInspectorGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Editor(nestMetadata, position);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cd9648444f40f4191982915f5289e6cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,32 @@
|
|||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[FuzzyOption(typeof(INesterUnit))]
|
||||
public class NesterUnitOption<TNesterUnit> : UnitOption<TNesterUnit> where TNesterUnit : INesterUnit
|
||||
{
|
||||
public NesterUnitOption() : base() { }
|
||||
|
||||
public NesterUnitOption(TNesterUnit unit) : base(unit) { }
|
||||
|
||||
// TODO: Favoritable
|
||||
public override bool favoritable => false;
|
||||
|
||||
protected override string Label(bool human)
|
||||
{
|
||||
return UnityAPI.Await(() =>
|
||||
{
|
||||
var macro = (UnityObject)unit.nest.macro;
|
||||
|
||||
if (macro != null)
|
||||
{
|
||||
return macro.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return unit.GetType().HumanName();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 03ffbe4749f4844648417d734d61d520
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class NestrerUnitWidget<TNesterUnit> : UnitWidget<TNesterUnit>
|
||||
where TNesterUnit : class, INesterUnit
|
||||
{
|
||||
public NestrerUnitWidget(FlowCanvas canvas, TNesterUnit unit) : base(canvas, unit) { }
|
||||
|
||||
protected override IEnumerable<DropdownOption> contextOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var childReference = reference.ChildReference(unit, false);
|
||||
|
||||
if (childReference != null)
|
||||
{
|
||||
yield return new DropdownOption((Action)(() => window.reference = childReference), "Open");
|
||||
yield return new DropdownOption((Action)(() => GraphWindow.OpenTab(childReference)), "Open in new window");
|
||||
}
|
||||
|
||||
foreach (var baseOption in base.contextOptions)
|
||||
{
|
||||
yield return baseOption;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDoubleClick()
|
||||
{
|
||||
if (unit.graph.zoom == 1)
|
||||
{
|
||||
var childReference = reference.ChildReference(unit, false);
|
||||
|
||||
if (childReference != null)
|
||||
{
|
||||
if (e.ctrlOrCmd)
|
||||
{
|
||||
GraphWindow.OpenTab(childReference);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.reference = childReference;
|
||||
}
|
||||
}
|
||||
|
||||
e.Use();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnDoubleClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40cd897821b754ed3b0e71afcd581880
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,33 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Descriptor(typeof(SuperUnit))]
|
||||
public class SuperUnitDescriptor : NesterUnitDescriptor<SuperUnit>
|
||||
{
|
||||
public SuperUnitDescriptor(SuperUnit unit) : base(unit) { }
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
|
||||
if (unit.graph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var definition = unit.nest.graph.validPortDefinitions.SingleOrDefault(d => d.key == port.key);
|
||||
|
||||
if (definition != null)
|
||||
{
|
||||
description.label = definition.Label();
|
||||
description.summary = definition.summary;
|
||||
|
||||
if (definition.hideLabel)
|
||||
{
|
||||
description.showLabel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57f04d6aac04849df90d9b081e8fe3ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Editor(typeof(SuperUnit))]
|
||||
public sealed class SuperUnitEditor : NesterUnitEditor
|
||||
{
|
||||
public SuperUnitEditor(Metadata metadata) : base(metadata) { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24609a202855c4946af787a77c0ace57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(SuperUnit))]
|
||||
public class SuperUnitWidget : NestrerUnitWidget<SuperUnit>, IDragAndDropHandler
|
||||
{
|
||||
public SuperUnitWidget(FlowCanvas canvas, SuperUnit unit) : base(canvas, unit) { }
|
||||
|
||||
protected override NodeColorMix baseColor
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: Move to descriptor for optimization
|
||||
using (var recursion = Recursion.New(1))
|
||||
{
|
||||
if (unit.nest.graph?.GetUnitsRecursive(recursion).OfType<IEventUnit>().Any() ?? false)
|
||||
{
|
||||
return NodeColor.Green;
|
||||
}
|
||||
}
|
||||
|
||||
return base.baseColor;
|
||||
}
|
||||
}
|
||||
|
||||
public DragAndDropVisualMode dragAndDropVisualMode => DragAndDropVisualMode.Generic;
|
||||
|
||||
public bool AcceptsDragAndDrop()
|
||||
{
|
||||
return DragAndDropUtility.Is<ScriptGraphAsset>() && FlowDragAndDropUtility.AcceptsScript(graph);
|
||||
}
|
||||
|
||||
public void PerformDragAndDrop()
|
||||
{
|
||||
UndoUtility.RecordEditedObject("Drag & Drop Macro");
|
||||
unit.nest.source = GraphSource.Macro;
|
||||
unit.nest.macro = DragAndDropUtility.Get<ScriptGraphAsset>();
|
||||
unit.nest.embed = null;
|
||||
unit.Define();
|
||||
GUI.changed = true;
|
||||
}
|
||||
|
||||
public void UpdateDragAndDrop()
|
||||
{
|
||||
}
|
||||
|
||||
public void DrawDragAndDropPreview()
|
||||
{
|
||||
GraphGUI.DrawDragAndDropPreviewLabel(new Vector2(edgePosition.x, outerPosition.yMax), "Replace with: " + DragAndDropUtility.Get<ScriptGraphAsset>().name, typeof(ScriptGraphAsset).Icon());
|
||||
}
|
||||
|
||||
public void ExitDragAndDrop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: faeb5868684234ccd9a36b3e2a589e93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class UnitPortDefinitionUtility
|
||||
{
|
||||
public static string Label(this IUnitPortDefinition definition)
|
||||
{
|
||||
return StringUtility.FallbackWhitespace(definition.label, definition.key?.Filter(symbols: false, punctuation: false).Prettify() ?? "?");
|
||||
}
|
||||
|
||||
public static IEnumerable<Warning> Warnings(FlowGraph graph, IEnumerable<IUnitPortDefinition> definitions = null)
|
||||
{
|
||||
if (definitions == null)
|
||||
{
|
||||
definitions = LinqUtility.Concat<IUnitPortDefinition>(graph.controlInputDefinitions,
|
||||
graph.controlOutputDefinitions,
|
||||
graph.valueInputDefinitions,
|
||||
graph.valueOutputDefinitions);
|
||||
}
|
||||
|
||||
var hasDuplicate = definitions.DistinctBy(d => d.key).Count() != definitions.Count();
|
||||
|
||||
if (hasDuplicate)
|
||||
{
|
||||
yield return Warning.Caution("Some port definitions with non-unique keys are currently ignored.");
|
||||
}
|
||||
|
||||
foreach (var definition in definitions)
|
||||
{
|
||||
if (!definition.isValid)
|
||||
{
|
||||
yield return InvalidWarning(definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Warning InvalidWarning(IUnitPortDefinition definition)
|
||||
{
|
||||
if (!StringUtility.IsNullOrWhiteSpace(definition.label))
|
||||
{
|
||||
return Warning.Caution($"{definition.GetType().HumanName().ToLower().FirstCharacterToUpper()} '{definition.label}' is not properly configured and is currently ignored.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Warning.Caution($"A {definition.GetType().HumanName().ToLower()} with incomplete configuration is currently ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d9477929446742bab29a3a8f6faff45
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue