コード例 #1
0
 public static XLuaSetting GetInstance()
 {
     if (ms_Instance == null)
     {
         ms_Instance = Load <XLuaSetting>(SETTING_NAME);
     }
     return(ms_Instance);
 }
コード例 #2
0
        public override string AddScript(string name, TextAsset script)
        {
            int startIndex = XLuaSetting.GetInstance().ExportedLuaRoot.Length + 1;
            int length     = name.IndexOf('.') - startIndex;

            name = name.Substring(startIndex, length).Replace(@"/", ".");
            m_Names.Add(name);
            m_Scripts.Add(script);
            return(name);
        }
コード例 #3
0
        public byte[] CustomLoader(ref string filepath)
        {
#if UNITY_EDITOR
            if (m_FileToCodes == null)
            {
                string    luaRoot      = XLuaSetting.GetInstance().ExportedLuaRoot;
                string    luaPath      = $"{luaRoot}/{filepath.Replace('.', '/')}.lua.txt";
                TextAsset luaTextAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(luaPath) as TextAsset;
                if (luaTextAsset == null)
                {
                    MDebug.LogError("XLua", $"Not found lua script: " + filepath);
                    return(null);
                }
                return(System.Text.Encoding.UTF8.GetBytes(LuaScriptParser.s_Instance.Parse(luaTextAsset.text)));
            }
#endif

            if (m_FileToCodes.TryGetValue(filepath, out byte[] code))