Exemplo n.º 1
0
        /// <summary>
        /// 为游戏物体生成编译单元。
        /// </summary>
        /// <param name="gameObject"></param>
        /// <returns></returns>
        public CodeCompileUnit genScript4GO(GameObject gameObject, AutoCompoGenSetting setting)
        {
            _setting       = setting;
            rootGameObject = gameObject;
            CodeCompileUnit unit = new CodeCompileUnit();

            //命名空间,引用
            _nameSpace = new CodeNamespace(setting.Namespace);
            unit.Namespaces.Add(_nameSpace);
            foreach (string import in setting.usings)
            {
                if (Regex.IsMatch(import, @"(\w\.)*\w"))
                {
                    _nameSpace.Imports.Add(new CodeNamespaceImport(import));
                }
                else
                {
                    Debug.LogError(import + "不是合法的命名空间");
                }
            }
            //类
            _type = new CodeTypeDeclaration();
            _nameSpace.Types.Add(_type);
            genType4RootGO();
            return(unit);
        }
Exemplo n.º 2
0
 void loadEditorSettings()
 {
     if (_setting == null)
     {
         _setting = new AutoCompoGenSetting();
         _setting.loadFromPrefs(PlayerSettings.productName);
     }
 }