资源简介

最近做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 < sprites.Length) {

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.meta
     文件       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.meta
     文件         191  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\Scenes.meta
     目录           0  2018-10-15 17:09  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts\
     文件        1505  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts\AssetPackerExample.cs
     文件         262  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts\AssetPackerExample.cs.meta
     文件        4805  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts\RectanglePackingExample.cs
     文件         262  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts\RectanglePackingExample.cs.meta
     文件         191  2017-02-02 05:28  UnityRuntimeSpriteSheetsGenerator-master\Assets\RuntimeSpriteSheetsGenerator\Demos\scripts.meta
     目录           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.meta
     文件       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.meta
     文件       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.meta
............此处省略58个文件信息

评论

共有 条评论