Unity之EditorGUILayout-Layer、Mask

作者: 循环渐进123456 | 来源:发表于2017-09-11 08:52 被阅读15次

    转载:http://blog.csdn.net/liqiangeastsun/article/details/42173291

    使用编辑器类在Inspecotr面板编辑 Layer、Mask、Tag
    1



    2



    3

    4

    20141226162002503.png

    在Editor文件夹下创建脚本InspectorTest

    
    using UnityEngine;  
    using System.Collections;  
    using UnityEditor;  
      
      
    [CustomEditor(typeof(Test))]  
    public class InspectorTest : Editor {  
      
        public override void OnInspectorGUI()  
        {  
            Test myTest = (Test)target;  
      
            myTest.selectLayer = EditorGUILayout.LayerField("Layer Objects", myTest.selectLayer);  
      
            myTest.selectFlag = EditorGUILayout.MaskField("player Flags ", myTest.selectFlag, myTest.options);  
      
    myTest.tagStr = EditorGUILayout.TagField("Tag for Objects:", myTest.tagStr);  
        }  
    }  
    
    

    Test脚本如下,将其拖拽到需要绘制的对象上即可

    
    using UnityEngine;  
    using System.Collections;  
    using UnityEditor;  
      
    public class Test : MonoBehaviour {  
      
        public int selectLayer = 0;  
      
        public int selectFlag = 0;  
    public string[] options = { "CanJump", "CanShoot", "CanSwim"};  
      
    public string tagStr = "";  
      
    }  
    

    相关文章

      网友评论

        本文标题:Unity之EditorGUILayout-Layer、Mask

        本文链接:https://www.haomeiwen.com/subject/ulyxsxtx.html