Adventure Creator Wikia
(Created page with "1. Upgrade to Unity 2018.2 or greater none|thumb|466x466px 2. Goto Window > Package Manager and download 2D Pixel Perfect. [[File:PIC1 (1).png|left|thumb|220...")
Tag: Visual edit
 
No edit summary
Tag: Visual edit
Line 3: Line 3:
 
2. Goto Window > Package Manager and download 2D Pixel Perfect.
 
2. Goto Window > Package Manager and download 2D Pixel Perfect.
 
[[File:PIC1 (1).png|left|thumb|220x220px]]
 
[[File:PIC1 (1).png|left|thumb|220x220px]]
 
[[File:Newpixcam.PNG|left|thumb|220x220px]]
 
[[File:Pic2 (1).png|left|thumb|220x220px]]
 
 
3. Add Pixel Perfect Camera script AC's to MainCamera.
 
3. Add Pixel Perfect Camera script AC's to MainCamera.
 
4. After importing your textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you can use Unity 2018's Presets for this).
 
4. After importing your textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you can use Unity 2018's Presets for this).
Line 18: Line 17:
 
on PPC and copy the new camera component settings, click "Run In Edit Mode" and, then paste them back into the camera as values.
 
on PPC and copy the new camera component settings, click "Run In Edit Mode" and, then paste them back into the camera as values.
 
[[File:Cropp.png|none|thumb|220x220px]]
 
[[File:Cropp.png|none|thumb|220x220px]]
  +
This is MASSIVELY important if you want to use UI's in camera space, or you have any UI issues where the canvas scaler isn't fitting the screen properly.
5. If you need to import any more textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you should be using Presets to do this).
 
   
  +
Notice I also used stretch fill? That will look ugly and blurry by default. But fear not, we can hack!
 
[[File:Findthis.PNG|none|thumb|220x220px]]
  +
Double-click PixelPerfectCamera (with the camera icon) to edit the script in VS and find this line at 187:
  +
[[File:Codd.PNG|none|thumb|220x220px]]
  +
''RenderTexture activeRT = m_Camera.activeTexture;''           
   
  +
''if (activeRT != null)''               
6. In the Sprites' Inspector window, set their Filter Mode to Point.
 
[[File:2 D Pix image 2.png|none|thumb|220x220px]]
 
   
  +
''activeRT.filterMode = m_Internal.useStretchFill ? '''FilterMode.Bilinear''' : FilterMode.Point;''
  +
  +
                and change it to
  +
  +
''RenderTexture activeRT = m_Camera.activeTexture;''           
  +
  +
''if (activeRT != null)''               
  +
  +
''activeRT.filterMode = m_Internal.useStretchFill ? '''FilterMode.Point''': FilterMode.Point;''
  +
[[File:Coddd.PNG|none|thumb|220x220px]]
  +
                This ensures that you'll have sharp pixels, even if stretch fill is used. This means that non integer sizes may be a bit pickled, but it's better than using bilinear ''(actually, if the RT upscaled to the closest smaller integer, THEN applied bilinear before upscaling to the final resolution, that would be better, but we can't have everything, can we? :p)''
  +
 
5. If you need to import any more textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you should be using Presets to do this).
  +
[[File:Pic3 (1).png|none|thumb|286x286px]]
 
6. In the Sprites' Inspector window, set their Filter Mode to Point.[[File:2 D Pix image 2.png|none|thumb|220x220px]]
   
 
7. Set their Compression to 'None'.
 
7. Set their Compression to 'None'.
Line 36: Line 54:
 
# Under the Sprite settings, select Custom from the Pivot drop-down menu. Then select Pixels from the Pivot Unit Mode drop-down menu. This allows you to input the pivot point's coordinatess in pixels, or drag the pivot point around freely in the Sprite Editor and have it automatically snap to pixel corners.
 
# Under the Sprite settings, select Custom from the Pivot drop-down menu. Then select Pixels from the Pivot Unit Mode drop-down menu. This allows you to input the pivot point's coordinatess in pixels, or drag the pivot point around freely in the Sprite Editor and have it automatically snap to pixel corners.
 
# Repeat step 4(3) for each Sprite element as needed.
 
# Repeat step 4(3) for each Sprite element as needed.
  +
[[File:2 D Pix image 4.png|none|thumb|220x220px]]
 
 
 
To ensure the pixelated movement of Sprites are consistent with each other, follow the below steps to set the proper snap settings for your project.
 
To ensure the pixelated movement of Sprites are consistent with each other, follow the below steps to set the proper snap settings for your project.
 
# Open the Snap Settings at menu: Edit > Snap Settings...
 
# Open the Snap Settings at menu: Edit > Snap Settings...
 
# For Move X/Y/Z, set their values to '1 divided by the Asset Pixels Per Unit (PPU) value'
 
# For Move X/Y/Z, set their values to '1 divided by the Asset Pixels Per Unit (PPU) value'
 
