码迷,mamicode.com
首页 > 编程语言 > 详细

Unity编辑器中选择特定Tag的所有物体

时间:2017-03-06 19:22:44      阅读:2414      评论:0      收藏:0      [点我收藏+]

标签:custom   rip   util   gre   unit   选择   color   using   log   

    using System;  
    using System.Collections;  
    using System.Collections.Generic;  
    using UnityEditor;  
    using UnityEngine;  
    using Object = UnityEngine.Object;  
      
    public class FindGosByTag : ScriptableWizard  
    {  
        //public string m_tagName;    
        public string[] m_tags;  
        private int m_tagIndex = 0;  
        void OnEnable()  
        {  
            m_tags = UnityEditorInternal.InternalEditorUtility.tags;  
        }  
      
        [MenuItem("Custom/Find GameObjects By Tag")]  
        private static void CreateWizard()  
        {  
      
            ScriptableWizard.DisplayWizard("Find GameObjects By Tag", typeof(FindGosByTag), "Find");  
        }  
      
        private void OnWizardCreate()  
        {  
      
            Selection.objects = GameObject.FindGameObjectsWithTag(m_tags[m_tagIndex]);  
            foreach (Object Go in Selection.objects)  
            {  
                Debug.Log("<color=green>想得到我的Tag吗?想要的话可以全部给你 去找吧 我把所有的Tag都放在这里 </color>" + Go.name, Go);  
            }  
        }  
        protected override bool DrawWizardGUI()  
        {  
            GUILayout.Label("Tag", EditorStyles.boldLabel);  
            m_tagIndex = EditorGUILayout.Popup(m_tagIndex, m_tags);  
            return true;  
        }  
      
    }  

 

Unity编辑器中选择特定Tag的所有物体

标签:custom   rip   util   gre   unit   选择   color   using   log   

原文地址:http://www.cnblogs.com/ptqueen/p/6511433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!