Author Topic: Feature request/suggestion: Auto 9-slice & Pipeline  (Read 8530 times)

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Feature request/suggestion: Auto 9-slice & Pipeline
« on: January 21, 2015, 03:53:52 AM »
Hi Aren!
We have a nice suggestion for NGUI! Here is the workflow that'll save hours of routine for GUI devs:
1) Designer prepares set of UI pngs
2) GUI dev opens NGUI Atlas Maker and adds them.

2.1.1) Atlas Maker checks if current image has android-style 9-patch "special marks" on the top and left (http://developer.android.com/tools/help/draw9patch.html)
2.1.2) If marks were found - Atlas Maker automatically shrinks current sprite to the minimal size before writing to atlas and writes default 9-slice guides positions for this sprite in Atlas metadata (or somewhere else)

2.2.1) If user clicks a button "Prepare for 9-slice" near sprite name in a list of sprites in the Atlas Maker before Atlas update the special window is shown.
2.2.2) In "Prepare for 9-slice" window user makes just one click - the approximate center of sprite. This step is needed because slice center not always is a sprite center (http://service.crazypanda.ru/v/clip2net/0/y/MGN1MRLgp9.png)
2.2.3) Le Auto-Shrink process! Script iterates through columns of pixels of the sprite to left and right from user defined "center" and checks if current column is the same like previous column. If columns are equal Script deletes it.
2.2.4) Same for sprite rows.
2.2.5) Atlas Maker writes default 9-slice guides positions for this sprite in Atlas metadata (or somewhere else)

This feature will save a tremendous amount of time for devs and designers.
The situation is that now we have 3 in-development mobile titles which are very heavy on UI: RPGs and MMO Strategy.
Now the pipeline we use is:
1) Designer draws a window with all possible states.
2) Designer exports all graphics using Adobe Generator to the set of PNGs
3) Designer imports all shrinkable graphics into... Fireworks! lol (this is THE ONLY tool that allows pixel based 9-slice scaling)
4) Designer tries to determine "where this f**n inner glow ends in this corner", draws a red vector lines and sets a 9-slice guides: (http://service.crazypanda.ru/v/clip2net/V/x/EbHhVj2Uab.png)
5) Designer shrinks panel to the minimal size (here comes another surprise! Fireworks can not do this pixel perfect...)
6) Designer saves two versions of sprite: "with red guides" suffixed with underscore (_) and "without red guides"
7) Developer imports panels with red guides to the NGUI Atlas.
8 ) Developer tries 3-4 times to set sprite 9-slice guides along with red line guides.
9) Developer updates sprite in the atlas maker with version with "no red lines"

As you see: this is a real hell :)
« Last Edit: January 21, 2015, 04:06:57 AM by artfabrique »

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: Feature request/suggestion: Auto 9-slice & Pipeline
« Reply #1 on: January 21, 2015, 07:38:25 AM »
It's a good idea but I think it will increase a lot the import process in the atlas because ReadPixel of a texture is very slow.

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: Feature request/suggestion: Auto 9-slice & Pipeline
« Reply #2 on: January 21, 2015, 08:36:27 AM »
It's a good idea but I think it will increase a lot the import process in the atlas because ReadPixel of a texture is very slow.
I dont think so.
First - it's a manual triggered operation, so if user does not want it it will be at the same speed.
Second - GetPixels32/SetPixels32, not ReadPixels should be used. http://docs.unity3d.com/ScriptReference/Texture2D.GetPixels32.html
And it's fast enough even for runtime usage. We've done in-game fingerpainting mechanics using it.
« Last Edit: January 22, 2015, 11:47:43 AM by artfabrique »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Feature request/suggestion: Auto 9-slice & Pipeline
« Reply #3 on: January 25, 2015, 01:14:38 PM »
This sounds like a cool idea.

I think it's hard to build into the existing atlas maker as it is, but I imagine it would be more doable to extend the atlas maker so you can make your own strategy for importing, that way automating whatever you need to do.

If you do some work on it, you can basically copy most of what the atlas maker does now and fiddle in your 9patch magic, and if you want it to be part of NGUI, try to do it in a way that extends the existing atlas maker, so you can use "Auto 9-slice importer" instead - I'm sure ArenMook will virtualize/protected any members of methods you would need for this.