DaVikingCode/UnityRuntimeSpriteSheetsGenerator
소개
Unity에서 런타임에 SpriteSheet를 생성하세요!
프로그래밍 언어 및 런타임측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalUnity Runtime SpriteSheets Generator
Unity and plugins provide many great ways to build Sprite Sheets. However they're used directly into Unity Editor or with an external software which is perfect in many case, but none provide the ability to generate SpriteSheets at runtime.
The RectanglePacking algorithm is a port of the AS3 version made by Ville Koskela. Assets used in the demo come from Kenney.
You could combine the generated Sprite Sheets.png with a pngquant compression via this script PngQuantNativeProcess.
Please note that Unity provides a Texture2D.PackTextures method, I didn't test it nor made benchmark performances.
Example:
Add the AssetPacker component to your GameObject:
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 () {
string[] files = Directory.GetFiles(Application.persistentDataPath + "/Textures", "*.png");
assetPacker = GetComponent<AssetPacker>();
assetPacker.OnProcessCompleted.AddListener(LaunchAnimations);
assetPacker.AddTexturesToPack(files);
assetPacker.Process();
}
void LaunchAnimations() {
StartCoroutine(LoadAnimation());
}
IEnumerator LoadAnimation() {
Sprite[] sprites = assetPacker.GetSprites("walking");
int i = 0;
while (i < sprites.Length) {
anim.sprite = sprites[i++];
yield return new WaitForSeconds(0.1f);
// loop
if (i == sprites.Length)
i = 0;
}
}
}
관련 프로젝트 살펴보기
불러오는 중…