Exemple #1
0
        //private static byte[] AssetBundleLoader(ref string filepath)
        //{
        //	if (!string.IsNullOrWhiteSpace(filepath))
        //	{
        //		var splits = filepath.Split(dot);

        //		if (splits != null)
        //		{
        //			var l = splits.Length;

        //			if (filepath.EndsWith(luaExtensionName) && splits.Length > 2)
        //			{
        //				var textAsset = AssetBundles.Default.LoadAsset(BundleNameToLower($"{splits[0]}_lua.unity3d"), $"{splits[l - 2]}.{splits[l - 1]}");

        //				if (textAsset != null && textAsset is TextAsset)
        //				{
        //					filepath = Path.Combine(Application.dataPath, luaDir + filepath.Replace(dot, backSlash).Replace(luaSuffixName, luaExtensionName) + txtExtensionName);

        //					return (textAsset as TextAsset).bytes;
        //				}
        //			}
        //			else if (splits.Length > 1)
        //			{
        //				var textAsset = AssetBundles.Default.LoadAsset(BundleNameToLower($"{splits[0]}_lua.unity3d"), $"{splits[l - 1]}{luaExtensionName}");

        //				if (textAsset != null && textAsset is TextAsset)
        //				{
        //					filepath = Path.Combine(Application.dataPath, luaDir + filepath.Replace(dot, backSlash) + luaTxtExtensionName);

        //					return (textAsset as TextAsset).bytes;
        //				}
        //			}
        //		}
        //	}

        //	return null;
        //}


        private static byte[] ABLuaLoader(ref string filepath)
        {
            if (!string.IsNullOrWhiteSpace(filepath))
            {
                var luaFileName = filepath.Replace(luaExtensionName, "");
                var splits      = luaFileName.Split(dot);

                if (splits != null)
                {
                    if (filepath.EndsWith(luaExtensionName))
                    {
                        filepath = Path.Combine("Assets/", luaDir, filepath.Replace(dot, backSlash).Replace(luaSuffixName, luaExtensionName) + txtExtensionName);
                    }
                    else
                    {
                        filepath = Path.Combine("Assets/", luaDir, filepath.Replace(dot, backSlash) + luaTxtExtensionName);
                    }
                }

                var obj = LoadHelper.LoadTextAsset(filepath);
                if (obj is TextAsset textAsset)
                {
#if UNITY_EDITOR
                    if (filepath.EndsWith("manifest.lua.txt"))
                    {
                        UnityEditor.AssetDatabase.TryGetGUIDAndLocalFileIdentifier(obj, out string _, out long id);
                        Debug.Log(id);
                    }
#endif
                    return(textAsset.bytes);
                }
            }

            return(null);
        }
Exemple #2
0
 private static byte[] Load(string path)
 {
     return(LoadHelper.LoadTextAsset(path).bytes);
 }