Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于在c#Unity中组合游戏对象的脚本_C#_Unity3d_Combinations_Gameobject - Fatal编程技术网

用于在c#Unity中组合游戏对象的脚本

用于在c#Unity中组合游戏对象的脚本,c#,unity3d,combinations,gameobject,C#,Unity3d,Combinations,Gameobject,我想制作一个脚本,生成一组游戏对象,如下所示: (给定游戏对象)a、b、c 结果:a、b、c、ab、ac、bc、abc 我找到了剧本 static IEnumerable<string> Combinations(List<string> characters, int length) { for (int i = 0; i < characters.Count; i++) { // only want 1 character, just return th

我想制作一个脚本,生成一组游戏对象,如下所示: (给定游戏对象)a、b、c 结果:a、b、c、ab、ac、bc、abc 我找到了剧本

static IEnumerable<string> Combinations(List<string> characters, int length)
{
for (int i = 0; i < characters.Count; i++)
{
    // only want 1 character, just return this one
    if (length == 1)
        yield return characters[i];

    // want more than one character, return this one plus all combinations one shorter
    // only use characters after the current one for the rest of the combinations
    else
        foreach (string next in Combinations(characters.GetRange(i + 1, characters.Count - (i + 1)), length - 1))
            yield return characters[i] + next;
}
}
静态IEnumerable组合(列表字符、整数长度)
{
for(int i=0;i

但是它只适用于字符串,因此如果我错过了任何可以在这里使用的解决方案,我将不胜感激。

gameObjects调用它。选择(o=>o.Name)
构建名称排列,然后再次按名称查找对象?注意组合和排列是非常不同的概念