Author Topic: Several questions  (Read 5315 times)

Shorinji

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Several questions
« on: June 11, 2012, 01:56:16 AM »
Hi all,

I am currently evaluating NGUI with the free version.
I have several questions. Note that i am new to Unity as well so my questions might be dumb, i apologize in advance.

-There is a editor tool that creates the widgets for you, does this mean that we cannot create widgets through script? If we can are there specific things we should take care of?

-I tried to make a custom widget by adding widgets as children of an empty gameobject. It work for some widgets, but the slicedsprite did not display correctly. Is it normal or not? Is there a way to make customs widgets?

-I would like to display a box around the model of the selected targets in my game, is there an easy way to do that with NGUI?

Thanks in advance
Shorinji

dlewis

  • Guest
Re: Several questions
« Reply #1 on: June 11, 2012, 02:48:25 AM »
In response to the first 2 questions.

'Widgets' are just gameobjects with one or more pre-assigned NGUI scripts attached. It's possible to make 'widgets' without using the Create/Add widget tool that NGUI has but there are more steps required.

For example, a sliced sprite script will need a texture atlas linked in as well as a sprite selected (I can't check all the steps for that example now since I don't have NGUI at home).

For the last question, it would be possible to display a box around something in the game (and there would be many ways to do it). The first thing I would attempt would be to use a sliced sprite, turn off 'render inside' so that you only have the outside (borders) showing and then dynamically change the X and Y scales depending on whatever maths are appropriate for the situation (ie. distance from camera, screen space it's taking up, bounding box etc).

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Several questions
« Reply #2 on: June 11, 2012, 03:11:47 AM »
I'm just here to backup dlewis, he says right things.

Making widgets from code is easy. Look into NGUITools.AddSprite/AddChild/AddWidget for details.

Making a border can be tricky, because you have to make it fit yourself, but it's certainly possible.

Shorinji

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Several questions
« Reply #3 on: June 11, 2012, 04:13:09 AM »
Hey, thanks for your answers.

Actually the question about the border was for an easy way to size it. I saw that another GUI named blindGUI seems to be able to do that so i though the NGUI might have this feature, but from what you say it seems it doesn't.

What about the slicedpanel which doesn't display correctly when child of an empty object (this empty object is under a UIPanel object)? Is it a bug or did i miss something?

PhilipC

  • Guest
Re: Several questions
« Reply #4 on: June 11, 2012, 09:01:57 AM »
A picture would help a lot in the case of the sliced panel not displaying correctly.

Shorinji

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Several questions
« Reply #5 on: June 11, 2012, 10:59:15 AM »
Hi,
I investigated a little bit in order to find the exact way how to reproduce the issue and i think i found it.
I am using the SciFi atlas.
It appears when SlicedSprite scale is too small.
Actually the parent GameObject was not involved in it, it just made the issue very obvious because i was scaling it up.
Now that i found that, i think it's not really a bug, it's just a limitation on the minimum size of a SlicedSprite. But anyway i don't think anyone will find it useful to have very small SlicedSprites, so i don't thing anything needs to be done here.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Several questions
« Reply #6 on: June 11, 2012, 06:55:15 PM »
If you make sliced sprite smaller than its borders, you're gonna have a bad time.