Monday, June 23, 2014

Camera and Texture settings to make 2d game in Unity

Here are some basic Camera and Texture setting for 2d game development in Unity3d,


(1). Choose 'Point' as the filter mode for your textures.
(This is essential for making your textures sharp).

(2). Choose 'Advanced' as your 'Texture Type' and disable 'Generate Mip Maps'.
(This is also important for 2d game, it reduces texture size as well).

(3). Choose 'RGBA 32 bit' as your 'Texture Format'.
(Choose lesser until your texture quality remains, this is also for texture memory size).

(4). Set your Camera Projection to 'Orthographic'.
(To make game for 2d view only).

(5). Set your 'Orthographic Size' to your screen height / 2.
(This makes 1 unit in Unity equals 1 pixel on your textures).

(6). Create a Quad by following Menu -> GameObject -> Create Other -> Quad in Unity.

(7). Scale your Quad to same size as your texture.
(A 256*256 texture needs a 256*256 quad).

Note : Textures you are using must be POT(Power Of Two) textures.

Code snippets to set Camera size,


using UnityEngine;


public class 2dCameraScale: MonoBehaviour 
{
    void Awake () 
    {
        Camera.main.orthographicSize = Screen.height / 2;
    }
}

Post Note : The topic is posted for Unity3d v. 4.2.1 or older mainly, in newer versions their are lots of 2d related stuffs are added. Though you can use above settings for newer version also. ;)

No comments:

Post a Comment

Popular Posts