Author Topic: About edit gui in ngui new version  (Read 2219 times)

galuodo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 65
    • View Profile
About edit gui in ngui new version
« on: April 22, 2013, 09:40:49 PM »
We used 2.1.6 to development our gui, and last week I tried to upgrade it to 2.5.1. Some new features like the selection window of sprite is useful, however I find some problems now.

First, NGUI has combined  four kinds of sprite into UISpirte, it is very simple to use, however when we create the shops or items, we used to use UIFilledSprtie and used NGUITOOL NGUITools.AddSprite to add new sprites,
  1.         private UISprite[] m_bagSprite = new UIFilledSprite[ConstPreference.Every_BagItem_Count];
  2.         m_bagSprite[i].type = UISprite.Type.Filled;
  3.         m_bagSprite[i] = NGUITools.AddSprite(anObj.gameObject, m_itemAtlas, "");
  4.  

it shows bug:
ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
(wrapper stelemref) object:stelemref (object,intptr,object)

So I change the code
  1. private UISprite[] m_bagSprite = new UISprite[ConstPreference.Every_BagItem_Count]
and the the type of the sprite to "Filled", the bug still there. So how can I use the filled sprite.

Second, seeing the image of sprite is very useful, however sometimes, when I want to add an Image Button, I really need to know the name of the sprite.Can the name of sprites displayed under the images?

The last problem, using the handle to directly modify th size of sprites in edit mode is cool, however our these sizes is alreadly decided, and sometime I want to change the position, I click the handles and change the sizes, it is very uncomfortable, can I disable those handles?



Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: About edit gui in ngui new version
« Reply #1 on: April 24, 2013, 02:28:41 AM »
1)
  1.  
  2. private UISprite[] m_bagSprite = new UISprite[ConstPreference.Every_BagItem_Count];
  3. m_bagSprite[i].type = UISprite.Type.Filled; //will give null reference error. null.type
  4. m_bagSprite[i] = NGUITools.AddSprite(anObj.gameObject, m_itemAtlas, "");
  5.  

instead do
  1. private UISprite[] m_bagSprite = new UISprite[ConstPreference.Every_BagItem_Count];
  2. m_bagSprite[i] = NGUITools.AddSprite(anObj.gameObject, m_itemAtlas, "");
  3. m_bagSprite[i].type = UISprite.Type.Filled;
  4.  

2)
The name is shown in the inspector when clicking the images. As for having the names inside the previewer, you'll have to talk to ArenMook. I'm not sure it can be done nicely when you have many, many sprites. In any case, if your inspector is next to the previewer, you can see the names in there.

3)
In 2.6.0 you can toggle the new handles off if you wish. For now, you should be able to click the center of the sprite and reposition it without scaling. Alternatively, set the numbers directly in the transform in the inspector.