public Texture2D LoadTexture2D(string assetPath) { assetPath = ModuleHub.AppendModPrefix(assetPath, moduleName); var go = LoadFromAssetsFolder <Texture2D>(assetPath); return(go); }
public GameObject LoadGameObject(string assetPath) { assetPath = ModuleHub.AppendModPrefix(assetPath, moduleName); var go = LoadFromAssetsFolder <GameObject>(assetPath); return(go); }
public byte[] LoadTextAsset(string assetPath) { assetPath = ModuleHub.AppendModPrefix(assetPath, moduleName); var assetPathInBundle = Path.Combine(UnityEngine.Application.dataPath, "modules", assetPath); return(NetHelper.UnityWebRequestLocalGet(assetPathInBundle)); }
public byte[] LoadTextAsset(string assetPath) { assetPath = ModuleHub.AppendModPrefix(assetPath, moduleName); var ta = LoadFromBundle <TextAsset>(assetPath); if (ta == null) { Debug.LogError($"load {assetPath} failed"); return(null); } return(ta.bytes); }
public UnityEngine.Object LoadFromBundleAsType(string assetPath, System.Type type) { assetPath = ModuleHub.AppendModPrefix(assetPath, moduleName); // 首先根据路径转为包名,这是打包的时候约定的:所有分隔符替换为下划线来组成bundle名 var bundleName = Path2AssetBundleName(assetPath); var bundle = GetBundle(bundleName); if (bundle == null) { Debug.LogError($"load {assetPath} failed, bundle {bundleName} not found"); return(null); } // 打包的时候,通过addressableNames把bundle中的资源的访问名字改为 // Assets/Lobby/Main.lua这样的风格,而不是 Assets/Tmp/Lobby/Main.lua.bytes var assetPathInBundle = pathPrefix + assetPath; var ta = bundle.LoadAsset(assetPathInBundle, type); return(ta); }