久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

AssetBundle系列游戲資源打包(一)

 3dC 2014-11-06

將本地資源打包,,然后放到資源服務(wù)器上供游戲客戶端下載或更新。服務(wù)器上包含以下資源列表:
(1)游戲內(nèi)容資源assetbundle
(2)資源維護(hù)列表,,包含每個(gè)資源的名字(完整路徑名)和對(duì)應(yīng)的版本號(hào)[資源名,版本號(hào)],,如下表所示(VersionNum.xml):

復(fù)制代碼
<VersionNum>
  <File FileName="Assets.Resources.BigLevelTexture.TestLevel.assetbundle" Num="1" />
  <File FileName="Assets.Resources.EquipmentTexture.Test001.assetbundle" Num="1" />
  <File FileName="Assets.Resources.EquipmentTexture.Test002.assetbundle" Num="1" />
  <File FileName="Assets.Resources.EquipmentTexture.Test003.assetbundle" Num="1" />
  <File FileName="Assets.Resources.EquipmentTexture.Test004.assetbundle" Num="1" />
  <File FileName="Assets.Resources.PetTexture.Empty.assetbundle" Num="1" />
</VersionNum>
復(fù)制代碼

 

那么本地客戶端的資源打包編輯器就需要完成以下工作:將資源打包,、生成版本號(hào)。
我們采用通過MD5碼對(duì)比的方式來對(duì)版本號(hào)進(jìn)行管理,,如果某資源的MD5碼變更了,,則將其版本號(hào)+1,否則不變,。那么,,可以將編輯器的具體任務(wù)劃分如下:
(1)將資源打包成assetbundle,并放到指定目錄下
(2)為每個(gè)assetbund生成最新MD5碼,,用于檢查資源是否有修改
(3)比較新舊MD5碼列表,產(chǎn)生資源變更列表,,對(duì)于每個(gè)變更的資源,,將其版本號(hào)+1
(4)將變更列表文件也打包成assetbundle

各個(gè)平臺(tái)使用的資源包時(shí)各自獨(dú)立的,打包資源代碼時(shí)的選項(xiàng)不一樣,,編輯器界面如下,,圖2中的4個(gè)按鈕每個(gè)對(duì)應(yīng)上述的一步操作:

 

 

最終生成的資源目錄結(jié)構(gòu)如下所示:

 編輯器代碼如下所示(包括菜單項(xiàng)和窗口):

復(fù)制代碼
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class AssetBundleController : EditorWindow
{
    public static AssetBundleController window;
    public static UnityEditor.BuildTarget buildTarget = BuildTarget.StandaloneWindows;

    [MenuItem("XiYouEditor/AssetBundle/AssetBundle For Windows32", false, 1)]
    public static void ExecuteWindows32()
    {
        if (window == null)
        {
            window = (AssetBundleController)GetWindow(typeof(AssetBundleController));
        }
        buildTarget = UnityEditor.BuildTarget.StandaloneWindows;
        window.Show();
    }

    [MenuItem("XiYouEditor/AssetBundle/AssetBundle For IPhone", false, 2)]
    public static void ExecuteIPhone()
    {
        if (window == null)
        {
            window = (AssetBundleController)GetWindow(typeof(AssetBundleController));
        }
        buildTarget = UnityEditor.BuildTarget.iPhone;
        window.Show();
    }

    [MenuItem("XiYouEditor/AssetBundle/AssetBundle For Mac", false, 3)]
    public static void ExecuteMac()
    {
        if (window == null)
        {
            window = (AssetBundleController)GetWindow(typeof(AssetBundleController));
        }
        buildTarget = UnityEditor.BuildTarget.StandaloneOSXUniversal;
        window.Show();
    }

    [MenuItem("XiYouEditor/AssetBundle/AssetBundle For Android", false, 4)]
    public static void ExecuteAndroid()
    {
        if (window == null)
        {
            window = (AssetBundleController)GetWindow(typeof(AssetBundleController));
        }
        buildTarget = UnityEditor.BuildTarget.Android;
        window.Show();
    }

    [MenuItem("XiYouEditor/AssetBundle/AssetBundle For WebPlayer", false, 5)]
    public static void ExecuteWebPlayer()
    {
        if (window == null)
        {
            window = (AssetBundleController)GetWindow(typeof(AssetBundleController));
        }
        buildTarget = UnityEditor.BuildTarget.WebPlayer;
        window.Show();
    }

    void OnGUI()
    {
        if (GUI.Button(new Rect(10f, 10f, 200f, 50f), "(1)CreateAssetBundle"))
        {
            CreateAssetBundle.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "Step (1) Completed", "OK");
        }

        if (GUI.Button(new Rect(10f, 80f, 200f, 50f), "(2)Generate MD5"))
        {
            CreateMD5List.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "Step (2) Completed", "OK");
        }

        if (GUI.Button(new Rect(10f, 150f, 200f, 50f), "(3)Compare MD5"))
        {
            CampareMD5ToGenerateVersionNum.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "Step (3) Completed", "OK");
        }

        if (GUI.Button(new Rect(10f, 220f, 200f, 50f), "(4)Build VersionNum.xml"))
        {
            CreateAssetBundleForXmlVersion.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "Step (4) Completed", "OK");
        }
    }

    public static string GetPlatformPath(UnityEditor.BuildTarget target)
    {
        string SavePath = "";
        switch (target)
        {
            case BuildTarget.StandaloneWindows:
                SavePath = "Assets/AssetBundle/Windows32/";
                break;
            case BuildTarget.StandaloneWindows64:
                SavePath = "Assets/AssetBundle/Windows64/";
                break;
            case BuildTarget.iPhone:
                SavePath = "Assets/AssetBundle/IOS/";
                break;
            case BuildTarget.StandaloneOSXUniversal:
                SavePath = "Assets/AssetBundle/Mac/";
                break;
            case BuildTarget.Android:
                SavePath = "Assets/AssetBundle/Android/";
                break;
            case BuildTarget.WebPlayer:
                SavePath = "Assets/AssetBundle/WebPlayer/";
                break;
            default:
                SavePath = "Assets/AssetBundle/";
                break;
        }

        if (Directory.Exists(SavePath) == false)
            Directory.CreateDirectory(SavePath);

        return SavePath;
    }

    public static string GetPlatformName(UnityEditor.BuildTarget target)
    {
        string platform = "Windows32";
        switch (target)
        {
            case BuildTarget.StandaloneWindows:
                platform = "Windows32";
                break;
            case BuildTarget.StandaloneWindows64:
                platform = "Windows64";
                break;
            case BuildTarget.iPhone:
                platform = "IOS";
                break;
            case BuildTarget.StandaloneOSXUniversal:
                platform = "Mac";
                break;
            case BuildTarget.Android:
                platform = "Android";
                break;
            case BuildTarget.WebPlayer:
                platform = "WebPlayer";
                break;
            default:
                break;
        }
        return platform;
    }

}
復(fù)制代碼

 PS:每個(gè)操作的具體實(shí)現(xiàn),見下一篇講解...

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多