# Snap settings are not applied retroactively. If there are any pre-existing GameObjects in the Scene, select each of them and click Snap All Axes to apply the Snap settings.
 
# Snap settings are not applied retroactively. If there are any pre-existing GameObjects in the Scene, select each of them and click Snap All Axes to apply the Snap settings.
  +
These are my settings for PPU of 20:
  +
[[File:Mysnap.PNG|none|thumb|220x220px]]
 
If you are using ProGrids (highly recommended!!) it will follow Unity's snap settings by default (check the preferences if it isn't)
   
  +
And that should be it! Read the manual for further instructions: 
   
 
https://github.com/Unity-Technologies/2d-pixel-perfect/blob/master/Documentation/2D%20Pixel%20Perfect%20Camera.md
If you are using ProGrids (highly recommended!!) it will follow Unity's snap settings by default (check the preferences if it isn't)
 
 
And that should be it! Read the manual for further instructions: https://github.com/Unity-Technologies/2d-pixel-perfect/blob/master/Documentation/2D%20Pixel%20Perfec...
 

Revision as of 14:26, 28 August 2018

1. Upgrade to Unity 2018.2 or greater

Pic5

2. Goto Window > Package Manager and download 2D Pixel Perfect.

PIC1 (1)
Newpixcam

3. Add Pixel Perfect Camera script AC's to MainCamera. 4. After importing your textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you can use Unity 2018's Presets for this).

I use 20 PPU since it makes sure a Lucasarts sized character is roughly the same height as Brain2D (the custodian of all Unity character sizes and as such his dimensions should be closely observed!)

I also use 384x216 as the reference resolution so the pixel size on screen is very similar to the older games when stretched to 1920x1080, but you can use 320x180 if you want pixel-perfectness for even more integer resolutions between 1920x1080.

If your camera appears with a larger size than the reference resolution (green line is smaller than white line):

Shouldnt

Make sure you resize the camera size to the same size as Pixel Perfect camera script will set it to during the game. To do this permanently, click "Run In Edit Mode":

Click1

on PPC and copy the new camera component settings, click "Run In Edit Mode" and, then paste them back into the camera as values.

Cropp

This is MASSIVELY important if you want to use UI's in camera space, or you have any UI issues where the canvas scaler isn't fitting the screen properly.

Notice I also used stretch fill? That will look ugly and blurry by default. But fear not, we can hack!

Findthis

Double-click PixelPerfectCamera (with the camera icon) to edit the script in VS and find this line at 187:

Codd

RenderTexture activeRT = m_Camera.activeTexture;           

if (activeRT != null)               

activeRT.filterMode = m_Internal.useStretchFill ? FilterMode.Bilinear : FilterMode.Point;

                and change it to

RenderTexture activeRT = m_Camera.activeTexture;           

if (activeRT != null)               

activeRT.filterMode = m_Internal.useStretchFill ? FilterMode.Point: FilterMode.Point;

Coddd

                This ensures that you'll have sharp pixels, even if stretch fill is used. This means that non integer sizes may be a bit pickled, but it's better than using bilinear (actually, if the RT upscaled to the closest smaller integer, THEN applied bilinear before upscaling to the final resolution, that would be better, but we can't have everything, can we? :p)

5. If you need to import any more textures into the project as Sprites, set all Sprites to the same Pixels Per Unit value (you should be using Presets to do this).

Pic3 (1)

6. In the Sprites' Inspector window, set their Filter Mode to Point.

2 D Pix image 2

7. Set their Compression to 'None'.

2 D Pix image 3

8. Set their pivot point to pixels.

Pic4 (1)


8. Follow the steps below to correctly set the pivot for a Sprite

  1. Open the Sprite Editor for the selected Sprite.
  2. If Sprite Mode is set to Multiple and there are multiple Sprite elements, then a pivot point must be set for each individual Sprite element.
  3. Under the Sprite settings, select Custom from the Pivot drop-down menu. Then select Pixels from the Pivot Unit Mode drop-down menu. This allows you to input the pivot point's coordinatess in pixels, or drag the pivot point around freely in the Sprite Editor and have it automatically snap to pixel corners.
  4. Repeat step 4(3) for each Sprite element as needed.
2 D Pix image 4

To ensure the pixelated movement of Sprites are consistent with each other, follow the below steps to set the proper snap settings for your project.

  1. Open the Snap Settings at menu: Edit > Snap Settings...
  2. For Move X/Y/Z, set their values to '1 divided by the Asset Pixels Per Unit (PPU) value'
  3. Snap settings are not applied retroactively. If there are any pre-existing GameObjects in the Scene, select each of them and click Snap All Axes to apply the Snap settings.

These are my settings for PPU of 20:

Mysnap

If you are using ProGrids (highly recommended!!) it will follow Unity's snap settings by default (check the preferences if it isn't)

And that should be it! Read the manual for further instructions: 

https://github.com/Unity-Technologies/2d-pixel-perfect/blob/master/Documentation/2D%20Pixel%20Perfect%20Camera.md