我正在使用Unity的地平面功能放置3D动画模型。但是,我现在正在使用AssetBundle功能下载此3d模型,并需要使用脚本将其放置在Ground Plane Stage上。但是,当我将其部署到android设备上时,它不会显示...我正在使用支持GroundPlane检测的Xiaomi Redmi 3s。我已添加脚本以将资产捆绑包下载到“平面查找器”中AssetbundleDownloadingScript:public class AssetLoader : MonoBehaviour{ public static AssetLoader Instance; public string url = "myurl"; public int version = 1; public string AssetName; //public Text infoText; public string infoText = ""; AssetBundle bundle; void Awake() { Instance = this; DownloadAsset(); } void OnDisable() { //AssetBundleManager.Unload(url, version); } public void DownloadAsset() { // bundle = AssetBundleManager.getAssetBundle (url, version); // Debug.Log(bundle); if (!bundle) StartCoroutine(DownloadAssetBundle()); } IEnumerator DownloadAssetBundle() { yield return StartCoroutine(AssetBundleManager.downloadAssetBundle(url, version)); bundle = AssetBundleManager.getAssetBundle(url, version); if (bundle != null) infoText = "Download Success....."; else infoText = "Download error please retry"; GameObject santaasset = bundle.LoadAsset("animation_keyframes_increase_v1", typeof(GameObject)) as GameObject; //here script attached to plane finder,get 1st child of planefinder var child = gameObject.transform.GetChild(0); if (santaasset != null) { santaasset.transform.transform.Rotate(new Vector3(0, 180, 0)); santaasset.transform.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); santaasset.transform.transform.SetParent(child.transform, false); } bundle.Unload(false); } public void SetInfoText(string text) { //infoText.text = text; } void OnGUI() { GUILayout.Label("Dummy Label:" + infoText); }}这是我的场景的屏幕截图:关于我在做什么错的任何建议吗?谢谢。
1 回答

慕森卡
TA贡献1806条经验 获得超8个赞
我在您发现AssetbundleDownloadingScript
您正在创建中时注意到GameObject santaasset
,但是您绝不会将对象分配给new
或现有的GameObject甚至是Instantiating
它。您要分配的Asset
是您正在从中加载的bundle
。但是,该资产也从未分配过,因为它只是被加载到内存中,因此Unity可以识别它。这就是您所经历的,这就是为什么您在游戏中看到该对象,但该对象未激活,甚至很难禁用的原因。
若要解决此问题,您必须像这样分配您的GameObject或实例化它:GameObject santaasset = Instantiate(bundle.LoadAsset("animation_keyframes_increase_v1", typeof(GameObject)) as GameObject);
- 1 回答
- 0 关注
- 155 浏览
添加回答
举报
0/150
提交
取消