我有以下资产包,我想添加jQuery UI作为其一部分.我该怎么做?
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AdminAsset extends AssetBundle
{
public $basePath = '@webroot/assets-admin';
public $baseUrl = '@web/assets-admin';
public $css = [
'css/common.css',
'css/animations.css',
'css/editor.css',
'css/form.css',
'css/fileupload.css',
'css/template.css',
'css/icons.css',
];
public $js = [
'js/libs/modernizr.js',
'js/script.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\web\YiiAsset',
];
}
Run Code Online (Sandbox Code Playgroud) 所以我创建了这个对象,它应该在我触摸游戏对象时在屏幕上加载游戏。但是,当我运行它时,出现此运行时错误
场景 'A' (-1) 无法加载,因为它尚未添加到构建设置或资产包尚未加载。要将场景添加到构建设置,请使用菜单 File->Build Settings... UnityEngine.Application:LoadLevel(String) NewBehaviourScript:OnCollisionEnter(Collision)(在 Assets/NewBehaviourScript.cs:10)
这是我的代码:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
void OnCollisionEnter (Collision col)
{
if(col.gameObject.name =="Hurt")
{
Application.LoadLevel("A");
}
}
}
Run Code Online (Sandbox Code Playgroud) scripting runtime-error unity-game-engine assetbundle unity5
我想知道 AssetBundle 已经在缓存中。这通常是通过Caching.IsVersionCached函数完成的。
该Caching.IsVersionCached(string url, int version)函数重载是不再支持统一2017.1。
Unity 2017.3建议我使用Caching.IsVersionCached(string url, Hash128 hash)重载。
我不知道它Hash128是什么以及如何获取和使用它。什么是Hash128用于如何从 AssetBundle 中获取它的?
谢谢您的回答。
但我无法解决我的问题。
这是我的代码
for (int i = 0; i < assetInfoList.Count; i++) {
while (!Caching.ready)
yield return null;
string url = GetUrl(assetInfoList[i].assetbundle_name);
string keyName = url + assetInfoList[i].version_no.ToString();
using (UnityWebRequest request = UnityWebRequest.GetAssetBundle(url,(uint)assetInfoList[i].version_no, 0))
{
if (Caching.IsVersionCached(url, assetInfoList[i].version_no) == true)
continue;
if (i == 0)
{
string wifiConnectRecommend = Message.Ins.WIFI_ONLY;
PopUpManager.Instance.PopUp_YesORNoForAssetBundle(wifiConnectRecommend.ToString(), ClickWifi, …Run Code Online (Sandbox Code Playgroud) 我正在 Unity 中为 iPhone 开发一个 AR 应用程序,它从网络服务器下载资源包并将它们附加到图像目标。到目前为止,几乎一切正常 - 除了当应用程序尝试加载资源包时,我收到以下错误:
无法加载“asset/bundle/url”,因为它不是使用正确的版本或构建目标构建的。
我使用以下脚本创建了 assetbundle,并根据 Unity 文档进行了稍微修改:
using UnityEditor;
public class CreateAssetBundles
{
[MenuItem ("Assets/Build AssetBundles")]
static void BuildAllAssetBundles ()
{
BuildPipeline.BuildAssetBundles ("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.iOS);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我使用 scp 将 assetbundles 上传到服务器。该应用程序可以正常下载资源包,但无法加载它们。这是代码:
IEnumerator DownloadAndCache (string username, string modelName){
// Wait for the Caching system to be ready
while (!Caching.ready) {
Debug.Log ("Waiting on caching");
yield return null;
}
//Compute request url for server
UriBuilder uriBuilder = new UriBuilder();
uriBuilder.Scheme = "http";
uriBuilder.Host = …Run Code Online (Sandbox Code Playgroud) 我想在 AR 相机中播放视频。我总共有 10 个视频和一个视频播放器。我正在从服务器下载视频播放器作为资产包,名称为 videoplayer.unit3d 并存储到 SD 卡中。当我扫描 imageTarget 时,我正在使用AssetBundle.LoadFromFile()函数读取视频资产包文件,并且第一次它工作正常。
如果我扫描第二个 imageTarget 它会显示以下错误
“无法加载,因为已经加载了另一个具有相同文件的 AssetBundle”
我试过 a bundle.Unload(true);andCaching.cleanchache()但它不工作抛出同样的错误。也试过bundle.Unload(false);
private void loadObject(string resourcePath, string objectName, TrackableBehaviour trackableBehaviuor, string videoUrl)
{
Debug.Log("Resource path " + resourcePath + " objectName " + objectName);
Debug.Log("Video Url from sd card " + videoUrl);
FileInfo fileInfo = new FileInfo(resourcePath);
if (!fileInfo.Exists)
return;
Debug.Log("File is present");
AssetBundle bundle = AssetBundle.LoadFromFile(resourcePath, 0, 0);//www.assetBundle;
Debug.Log("Bundle data is " + bundle);
if (bundle …Run Code Online (Sandbox Code Playgroud)