Author Topic: Labels on different Layers legitimate?  (Read 8520 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Labels on different Layers legitimate?
« on: April 20, 2013, 06:54:32 AM »
So i want to use the nice Labels outside of the UI I made with nGUI.

So first i did this:

- Since i couldn't chose in the Widget-Tool the parent i wanted to  I made an empty GameObject and attached the UILabel-Component to it. Didn't had any effect, i could write something in the Textbox, but it didn't showed up in the Scene/Game-View.


Then i did that:

- i choose the UI-Panel on the GUILayer.
- created a Label with the Panel as Parent
- worked (of course)
- then i took the Label, made it a child of another gameobject outside the UI, changed the Layer of the Label
- worked
-> i can edit the Text and work with all the Settings (Outlines, Pixel-Perfect, etc.)

So: is this okay or will there be some problems concerning the Layers and the UI Behaviour?

And another question:
After some Minutes in the Widget Tool i could choose the Gameobject i wanted first to use as Parent? Why is that? Why couldn't i use it in the first place? And for some reason i only can choose that certain object and the panel. I can drag and drop the hell out of any other gameobject, it only works with that certain Gameobject and the Panel, of course.



By the way: i am using nGUI 2.3.4 (at least, that's what the ReadMe in the Project tells me) -  I bought the Package here at your website and not via the AssetStore. Are there some Updates yet?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #1 on: April 20, 2013, 09:08:56 AM »
Pay close attention to the game object's layer. When creating a child of a UI hierarchy, the label automatically inherits the UI layers. When creating a child of some random game object, it will inherit that game object's layer (likely Default).

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #2 on: April 20, 2013, 09:26:48 AM »
Well, yes, i understand that, but that kind of didn't answer my question.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #3 on: April 20, 2013, 09:31:25 AM »
The widget tool chooses the parent you have selected in the hierarchy. You don't drag anything, just click it.

If it doesn't want to choose the one you want, then you are likely trying to set a widget to be a parent and that's a no go.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #4 on: April 20, 2013, 10:09:14 AM »
Clicked on the Object -> doesn't appear in the WidgetTool Section "Add To", the Panel is autoselected and doesn't change, doesn't matter which Object in the Hierarchy is selected and yeah NONE of the selected Objects are Widget, in fact, the most of them are empty GameObjects...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #5 on: April 20, 2013, 06:04:03 PM »
Are they in the right layer?

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #6 on: April 21, 2013, 03:30:45 AM »
Well that is the thing! I want to use the Labels OUTSIDE of my GUILayer-UserInterface. All my other Objects are in "Default", and i want to create a Label which i can put in an other empty GameObject with that "Default"-Layer.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #7 on: April 21, 2013, 06:29:07 AM »
Aaah, ok. Very well, then you have to make a UIPanel that you use as a parent (or grandparent) for the label you want to make.You also need to take care of the scale of it yourself. If you have the Panel set up first, the widget wizard should recognize that.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #8 on: April 21, 2013, 07:21:31 AM »
Well yes, as said in the first post, that's the way i did it:

- Made a fresh new UI with an automatic made Camera, Anchor and Panel
- selected the Panel in the Widget Tool and created a Label
- dragged the Label out of the Panel and put it in an object outside of the UI I made
-> made the Label a child and changed the Layer manually from GUILAYER to DEFAULT


My original question was: is this way of doing that allright?

Otherwise it didn't work; i attached the UILabel-Component to an Empty GameObject but there was no text displayed on the Scene/Game-View when i edit the Textbox in the Inspector of the UILabel-Component.

Edit:

Maybe it's just my version, i am working with 2.3.4. Since I bought the Plugin here on the website i can't just update it via the AssetStore and the Link I was provided when I bought the plugin just downloads the 2.3.4 version...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #9 on: April 21, 2013, 07:46:27 AM »
You shouldn't have to do all that.

If you're not going to let the UI handle the label, then you don't need a new UI at all.

As long as you have a panel on any object, the widget wizard should be able to recognize that when you select it, and thus you should be able to make it directly as a child of the gameobject you want ( as long as someone in its parantage has a UIPanel).

If you drag the label out somewhere where there's no UIPanel, then I believe the widget will make a panel on itself as it can't be drawn without a panel. If you look at the label in question, it likely has a uipanel component on itself now.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #10 on: April 21, 2013, 08:04:41 AM »
Hm, I think you don't get my "problem" :D

I didn't made a second UI, i just try to explain my steps of procedures so you guys can reproduce it (in your mind).
The UI existed all the time.

I made some pics, maybe it's clearer to understand that why what I want to accomplish.

Here is my Hierarchy:


The UI Root Object and all it's children are on the GUILAYER.
All the Other object have different Layers (most of them DEFAULT).
In the GameObject PLATTFORM 4 there is this Childobject:



In the Scene/Game it looks like this:



And here is the Inspector for the Labek-Object:



As you see i set it also to the Layer DEFAULT.

And the way I did that I already explained above:

- selected the Panel from the UI in the WidgetTool
- created a new Label as a child of the Panel
- dragged it out and put it as a child of the WoodenSign-Object, changed also its layer from GUILAYER to Default

The thing is, it is working but I am not sure if there won't be any future problems with that regarding...i don't know, the fonts, the whole UI-setup etc.
I'm just curious i couldn't do that with the Components itself as I mentioned before:

Created an Empty Gameobject and put the UILabel-Comp:



Edited the Text-Box, but it isn't displayed at all, neither the Scene nor the Game-View:


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #11 on: April 21, 2013, 07:16:25 PM »
The only way you can use a game object hierarchy in your UI is if it's scaled uniformly -- that is all 3 values of the transform's scale match.

If yours don't, then the panel tool will not allow you to select it. Likewise to add to a panel you must first have a panel there. Try this:

1. Create a simple game object, scale (1, 1, 1).
2. Add a UIPanel to it.

Now you will see it in the panel tool and will be able to add children to it.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #12 on: April 22, 2013, 02:48:58 AM »
Allright, i'll keep that in mind :)

But what about the original question:

Can I use Labels on different Layers without problems?
« Last Edit: April 22, 2013, 03:43:44 AM by BehindTheStone »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Labels on different Layers legitimate?
« Reply #13 on: April 22, 2013, 02:55:04 AM »
Yes you can. :)