トップ 一覧 検索 ヘルプ RSS ログイン

unity_editor_selection_gameobjectsの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!!選択中のGameObjectを取得

Editorの機能として、選択されているGameObjectを列挙します。

要:
 using UnityEngine;
 using UnityEditor;

 // 選択中のGameObjectを配列として取得.
 int selectCou = Selection.gameObjects.Length;
 for (int i = 0; i < selectCou; i++) {
     GameObject obj = Selection.gameObjects[i];
 
     // MeshのGameObjectであるか判定.
     if (obj.GetComponent<MeshFilter>() != null) {
         if (obj.GetComponent<MeshFilter>().sharedMesh != null) {
             Debug.Log(obj);
         }
     }
 }
「Selection.gameObjects」で、GameObjectの配列を取得できます。
 

----
{{lastmodified}}