Add Delay node to Visual Scripting

This commit is contained in:
Wojtek Figat
2021-06-14 16:10:08 +02:00
parent 90105c421d
commit f5cdb0abfd
9 changed files with 170 additions and 144 deletions

View File

@@ -293,6 +293,21 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Input(1, "Value", true, null, 1),
}
},
new NodeArchetype
{
TypeID = 6,
Title = "Delay",
Description = "Delays the graph execution. If delay is 0 then it will pass though.",
Flags = NodeFlags.VisualScriptGraph,
Size = new Vector2(150, 40),
DefaultValues = new object[] { 1.0f },
Elements = new[]
{
NodeElementArchetype.Factory.Input(0, string.Empty, true, typeof(void), 0),
NodeElementArchetype.Factory.Input(1, "Duration", true, typeof(float), 1, 0),
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(void), 2, true),
}
},
};
}
}

View File

@@ -677,19 +677,21 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public ThisNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{}
{
}
/// <inheritdoc />
public override void OnLoaded()
{
base.OnLoaded();
var vss = (VisualScriptSurface)this.Context.Surface;
var type = TypeUtils.GetType(vss.Script.ScriptTypeName);
var surface = (VisualScriptSurface)Context.Surface;
var type = TypeUtils.GetType(surface.Script.ScriptTypeName);
var box = (OutputBox)GetBox(0);
box.CurrentType = type ? type : new ScriptType(typeof(VisualScript));
}
}
private class AssetReferenceNode : SurfaceNode
{
/// <inheritdoc />