以下の内容はhttps://baba-s.hatenablog.com/entry/2025/03/09/182839より取得しました。


【Unity】UnityEditor.GameObjectUtility.DuplicateGameObject でゲームオブジェクトを複製する方法

概要

using UnityEditor;

internal static class Example
{
    [MenuItem( "Tools/Example" )]
    private static void Run()
    {
        var gameObject = Selection.activeGameObject;
        var clone      = GameObjectUtility.DuplicateGameObject( gameObject );

        Selection.activeGameObject = clone;
    }
}

Unity 2023.1.0f1 から UnityEditor.GameObjectUtility.DuplicateGameObject
ゲームオブジェクトを複製できるようになった。

using UnityEditor;

internal static class Example
{
    [MenuItem( "Tools/Example" )]
    private static void Run()
    {
        var gameObjects = Selection.gameObjects;
        var clones      = GameObjectUtility.DuplicateGameObjects( gameObjects );

        Selection.objects = clones;
    }
}

複数のゲームオブジェクトを複製できる
GameObjectUtility.DuplicateGameObjects も追加された。

参考サイト様




以上の内容はhttps://baba-s.hatenablog.com/entry/2025/03/09/182839より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14