레이블이 Texture Packer in Unity인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Texture Packer in Unity인 게시물을 표시합니다. 모든 게시물 표시

2013년 11월 28일 목요일

Texture Packer in Unity_Step4. Texture Packer Helper제어를 통한 Sprite Texture 구현


1. Step3에서 만들어놓은 Test Plane에다가 아래의 Script를 추가


Sprite.cs
using UnityEngine;
using System.Collections;

public enum SpriteType {
    Once,
    Loop,
}

public class Sprite : MonoBehaviour {
    
    public SpriteType _Type;
    public string _TextureName; // texture Name
    public int _MaxFrame; // Texture Frame Length
    public float _Dealay; // Sprite play Dealay 
    
    private TPHelper _TPH;
    private int _NowFrame; // now frame Num
    void Awake() {
        _TPH = GetComponent<TPHelper>();
    }
    
    // Use this for initialization
    void Start () {
        _NowFrame = 1;
        StartCoroutine(PlaySprite());
    }
    
    // Update is called once per frame
    void Update () {
    
    }
    
    IEnumerator PlaySprite() { //is Recursion Function
        _NowFrame++;
        yield return new WaitForSeconds(_Dealay);
        _TPH.OnTextureChange(_TextureName + _NowFrame.ToString()); 
        
        if(_NowFrame == _MaxFrame && _Type == SpriteType.Loop) _NowFrame = 0;
        if(_NowFrame == _MaxFrame && _Type == SpriteType.Once) yield return null;
        if(_NowFrame != _MaxFrame) { 
            StartCoroutine(PlaySprite()); 
        }
    }
}




2. Inspector창에서 Property값 변경 





3. Play 후 확인.

ps. 가장 최대한 이해하기 쉽게끔 작성한 코드라서 난이도 측면에서는 아주 쉬우실듯.
이런식으로 TPHelper 컴포넌트에 접근하여서 Texture 수정 , Atlas변경을 할수있으니 
입맛대로 코딩하셔서 사용하시면됩니다 ^ㅡ^

Texture Packer in Unity_Step3. Unity내에 Atlas 불러오기온 뒤 Texture Plane생성하기


pre. Custom Plane Mesh를 사용하지않고 TexturePacker 자체에서 Sprite Object를 생성해주는 기능이 있긴하지만.. 스크립트상에서 접근하여 다루기가 불편하여 이런식으로 작업을 진행하였습니다. ㅎㅎ Custom Plane? -> 링크

 1.이전 Step에서 만들어논 Atlas이미지를 Unity Asset/Resources폴더에 위치시킨다.
 (* .txt파일포함)


2.Texture Import Setting값 조정

3. .txt파일 이름 수정 Test_data -> 생성된 Atlas material 확인  


4. 게임에 사용할 Custom Plane 생성(X,Y축 사용시 Vertical로 생성)



5.생성된 Plane에 TPMesh Texture Ex 컴포넌트 추가



6.자동으로 Add되는 TPHelper 속성에 Atlas를 Test로 선택.


7.End

(texture속성을 봐꿔가면서 확인해보시길^^)


2013년 11월 25일 월요일

Texture Packer in Unity_Step2. Texture Packer를 활용한 Texture Atlas 생성하기.


 1. Texture Packer 실행

 2. Atlas를 만들 대상이 되는 Image파일들 Drag & Drop


3. TextureSettings Option 조절


Force Squared - Check
[ Atlas Texture 정사각형 이미지로 제작 ]
Algorithm - Basic 
[ Max Rect는 Full Version Only라고 되어있더군요...
근데 Max Rect mode로 진행해도 이상이 없는? ]

Trim mode - 2D texture : Trim 
                   3D texture : None

Allow Rotation -  Check 해제
[ Allow Rotation 또한 Full version only... ^^ ]
Border , Shape Padding - 1

그외에 옵션들도 궁금하시면 조금씩 수정해보면서 확인해보시면 됩니다.


4. Publish (ctrl + P)
 - 만들어진 Atlas 이미지 확인


Texture Packer in Unity_Step1. 준비물



 Unity내에서 Texture Packer를 활용하여 이미지 처리를 진행할경우 필요한 것들.

1. Texture Packer - 다운로드

2. Asset Store -> Texture packer Asset 다운로드 ( 저는 Free 버전을 사용하여 진행 )





2013년 11월 22일 금요일

[Texture Packer in Unity] Update 예정


Update 예정

texture packer를 활용한

Unity에서 sprite , animation 등으로 활용하는법