码迷,mamicode.com
首页 > 编程语言 > 详细

Unity 分场景打包

时间:2018-11-08 16:12:38      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:assets   Plan   导入   init   load   命名空间   get   prefab   ack   

分场景打包步骤:导入unity中AB包后

  1: 指定场景
  2: 指定abname
  3: 指定objinabname
  4: 协同
  5: 委托 void string

unity

技术分享图片

技术分享图片

先引入命名空间  using LLWHABFW;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LLWHABFW;
using UnityEngine.SceneManagement;
public class S3LoadAB : MonoBehaviour {

    private string _abScence = "scenes03";//指定场景 //小写s
    private string _aBName = "scenes03/scenes03.ab";  //指定abName
    private string _objInAB01 = "Plane.prefab";//指定objIn abName
    private string _objInAB02 = "RollerBall.prefab";//指定objInabName
    private List<GameObject> _list;
    // Use this for initialization
    void Start ()
    {
        _list = new List<GameObject>();
        StartCoroutine(AssetBundleMgr.GetInstance().LoadAssetBundlePack(_abScence, _aBName, XXXX));//协同
    }
    // Update is called once per frame
    void Update ()
    {
        if (Input.GetKeyDown(KeyCode.Space))  //销毁资源
        {
            for (int i = 0; i < _list.Count; i++)
            {
                Destroy(_list[i]);
            }
            _list.Clear();
            AssetBundleMgr.GetInstance().DisposeAllAssets(_abScence);
            SceneManager.LoadScene("1");
        }    
    }
    private void XXXX(string LLwh)   //void string
    {
        GameObject Plane, Ball;
        Plane = AssetBundleMgr.GetInstance().LoadAsset(_abScence, _aBName, _objInAB01, false) as GameObject;
        Ball = AssetBundleMgr.GetInstance().LoadAsset(_abScence, _aBName, _objInAB02, false) as GameObject;
        _list.Add(Instantiate(Plane));
       _list.Add(Instantiate(Ball));
    }
}

 

 

 

Unity 分场景打包

标签:assets   Plan   导入   init   load   命名空间   get   prefab   ack   

原文地址:https://www.cnblogs.com/lk95/p/9929235.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!