Version: 2020.2
언어: 한국어
public static Transform[] GetTransforms (SelectionMode mode);

파라미터

mode Options for refining the selection.

설명

Allows for fine grained control of the selection type using the SelectionMode bitmask.

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; } }