Concatenate#
Combine / Concatenate
Can Read
Cannot Write
Description#
A collection with the items of the first collection followed by the ones of the second
Parameters#
| Name | Description |
|---|---|
| Collection 1 | The collection whose items come first |
| Collection 2 | The collection whose items are appended at the end |
Code#
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Concatenate")]
[Category("Combine/Concatenate")]
[Description("A collection with the items of the first collection followed by the ones of the second")]
[Image(typeof(IconStack), ColorTheme.Type.Teal, typeof(BadgePlus))]
[Parameter("Collection 1", "The collection whose items come first")]
[Parameter("Collection 2", "The collection whose items are appended at the end")]
[Keywords("Join", "Merge", "Append", "Add", "Union", "Combine")]
[Serializable]
public class TypeCollectionGameObjectsConcatenate : TypeCollectionGameObjects
{
// EXPOSED MEMBERS: -----------------------------------------------------------------------
[SerializeField] private GetCollectionGameObjects m_Collection1 = new GetCollectionGameObjects();
[SerializeField] private GetCollectionGameObjects m_Collection2 = new GetCollectionGameObjects();
// PUBLIC METHODS: ------------------------------------------------------------------------
public override void Get(Args args, List<GameObject> values)
{
values.Clear();
List<GameObject> buffer = ListPool<GameObject>.Get();
try
{
this.m_Collection1.Get(args, buffer);
values.AddRange(buffer);
this.m_Collection2.Get(args, buffer);
values.AddRange(buffer);
}
finally
{
ListPool<GameObject>.Release(buffer);
}
}
public override string ToString()
{
return $"{this.m_Collection1} + {this.m_Collection2}";
}
// PROTECTED METHODS: ---------------------------------------------------------------------
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}