資源簡介
最近做mmo的時候發現有很多瑣碎的icon,比如戰場中的頭像,小地圖的icon之類的,占用了很多的draw call
為了節省draw call就找到了這個代碼。

代碼片段和文件信息
using?DaVikingCode.AssetPacker;
using?System.Collections;
using?System.Collections.Generic;
using?System.IO;
using?UnityEngine;
using?UnityEngine.UI;
public?class?AssetPackerExample?:?MonoBehaviour?{
public?Image?anim;
AssetPacker?assetPacker;
void?Start?()?{
//?We?just?copy?and?paste?files?so?you?don‘t?have?to?do?it?manually.
CopyPasteFoldersAndPNG(Application.dataPath?+?“/RuntimeSpriteSheetsGenerator/Demos/Sprites“?Application.persistentDataPath);
string[]?files?=?Directory.GetFiles(Application.persistentDataPath?+?“/Textures“?“*.png“);
assetPacker?=?GetComponent();
assetPacker.OnProcessCompleted.AddListener(LaunchAnimations);
assetPacker.AddTexturesToPack(files);
assetPacker.Process();
}
void?LaunchAnimations()?{
StartCoroutine(LoadAnimation());
}
IEnumerator?LoadAnimation()?{
Sprite[]?sprites?=?assetPacker.GetSprites(“walking“);
int?j?=?0;
while?(j?
anim.sprite?=?sprites[j++];
yield?return?new?WaitForSeconds(0.1f);
if?(j?==?sprites.Length)
j?=?0;
}
}
void?CopyPasteFoldersAndPNG(string?SourcePath?string?DestinationPath)?{
foreach?(string?dirPath?in?Directory.GetDirectories(SourcePath?“*“?SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(SourcePath?DestinationPath));
foreach?(string?newPath?in?Directory.GetFiles(SourcePath?“*.png“?SearchOption.AllDirectories))
File.Copy(newPath?newPath.Replace(SourcePath?DestinationPath)?true);
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-04-30?10:37??UnityRuntimeSpriteSheetsGenerator-master\
?????文件?????????449??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\.gitignore
?????目錄???????????0??2018-10-16?14:58??UnityRuntimeSpriteSheetsGenerator-master\.vs\
?????目錄???????????0??2018-10-16?14:58??UnityRuntimeSpriteSheetsGenerator-master\.vs\UnityRuntimeSpriteSheetsGenerator-master\
?????目錄???????????0??2018-10-16?15:00??UnityRuntimeSpriteSheetsGenerator-master\.vs\UnityRuntimeSpriteSheetsGenerator-master\v15\
?????文件???????27648??2018-10-16?15:00??UnityRuntimeSpriteSheetsGenerator-master\.vs\UnityRuntimeSpriteSheetsGenerator-master\v15\.suo
?????目錄???????????0??2018-10-16?14:58??UnityRuntimeSpriteSheetsGenerator-master\.vs\UnityRuntimeSpriteSheetsGenerator-master\v15\sqlite3\
?????文件??????552960??2018-10-16?14:58??UnityRuntimeSpriteSheetsGenerator-master\.vs\UnityRuntimeSpriteSheetsGenerator-master\v15\sqlite3\storage.ide
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes\
?????文件???????12397??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes\AssetPacker.unity
?????文件?????????174??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes\AssetPacker.unity.me
?????文件???????34317??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes\RectanglePacking.unity
?????文件?????????174??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes\RectanglePacking.unity.me
?????文件?????????191??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes.me
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????文件????????1505??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????文件?????????262??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????文件????????4805??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????文件?????????262??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????文件?????????191??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\sc
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\
?????目錄???????????0??2018-10-15?17:09??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\
?????文件???????13804??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0001.png
?????文件????????2265??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0001.png.me
?????文件???????13810??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0002.png
?????文件????????2265??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0002.png.me
?????文件???????13693??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0003.png
?????文件????????2265??2017-02-02?05:28??UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Sprites\Textures\walking0003.png.me
............此處省略58個文件信息
評論
共有 條評論