示例#1
0
    public void BeginInit()
    {
        env = new CSLE.CLS_Environment(this);
        Log_Warn("C#Light Ver:" + env.version);

        //System
        env.RegType(new CSLE.RegHelper_Type(typeof(NotImplementedException), "NotImplementedException"));
        env.RegType(new CSLE.RegHelper_Type(typeof(Exception), "Exception"));
        env.RegType(new CSLE.RegHelper_Type(typeof(object), "object"));

        //Framework
        env.RegType(new CSLE.RegHelper_Type(typeof(IScreenForModel), "IScreenForModel"));
        env.RegType(new CSLE.RegHelper_Type(typeof(IGameForModel), "IGameForModel"));

        env.RegType(new CSLE.RegHelper_Type(typeof(IGameModel), "IGameForModel"));
        env.RegType(new CSLE.RegHelper_Type(typeof(IScriptModel), "IScriptModel"));
        env.RegType(new CSLE.RegHelper_Type(typeof(IUIToolModel), "IUIToolModel"));
        env.RegType(new CSLE.RegHelper_Type(typeof(IBlockSceneModel), "IBlockSceneModel"));

        //UnityEngine
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Debug), "Debug"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.GameObject), "GameObject"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Object), "Object"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Transform), "Transform"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.UI.Text), "Text"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.RectTransform), "RectTransform"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Vector2), "Vector2"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Vector3), "Vector3"));
        env.RegType(new CSLE.RegHelper_Type(typeof(UnityEngine.Vector4), "Vector4"));



        //直接编译模式
        string[] files = System.IO.Directory.GetFiles(Application.streamingAssetsPath + "/script", "*.cs", System.IO.SearchOption.AllDirectories);
        Dictionary <string, IList <CSLE.Token> > tokens = new Dictionary <string, IList <CSLE.Token> >();

        foreach (var f in files)
        {
            string code = System.IO.File.ReadAllText(f);
            var    t    = env.ParserToken(code);
            tokens[f] = t;
        }

        env.Project_Compiler(tokens, true);


        inited = true;
    }
示例#2
0
    public void BuildProject(string path)
    {
#if UNITY_STANDALONE
        if (env == null)
        {
            Init();
        }
        string[] files = System.IO.Directory.GetFiles(path, "*.cs", System.IO.SearchOption.AllDirectories);
        Dictionary <string, IList <CSLE.Token> > project = new Dictionary <string, IList <CSLE.Token> >();
        foreach (var v in files)
        {
            var tokens = env.tokenParser.Parse(System.IO.File.ReadAllText(v));
            project.Add(v, tokens);
        }
        env.Project_Compiler(project, true);
#endif
    }