protected void OnEnable()
        {
            editorItem = (ContextRoot)target;

            var customScriptsNames = new List <string>();

            // 第一个类型必须保持为 UnityEngine.MonoBehaviour
            customScriptsNames.Add(MONO_BEHAVIOUR_TYPE);
            // 获取继承了 MonoBehaviour 的类型并遍历
            var customTypes = TypeUtils.GetAssignableTypes(typeof(MonoBehaviour));
            int length      = customTypes.Length;

            for (int i = 0; i < length; i++)
            {
                // 如果不是 ToluaContainer 命名空间下的类型才添加到 customScriptsNames
                if (!customTypes[i].FullName.StartsWith("ToluaContainer"))
                {
                    customScriptsNames.Add(customTypes[i].FullName);
                }
            }
            // 将 customScriptsNames 的结果转为数组保存到 customScripts 数组
            customScripts = customScriptsNames.ToArray();

            // 如果 editorItem.baseBehaviourTypeName 为空将 MONO_BEHAVIOUR_TYPE 作为基类名
            if (string.IsNullOrEmpty(editorItem.baseBehaviourTypeName))
            {
                editorItem.baseBehaviourTypeName = MONO_BEHAVIOUR_TYPE;
            }
        }
Exemplo n.º 2
0
        protected void OnEnable()
        {
            this.editorItem = (ContextRoot)this.target;

            var customScriptsNames = new List <string>();

            //The first type is always "UnityEngine.MonoBehaviour".
            customScriptsNames.Add(MONO_BEHAVIOUR_TYPE);

            var customTypes = TypeUtils.GetAssignableTypes(typeof(MonoBehaviour));

            foreach (var customType in customTypes)
            {
                //Prevent Adic MonoBehaviours from entering the list.
                if (!customType.FullName.StartsWith("Adic"))
                {
                    customScriptsNames.Add(customType.FullName);
                }
            }
            this.customScripts = customScriptsNames.ToArray();

            //Forces the base MonoBehaviour type as base type.
            if (string.IsNullOrEmpty(this.editorItem.baseBehaviourTypeName))
            {
                this.editorItem.baseBehaviourTypeName = MONO_BEHAVIOUR_TYPE;
            }
        }
Exemplo n.º 3
0
        protected void OnEnable()
        {
            this.editorItem = (ContextRoot)this.target;

            var customTypes = TypeUtils.GetAssignableTypes(typeof(MonoBehaviour));
            var customScriptsNames = new List<string>();
            foreach (var customType in customTypes) {
                //Prevent Adic MonoBehaviours from entering the list.
                if (!customType.FullName.StartsWith("Adic")) {
                    customScriptsNames.Add(customType.FullName);
                }
            }
            this.customScripts = customScriptsNames.ToArray();
        }