Author Topic: Tutorial questions from a new user.  (Read 2789 times)

jRose

  • Guest
Tutorial questions from a new user.
« on: May 01, 2013, 10:10:56 AM »
Hello,

I am a new user of nGUI, very much liking it but I have run into a few questions.

1)   I am working on going through the tutorials and I’m right at the start. Every time I click the “Make Pixel-Perfect” button it resizes my sprites to be much smaller then I have scaled them to be. Always the same size but much smaller then I want. Why is this happening?

2)   In the tutorial they make a sprite that tiles. I see how to make a sprite, I don’t see tiling sprite as an option in the widget tool. What am I missing?

Thanks for your help.

n8

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Tutorial questions from a new user.
« Reply #1 on: May 01, 2013, 10:43:31 AM »
Both questions are fairly simple to answer, but a bit difficult to discover on your own.

1)   I am working on going through the tutorials and I’m right at the start. Every time I click the “Make Pixel-Perfect” button it resizes my sprites to be much smaller then I have scaled them to be. Always the same size but much smaller then I want. Why is this happening?

A sprite is "Pixel Perfect" when it is scaled to the same size that it was originally created at in your image editor.  For instance if you create a an image that is 64X64 pixels in photoshop, then import->add to Atlas->create sprite, then scale the sprite to 128X150, your image is being scaled above it's original intended size and could become blurry or pixelated.  Hitting "Make Pixel Perfect" will bring it back down to 64X64 where the image is not being stretched in any way, restoring it to a clean non pixelated state.  one way of getting around the pixelation is to setup the sprite to be either tiled, or sliced which leads me into your next question:

2)   In the tutorial they make a sprite that tiles. I see how to make a sprite, I don’t see tiling sprite as an option in the widget tool. What am I missing?

to setup a sprite so that it can tiled is very simple just click on the created sprite and you should see a selection box under the color selection that says "Sprite Type". Just select tiled and then you can stretch out your sprite as much as you want and the sprite will tile to fill the space.

you follow the same instructions above to set the sprite as sliced, however there is another step you must take to see the full effect of this type of sprite.
First find the atlas prefab in your project (you can do this by selecting the atlas in the widget wizard window, Unity will highlight the corresponding prefab your project).  Select the atlas prefab and you will see a UI in the inspector for modifying some of the properties of the atlas.

Select the sprite that you are wanting to make sliced, then adjust the "Border" fields to your liking.  You can watch where the borders are in the sprite preview below.  You will want to move your borders in to the point where your sprite's outer edge is outside of the border, this mode will cause the part of the sprite that is "inside" of all the borders to be stretched, while keeping the part of the sprite outside of the borders to be pixel perfect

I hope this helps you get off the ground




jRose

  • Guest
Re: Tutorial questions from a new user.
« Reply #2 on: May 01, 2013, 06:52:44 PM »
Extreemly useful, thank you

andrejvojtas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Tutorial questions from a new user.
« Reply #3 on: May 01, 2013, 11:00:48 PM »
I run into the same thing: hitting 'Make Pixel Perfect' did re-size the sprite, but the result in my Game View was much smaller then expected.

This was because I didn't delete the Main Camera and didn't run the NGUI > Open the UI Wizard option and the scene was not set up properly. Instead I just run NGUI > Create a Texture. And the scene looks pretty much the same, the trick is which camera is setup to display the textures/sprite. If you don't run the wizard, the main camera is showing NGUI elemments and the main camera is not in the correct position, so the make pixel perfect results into not correct size on screen.

It's all about setting ONLY the camera that is parented to UI Root (2D) to display the NGUI elements. You can achieve this with camera mask culling options and adding the NGUI elements to a layer, that is visible only by the correct camera.