AssetsBundle基础

1.打包:

    [MenuItem("AssetBundleTools/BuildAllAssetBundles")]
    public static void BuildAllAB()
    {
        //打包AB输出路径
        string strABOutPathDIR = string.Empty;

        //获取"StreamingAssets"数值
        strABOutPathDIR = Application.streamingAssetsPath;
        //判断生成输出目录文件夹
        if (!Directory.Exists(strABOutPathDIR))
        {
            Directory.CreateDirectory(strABOutPathDIR);
        }
        //打包生成
        BuildPipeline.BuildAssetBundles(strABOutPathDIR,BuildAssetBundleOptions.None,BuildTarget.StandaloneWindows64);
    }
 

2.有依赖关系的文件要先加载依赖关系文件 .

/***
 *
 *   Title: "AssetBundle原理"项目
 *
 *   Description:
 *          功能: 
 *             演示AssetBundle基本加载
 *             分为两种:
 *             1: 加载非“对象预设”方式。(例如: 贴图、材质、音频...)
 *             2:  加载“对象预设”(*.Prefab) 方式。
 *
 *   Author: Liuguozhu
 *
 *   Date: 2017.10
 *
 *   Modify:  
 *
 */
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace DemoSpace
{
    public class AssetBundleLoadDemo : MonoBehaviour 
    {
        //测试对象,改变贴图
        //public GameObject goCubeChangeTextur;
        //测试对象,显示方位
        public Transform TraShowPos;

        //定义URL与资源名称
        //private string _URL1;
        //private string _AssetName1;

        private string _URL0;  //只加载AB包URL路径

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值