- 最后登录
- 2014-10-23
- 注册时间
- 2011-7-19
- 阅读权限
- 90
- 积分
- 81303
 
- 纳金币
- -1
- 精华
- 11
|
When building a sprite-based game, you often must take a tileset and find some way to split it into the hundred smaller sprites used in your game. If you're using Unity, a 3D game editor, then there is no easy way to do this. The task will take you so many hours with photoshop that you'll develop carpal tunnel syndrome and a burn-in of the ps UI.
Lo, behold the Tile Selector, a system that takes a tileset and chops it up into bite-sized pieces that you specify, using a custom editor that makes the process easy. It even generates all the materials and textures you need, stores them discreetly, and applies them to your object as necessary.
Usage
The TileSet comprises three scripts. TileManagerEditor and TileSelectorEditor are Editor scripts and must be placed in the Editor folder of your project hierarchy. TileManager is the base script that kicks off the magic, and is a component attached to the sprite you want to texture.
![]()
Step 1
Create a GameObject (frequently a plane) and attach a material (frequently with a Transparent Cutout shader) to it. The GameObject must have a material and the TileManager (below) script attached to it, or the Tile Selector won't work.
Step 2
Attach this script to the GameObject:
/*
Copyright 2010 CJ Currie
@Date: October 2010
@Contact:
CJCurrie@BlackStormsStudios.com
@Script: A storage class for the tile selector.
@Connections:
@TODO:
*/
using UnityEngine;
using UnityEditor;
public class TileManager : MonoBehaviour {
public int[] lastTile = new int[4];
public Texture currentTile = new Texture();
public string uniquePath = "";
public string uniqueID = "";
}
Note that this is a storage class. If you want to pull data from the custom editor, store it here.
|
|