言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Selection.GetTransforms

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

Parameters

mode Options for refining the selection.

Description

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