Add Array Add Unique node to Visual Scripting

This commit is contained in:
Wojtek Figat
2022-04-13 21:25:11 +02:00
parent a27d69f852
commit 3d76b2c10f
2 changed files with 25 additions and 0 deletions

View File

@@ -258,6 +258,24 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Output(0, string.Empty, null, 1)
}
},
new NodeArchetype
{
TypeID = 14,
Title = "Array Add Unique",
Description = "Adds the unique item to the array (to the end). Does nothing it specified item was already added.",
Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
Size = new Vector2(170, 40),
ConnectionsHints = ConnectionsHint.Array,
IndependentBoxes = new int[] { 0 },
DependentBoxes = new int[] { 1, 2 },
DependentBoxFilter = GetArrayItemType,
Elements = new[]
{
NodeElementArchetype.Factory.Input(0, "Array", true, null, 0),
NodeElementArchetype.Factory.Input(1, "Item", true, typeof(object), 1),
NodeElementArchetype.Factory.Output(0, string.Empty, null, 2)
}
},
// first 100 IDs reserved for arrays
};
}

View File

@@ -1344,6 +1344,13 @@ void VisjectExecutor::ProcessGroupCollections(Box* box, Node* node, Value& value
array.Reverse();
value = MoveTemp(v);
break;
// Add Unique
case 14:
b = node->GetBox(1);
ENSURE(b->HasConnection(), TEXT("Missing value to add."));
array.AddUnique(eatBox(b->GetParent<Node>(), b->FirstConnection()));
value = MoveTemp(v);
break;
}
}
}