Created
March 7, 2014 05:20
-
-
Save tsubaki/9405694 to your computer and use it in GitHub Desktop.
シーン内のルートオブジェクトを取得するメソッドをtransformに追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
public static class TransformExtension | |
{ | |
public static GameObject[] FindRootObject (this Transform transform) | |
{ | |
return Array.FindAll (GameObject.FindObjectsOfType<GameObject> (), (item) => item.transform.parent == null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
実際に使う場合はこんな感じで使う。
ただactiveじゃないオブジェクトは取得できないので注意。その手の物は自己登録式でリスト作ったほうが効率的(もしくはエディタ拡張でビルド時にリスト作っちゃうか)