概要
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
も追加された。