Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Annoying panel issue.

Discussion in 'Scripting' started by unity_IdF3Y7NrR21HSw, Jun 26, 2018.

  1. unity_IdF3Y7NrR21HSw

    unity_IdF3Y7NrR21HSw

    Joined:
    Apr 3, 2018
    Posts:
    32
    I`m trying to flash a panel over another panel but no matter how hard I try and what I do I just can`t seem to bring a panel over the other, can`t get either panel to be displayed on top of another, if I want to use a panel I need to wait for it to end (SetActive(false)) then bring up the other panel and viceversa what do I need to do in order to have a main panel active for 2 seconds and have another one flash on top of the first panel for .2 seconds? Changing the panel order in the hierarchy doesn`t seem to help at all.

    Panel 1 script:
    Code (CSharp):
    1. public void Freeze()
    2.     {
    3.        
    4.         StartCoroutine(freeze());
    5.     }
    6.  
    7.     public IEnumerator freeze()
    8.     {
    9.         freezeScreen.SetActive(true);
    10.         Time.timeScale = freezeIntensity;
    11.         yield return new WaitForSeconds(freezeTime);
    12.         Time.timeScale = 1f;
    13.         freezeScreen.SetActive(false);
    14.    
    15.  
    16.     }
    The public void Frenzy is attached to a button that brings up the main panel I want to be rendered under the flashing one.

    Panel 2 script:
    Code (CSharp):
    1.  public void Frenzy()
    2.     {
    3.         frenzyActive = true;
    4.         StartCoroutine(frenzy());
    5.     }
    6.  
    7.     IEnumerator frenzy()
    8.     {
    9.        
    10.         frenzyScreen.SetActive(true);
    11.         yield return new WaitForSeconds(0.2f);
    12.         frenzyScreen.SetActive(false);
    13.        
    14.     }
    This is the button that flashes the panel for .2 seconds.

    As I mentioned, changing the panel order is useless as after I press the first button and bring up the main panel I need to wait for it to end before being able to flash the second panel and vice versa (did a lot of tests regarding this manner, even increased the flashing time to 2 seconds instead of .2)

    What else can be causing this problem?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    I'm not sure if you mean Panel as in the UI panel (which is just technically an image with some adjusted settings), but all ui is rendered in the order of the children. Which means the last child is always drawn on top. But this applies to a single canves as you can have multiple canves in your scene and set an order on them which will determine which group of children is drawn first.

    If you mean panel as in something else, then I'd need more info on them.
     
  3. unity_IdF3Y7NrR21HSw

    unity_IdF3Y7NrR21HSw

    Joined:
    Apr 3, 2018
    Posts:
    32
    I mean panel as in the UI, I do have more than just one canvas though but regardless of the panel order in the canvas children I still can`t activate one panel before the other is deactivated.
     
  4. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Do you mean that the panels are not transparent?

    So if you have both panels active (and keep them active) and then, in the Editor, you reorder the panels, you mean you see only the last panel (the one lowest in the hierarchy as Brathnann mentioned previously)?
     
  5. unity_IdF3Y7NrR21HSw

    unity_IdF3Y7NrR21HSw

    Joined:
    Apr 3, 2018
    Posts:
    32
    No, I just see whichever panel I activate first, can`t activate any other before the first one goes away, regardless of which one I set active first. The panels are indeed transparent but this has nothing to do with our issue.
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    If you lay out

    canves
    --Panel 1
    --Panel 2

    And everything is active and panel 2 is over panel 1, then there is nothing wrong with your hierarchy, so it's a code issue at that point.

    I do see a time.timescale adjustment in your first script. Are you doing something with timescale?
     
  7. unity_IdF3Y7NrR21HSw

    unity_IdF3Y7NrR21HSw

    Joined:
    Apr 3, 2018
    Posts:
    32
    Yeah, I`m adding a cool slow down effect, a freeze down where everything slows down.I`m gonna comment it out and see if there`s any change.
    Edit: no change whatsoever, still have the issue.
     
    Last edited: Jun 27, 2018
  8. unity_IdF3Y7NrR21HSw

    unity_IdF3Y7NrR21HSw

    Joined:
    Apr 3, 2018
    Posts:
    32
    upload_2018-6-27_2-45-46.png
    This is how my hierarchy looks like, frenzy should be displayed on top of freeze but yet it doesn`t.
     
  9. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    The hierarchy looks fine, but, I'm not sure I know what is suppose to be happening in the game view. I see what looks like two icons. Are those suppose to be on top of each other? Where are the panels?