纳金网

标题: A tileset selector (一) [打印本页]

作者: 会飞的鱼    时间: 2011-11-18 15:13
标题: A tileset selector (一)


           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.
         

作者: tc    时间: 2012-3-5 23:23
呵呵,很漂亮啊

作者: tc    时间: 2012-3-21 23:26
我来顶个

作者: 晃晃    时间: 2012-3-26 23:24
呵呵,很漂亮啊

作者: C.R.CAN    时间: 2012-3-27 23:24
提醒猪猪,千万不能让你看见

作者: tc    时间: 2012-4-3 13:08
你们都躲开,我来顶

作者: C.R.CAN    时间: 2012-4-16 23:21
都闪开,介个帖子,偶来顶

作者: 晃晃    时间: 2012-4-19 23:25
发了那么多,我都不知道该用哪个给你回帖了,呵呵

作者: tc    时间: 2012-4-27 23:22
人过留名!

作者: 奇    时间: 2012-5-10 23:18
真是不错啊

作者: C.R.CAN    时间: 2012-5-28 23:20
加精、加亮滴铁子,尤其要多丁页丁页

作者: C.R.CAN    时间: 2012-6-26 23:21
我就看看,我不说话

作者: tc    时间: 2012-12-3 23:20
不会吧,太恐怖了

作者: 奇    时间: 2013-3-5 23:22
好可爱的字,学习了

作者: 奇    时间: 2013-3-21 23:56
已阵亡的 蝶 随 风 舞 说过  偶尔按一下 CTRL A 会发现 世界还有另一面





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5