Impressed by Demosthenes's article Use this script to reduce unity build size.
- Sprite Texture Loader
- Sprite Animation Loader
- Simple Sprite Texture Pool
- Simple Sprite Animation Pool
- Animator Helper
- And Editor Inspector Helper
How to use SpriteTextureLoader Step by Step
- Add Image or SpriteRenderer to GameObject
- Assign a texture you want.
- Add SpriteTextureLoader script.
- Select 'Type' you added(Image or SpriteRenderer).
- Please select another GameObject and select it. - There is a bug. SpriteTextureLoaderEditor coundn't refresh itself.
- Check options you want.
- ColorChangeWhenComplete : If sprite is loaded, they appears smoothly.
- AutomaticLoad : When this object enables, Load automatically.
- LoadInRuntime : Use this object with SpriteTexturePool.
- Click "MakeImageName"
- Image Name, Image Idx property will be changed.
- Click "Create Meta Data"
- This creates meta data about your texture import setting. Such as Single, Multiple, Pivots.
- File name will be /Assets/StreamingAssets/[Image Name].json
- Click "Create .bytes Texture"
- This function copies /Assets/foo/bar/[Image Name].* to /Assets/StreamingAssets/[Image Name].bytes so Unity recognize this as text.
- Don't click "Clear" button. This clears SpriteTextureLoader settings.
- Thie means you will assign Image name manually.
- Click "Finish".
This script creates some context menus in Project Window. You can click "Create .bytes Texture" menu to create .bytes texture manually.
This script works with SpriteTextureLoader to use Animator. With this script, You can implement sprite animation.
- You should create Animator and Animations.
- Add SpriteTextureLoader script and create .bytes texture described in Sprite Texture Loader Usage.
- Add SpriteAnimationLoader script.
- Check options you want.
- ColorChangeWhenComplete : If sprite and animation are loaded, they appears smoothly.
- AutomaticLoad : When this object enables, Load automatically.
- LoadInRuntime : Use this object with SpriteTexturePool.
- AutoEnable : When this object enables, Play automatically.
- Before Use this Click "Make First Frame" in Animator.
- This described in below AnimatorEditor section.
- Click "Make AnimatorName".
- Animator Name property will be changed.
- Click "Create Animator Meta Data".
- This creates meta data about your animator in /Assets/StreamingAssets/Anim_[Animator Name].json
- Click "Remove Sprite Animator Data".
- This function will remove your animator data so that their sprite animation data will be deleted.
- Don't Click "Restore Sprite Animator Data".
- This needs when you edit animation data in Animator and Animation Window.
- Don't Click "Clear".
- Thie means you will assign Animator name manually.
- Click "Finish".
Nothing to explain.
This script implements simple texture pool. Supports Preload enumerator to load all textures when start. This prevents loading lag.
- Add GameObject into your first scene.
- Add SpriteTexturePool script.
- If you want to load all textures in loading time. Use Preload Enumerator.
- Click "Make Streaming Texture List" to save all .bytes texture lost.
- Save this GameObject.
This script implements simple animator pool. Supports Preload enumerator to load all animators when starts. This prevents loading lag.
- Add GameObject into your first scene.
- Add SpriteAnimationPool script.
- If you want to load all textures in loading time. Use Preload Enumerator.
- Click "Make Streaming Animator List" to save all .bytes texture lost.
- Save this GameObject.
If your game change animatior transition. SpriteAnimationLoader coundn't know about first frame's image or sprite assignment. So you should make meta data about it. This creates "Make First Frame" button in Animator to do this.
Change Animator in runtime.
var animLoader = Cat.GetComponent<SpriteAnimationLoader> ();
animLoader.ChangeTo ("newAnimatorName");
animLoader.Load ();
Change Sprite in runtime.
var loader = image.GetComponent <SpriteTextureLoader> ();
loader.ChangeTo ("newImageName", "newImageIndex");
loader.Load ();
I use these script to development my game. It's on Apple Appstore and Google Playstore.