亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將3D模型動態添加到地平面

如何將3D模型動態添加到地平面

C#
慕娘9325324 2021-05-07 18:14:23
我正在使用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);


查看完整回答
反對 回復 2021-05-16
  • 1 回答
  • 0 關注
  • 164 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號