<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [Unity中如何查找腳本掛載在哪個物體上(以2017.2版本為例)](https://blog.csdn.net/weixin_44560436/article/details/86626299) Unity中如何查找腳本掛載在哪個物體上(以2018版本為例) Windows->gennal->Test Runner 2:彈出一個下面這個窗口 ![](https://img.kancloud.cn/bb/39/bb3979632a70530a94dc6fc00cf224aa_471x246.png) 點擊上圖紅框后在project敞口下的Assets目錄下自動生成tests文件夾且tests文件夾下又個tests的腳本 [asd](file:///D:/important/2018.4.8c3/Editor/Data/Documentation/en/ScriptReference/EditorWindow.html) ![](https://img.kancloud.cn/ef/50/ef50fff060847c1a5233c5d33edb2ee1_307x34.png) ``` using UnityEngine; using UnityEditor; /// <summary> /// 盛放物體代碼 /// </summary> public class FindMissingScriptsRecursively : EditorWindow { static int go_count = 0, components_count = 0, missing_count = 0; [MenuItem("Window / FindMissingScriptsRecursively")] public static void ShowWindow() { EditorWindow.GetWindow(typeof(FindMissingScriptsRecursively)); } public void OnGUI() { if (GUILayout.Button("Find Missing Scripts in selected GameObjects")) { FindInSelected(); } } private static void FindInSelected() { GameObject[] go = Selection.gameObjects; go_count = 0; components_count = 0; missing_count = 0; foreach (GameObject g in go) { FindInGO(g); } Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count)); } private static void FindInGO(GameObject g) { go_count++; Component[] components = g.GetComponents<Component>(); for (int i = 0; i < components.Length; i++) { components_count++; if (components[i] == null) { missing_count++; string s = g.name; Transform t = g.transform; while (t.parent != null) { s = t.parent.name + "/" +s; t = t.parent; } Debug.Log(s + " has an empty script attached in position: " + i, g); } } // Now recurse through each child GO (if there are any): foreach (Transform childT in g.transform) { //Debug.Log("Searching " + childT.name + " " ); FindInGO(childT.gameObject); } } } ``` ``` using UnityEngine; using UnityEditor; using System.Collections.Generic; ///////////////////////////////////////////////////////////////////////////// ///盛放腳本的代碼 查找節點及所有子節點中,是否有指定的腳本組件 ///////////////////////////////////////////////////////////////////////////// public class MonoFinder : EditorWindow { Transform root = null; MonoScript scriptObj = null; int loopCount = 0; List<Transform> results = new List<Transform>(); [MenuItem("Seek/Finder/MonoFinder")] //[MenuItem("Level4/Finder/MonoFinder")] static void Init() { EditorWindow.GetWindow(typeof(MonoFinder)); } void OnGUI() { GUILayout.Label("節點:"); root = (Transform)EditorGUILayout.ObjectField(root, typeof(Transform), true); GUILayout.Label("腳本類型:"); scriptObj = (MonoScript)EditorGUILayout.ObjectField(scriptObj, typeof(MonoScript), true); if (GUILayout.Button("Find")) { results.Clear(); loopCount = 0; Debug.Log("開始查找."); FindScript(root); } if (results.Count > 0) { foreach (Transform t in results) { EditorGUILayout.ObjectField(t, typeof(Transform), false); } } else { GUILayout.Label("無數據"); } } void FindScript(Transform root) { if (root != null && scriptObj != null) { loopCount++; Debug.Log(".." + loopCount + ":" + root.gameObject.name); if (root.GetComponent(scriptObj.GetClass()) != null) { results.Add(root); } foreach (Transform t in root) { FindScript(t); } } } } ``` 有了這兩個腳本,會發現unity的菜單里會多出一個Seek(如圖)的選項,然后點擊它,會出現一個彈窗。上面那個節點(如圖)就是盛放物體的,下面那個腳本類型(如圖)就是放腳本的。 例如下面的案例中,我要查找一個名字叫MainPanel的腳本在Canves這個物體里有多少被掛載了。直接把對應的東西拖進去,然后點擊find就會發現在MainPanel這個子物體里有這個腳本。 ![](https://img.kancloud.cn/8b/84/8b8444b3435ae8dc5449937f3ffd7059_552x270.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看