老公原谅我在老公面前,小情侣在废弃楼房里约会电视剧,大赛每日一赛吃瓜爆料

  • 您的位置:首页 > 新闻动态 > Unity3D

    Unity3d 动态加载模型文件的方法

    2019/1/22??????点击:
    方法1(已测试过)
    1 将模型拖动到场景中 ,调整好位置。(制作prefab需要)
    2 新建Resources(如果工程中有的话 就不用新建了,Resource.Load调用的就是该文件夹下的资源),在该文件夹下建一个prefab,将上面的模型拖动到这个prefab上
    3 删除场景中的该物体模型

    4 编写脚本,把它仍随便一个GameObject

    using UnityEngine;
    using System.Collections;
     
    public class LoadFBX : MonoBehaviour {
         // Use this for initialization
        void Start () {
        GameObject gFbx=(GameObject)Instantiate( Resources.Load("che"));
        }
        // Update is called once per frame
        void Update () {  }
    }
    
    方法2:(没测试过,应该可以,因为之前能成功加载GameObject对象)
    1 按方法1 制作prefab 注意调整好位置
    2 然后使用AssetBundle导出包选项 create single AssetBundle(这之前需要在工程文件夹中新建一个叫做“Dynamic_Asset”的文件夹)
    3 这时可以看到导出的.AssetBundle文件了
    4 编写代码
    public string url;
        void Start () {
            string Scname = "scene1_part2.assetbundle";
            url = "file://F://asd//Dynamic//";
            StartCoroutine(DLAsset(url,Scname));
        }
        void Update () {
     
        }    
        public IEnumerator DLAsset (string url,string Scname) {
            WWW www = new WWW(url+Scname);
            yield return www;
            GameObject GO = (GameObject)Instantiate(www.assetBundle.mainAsset);
        }
    主站蜘蛛池模板: 绩溪县| 四川省| 高碑店市| 渝北区| 鲜城| 宝清县| 普陀区| 区。| 江达县| 汝阳县| 简阳市| 财经| 邳州市| 石阡县| 延边| 镇赉县| 兴城市| 吉木萨尔县| 当阳市| 临邑县| 衡东县| 谷城县| 潜山县| 台中市| 洱源县| 濉溪县| 安西县| 牡丹江市| 安康市| 革吉县| 瑞金市| 宝坻区| 都安| 焉耆| 临沭县| 邳州市| 黄大仙区| 双江| 囊谦县| 泸水县| 中西区|