Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public static function GetTransforms(mode: SelectionMode): Transform[];
public static Transform[] GetTransforms(SelectionMode mode);
public static def GetTransforms(mode as SelectionMode) as Transform[]


mode Options for refining the selection.


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

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

for (var t in selection) t.parent = newParent.transform; } // Disable the menu if there is nothing selected @MenuItem ("Example/Create Parent For Selection _p", true) static function ValidateSelection() { return Selection.activeGameObject != null; } }