GithubHelp home page GithubHelp logo

kimi2016 / assetupdater-core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snaticy/assetupdater-core

0.0 1.0 0.0 38 KB

AssetUpdater is a plugin which helps developers build assetbundles and download it easily

License: MIT License

C# 100.00%

assetupdater-core's Introduction

AssetUpdater

AssetUpdater 为开发者提供了方便的生成以及下载 Assetbundle 的工作流。借助该插件,开发者可以一键式的生成 Assetbundle 并在自己的项目中使用几行代码来完成从特定链接下载需要被更新的所有 Assetbundle。

License License

安装

  • 方法一:在 Unity 工程 Assets 目录下新建文件夹 AssetUpdater, 下载 Zip 后将所有文件解压至该文件夹即可。
  • 方法二:直接下载 Release 最新版本的 AssetUpater.unitypackage 并将其导入工程即可
  • 方法三:在 Unity 工程中添加 git submodule 并设置相对路径为 Assets/AssetUpdater。

快速入门

该插件的主要功能分为 ”生成 Assetbundle“ 和 ”下载 Assetbundle“ 两部分。

生成 Assetbundle

导入插件后单击 Unity 菜单栏中的 Window/AssetUpdater Settings即可在 Inspector 中显示设置面板。如下图所示:

当你为某些文件设置assetbundle name后,该 assetbundle 就会出现在Local BundlesRemote Bundles中,其中Local Bundles中的 assetbundle 会在生成后被额外复制到streamingassets目录下。在打包时随安装包发布,并生成独特的 versionfile 做记录,放置重复下载。

选择平台后点击最下方Build Assetbundles按钮即可生成 Assetbundle 及其版本信息文件。其中原始的 assetbundle 及其 assetbundlemanifest 文件会被放置在与 Unity 工程中Assets目录同级的AssetBundlePool文件夹,并将 assetbundle 文件按照原始目录结构复制到与 Unity 工程中Assets目录同级的AssetBundleServer文件夹中,同时在该文件夹生成版本信息文件,版本信息文件默认文件名为versionfile.bytesAssetBundleServer文件夹中的全部内容放置在你的 http 文件服务器中供客户端下载即可。

如需要本地测试则可以在AssetBundleServer目录运行sudo python -m SimpleHTTPServer 80命令,即可开启本地 http 文件服务,访问 http://localhost 即可下载文件。

下载 Assetbundle

AssetUpdater Seetings中设置remote url为你的 http 文件服务器地址,如需本地测试则设置为 http://localhost 即可。

在 Unity 工程中添加如下代码。

using Meow.AssetUpdater.Core;
using UnityEngine;

public class TestScript : MonoBehaviour
{
	// Use this for initialization
	IEnumerator Start()
	{
		yield return MainUpdater.LoadAllVersionFiles();
		yield return MainUpdater.UpdateFromStreamingAsset();
		yield return MainUpdater.UpdateFromRemoteAsset();
	}	
}

MainUpdater.LoadAllVersionFiles()会加载本地streamingAssetPathpersistentDataPath(如果不存在则会自动生成一个)以及remote url中所有的 versionfile。

MainUpdater.UpdateFromStreamingAsset()则会对比persistentDataPathstreamingAssetPath中的 versionfile 并将不存在或版本更新的 assetbundle 文件复制至persistentDataPath中。复制后将会更新persistentDataPath对应的 versionfile 中的信息并将其写入磁盘。每复制完一个 assetbundle 并将其写入磁盘后会立即更新 versionfile。因此即使下载过程中断也不会导致已下载的 assetbundle 下次启动时被重复下载。

MainUpdater.UpdateFromRemoteAsset()会对比persistentDataPathremote Url中的 versionfile,将不存在或版本更新的 assetbundle 文件复制至persistentDataPath中。在生成 assetbundle 时勾选至Local Bundles的 assetbundle 文件在上一步已被更新至 persistentDataPath因此不会重复下载,除非 remote 中的 assetbundle 版本更新。每更新完一个 assetbundle 并将其写入磁盘后会立即更新 versionfile。因此即使下载过程中断也不会导致已下载的 assetbundle 下次启动时被重复下载。

assetupdater-core's People

Contributors

snaticy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.