Author Topic: UIPanel  (Read 50322 times)

vikti

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: UIPanel
« Reply #15 on: August 30, 2014, 02:32:46 PM »
Have you got a code to adjust the size of a collider on uipanel ? (like on uisprite)

vikti

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: UIPanel
« Reply #16 on: August 30, 2014, 02:37:34 PM »
Ho, maybe I found a better way using an invisible widget.


Tulrath

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPanel
« Reply #17 on: September 06, 2014, 11:27:28 PM »
Is there a way to reduce the alpha on a panel (say, for example to 0.1f) without fading the contents?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIPanel
« Reply #18 on: September 07, 2014, 08:51:56 AM »
No, all alpha is cumulative.

eagle

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIPanel
« Reply #19 on: September 09, 2014, 03:44:49 PM »
My scenario is, i want to make 8 panels which i want to get in front as i click relevant button. No sequence of panels will be used, e.g. 1 will be default, and when i click 5, 3 & 7 are clicked, relevant panels should be shown respectively.

How i can achieve this scenario.
Your NGUI tutorials are minimum (i think NO) on panels, please showing this scenario in a tutorial will be much helpful.

Looking forward to your quick reply.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIPanel
« Reply #20 on: September 10, 2014, 01:34:57 AM »
Starlink UI kit has an easy to use windowing system, source code for which I've posted on this forum a long time ago. UIWindow.Show(panel), UIWindow.Close(panel), UIWindow.GoBack() -- trivial stuff.

If you want to show multiple panels at the same time instead of one at a time, then I assume you will want to bring the last activated panel to front. NGUITools.BringForward can do that.

Rahkola

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIPanel
« Reply #21 on: September 27, 2014, 12:57:49 PM »
How is the layering of widgets handled? We would like to add particle systems in the UI and control both panel layer and the widget layer of the particle system.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIPanel
« Reply #22 on: September 27, 2014, 07:30:21 PM »
If you want to insert particles in between of your UI elements, you will need to change the render queue of panels. By default every new panel comes directly after the one before it. If you need to insert a particle system, you will need to interrupt this order.

RetroGuy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPanel
« Reply #23 on: October 01, 2014, 01:06:37 PM »
Is there any way to animate panel scale without affecting bunch of anchored widgets below? I've tried to select "OnEanble" in Anchors Execute options, but of no avail: they continue to stick to panel borders following some weird algorithms whatsoever. Moreover, there is also impossible to move this panel as well. Is there any simple "official" workaround about that? All I'd like to do is to switch off all these smart features for a time, animate window as any other unity object, and that turn control to the panel again. Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIPanel
« Reply #24 on: October 01, 2014, 05:31:40 PM »
Change the anchors to be OnStart.

RetroGuy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPanel
« Reply #25 on: October 04, 2014, 04:16:53 AM »
Oh, thanks. It works. Sometimes you just need to check updates before asking :)

bjennings76

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIPanel
« Reply #26 on: October 18, 2014, 12:08:40 PM »
I struggled for a long time to get the UIPanel to freely resize, but to also respect the restrictions of the UIRoot. I haven't had much luck. It will only work one of two ways:
  • No Constraints - Anchored elements stick to the sides of the panel, even beyond the UIRoot's constraints.
  • Constraints on UIPanel - The anchored elements respect the root UIPanel, but don't slide in when the UIRoot's view is smaller than the UIPanel's constraints.
I feel like there's a setting I'm missing somewhere. I was able to fix it using a custom component, though, which toggles a UIPanel's constraints depending on the UIRoot's view ratio. I'll post it here in case someone else runs into the same problem:

  1. using UnityEngine;
  2.  
  3. [ExecuteInEditMode, RequireComponent(typeof(UIPanel))]
  4. public class UIConstrain : MonoBehaviour
  5. {
  6.     private UIPanel Panel { get { return _panel ?? (_panel = GetComponent<UIPanel>()); } }
  7.     private UIPanel _panel;
  8.  
  9.     private UIRoot Root { get { return _root ?? (_root = GetComponentInParent<UIRoot>()); } }
  10.     private UIRoot _root;
  11.  
  12.     private static float Ratio { get { return Screen.width*1f/Screen.height; } }
  13.     private float MaxRatio { get { return Root.manualWidth*1f/Root.manualHeight; } }
  14.  
  15.     private void Start() { UpdateAnchors(); }
  16.  
  17. #if UNITY_EDITOR
  18.     private void Update() { if (!Application.isPlaying) { UpdateAnchors(); } }
  19. #endif
  20.  
  21.     private void UpdateAnchors()
  22.     {
  23.         if (!Root || !Panel) { return; }
  24.  
  25.         // Ratio is less than max ratio, so release panel constraints.
  26.         if (Ratio < MaxRatio && Panel.clipping == UIDrawCall.Clipping.ConstrainButDontClip) { Panel.clipping = UIDrawCall.Clipping.None; }
  27.  
  28.         // Ratio is more than max ratio, so constrain panel.
  29.         else if (Ratio > MaxRatio && Panel.clipping == UIDrawCall.Clipping.None)
  30.         {
  31.             Panel.clipping = UIDrawCall.Clipping.ConstrainButDontClip;
  32.             Panel.baseClipRegion = new Vector4(Panel.baseClipRegion.x, Panel.baseClipRegion.y, Root.manualWidth, Root.manualHeight);
  33.         }
  34.     }
  35. }
  36.  
« Last Edit: October 28, 2014, 07:41:16 PM by bjennings76 »

RetroGuy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIPanel
« Reply #27 on: October 29, 2014, 04:56:47 PM »
I'd like to implement HP bars on top of characters in the game with NGUI. This UI should be rendered by main camera and be like a 3D object. I've tried to make a construction of UIPanel and label together, and it works fine all in all, but the panels keep rendering huge pink borders (probably treating in-game camera like UI one). It creates a big mess in my scene view, so I'd like to hide it somehow. I can simply get rid of it by commenting OnDrawGizmos code, but I don't want to modify it in such harsh way, especially considering it's quite useful when you make a fully-fledged windows. So the question is, is there some workaround about it? And, what is more important, had I implemented this task in a way it supposed to be?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIPanel
« Reply #28 on: October 30, 2014, 01:16:23 PM »
In-game camera like UI one? Not sure if I follow you there. Your game window can be set to draw gizmos, which you can likewise turn off. Gizmos only draw if the component is not folded in inspector. Gizmos are also editor-only, and have no effect in the game. A pic would help me understand you better.

Cine

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIPanel
« Reply #29 on: February 16, 2015, 02:13:42 AM »
I am trying to have a scroll able panel inside a another panel.
The outer panel has unified anchors at
left -> right -150
right -> right 0
bottom -> bottom 0
top -> top 0
I then want to anchor the inner panel at
left -> left 10
right -> right 10
bottom -> top -45
top -> top -25
That part works just fine, but as soon as I enable soft clipping to get the scrolling view, the center of the clipping stays fixed according to some unknown origin, and not the actual position of the panel. And if I try to update the center or the offset in the inspector, the update is just ignored.
The end result is that whenever I change the size of the screen, the position of the content of the inner panel is left where it was, which means it is lost in clipping somewhere else.
How to fix it, so that it is possible to use clipping and achoring at the same time?