Version: 2022.3
言語: 日本語
public static Transform[] GetTransforms (SelectionMode mode);

パラメーター

mode Selection を絞り込むためのオプション

説明

SelectionMode ビットマスクを使用して Selection の種類を細かく制御できます

using UnityEngine;
using UnityEditor;

class CreateParentForTransforms : ScriptableObject { [MenuItem("Example/Create Parent For Selection _p")] static void MenuInsertParent() { Transform[] selection = Selection.GetTransforms( SelectionMode.TopLevel | SelectionMode.Editable); GameObject newParent = new GameObject("Parent");

foreach (Transform t in selection) { t.parent = newParent.transform; } }

// Disable the menu if there is nothing selected [MenuItem("Example/Create Parent For Selection _p", true)] static bool ValidateSelection() { return Selection.activeGameObject != null; } }