- Home /
Other
How to make everything inside a panel visible and on top of everything ?
"LevelCompletedPanel" is the one that I am trying to make it on top of everything when a level is finished. This panel is inactive and its children are active as default. And this is what I do on scripting :
public static GameObject panel;
private void Start()
{
panel = GameObject.Find("GameManager/ExtraCanvas/LevelCompletedPanel");
}
public static void LevelCompleted()
{
instance.StartCoroutine(LevelFinished());
}
public static IEnumerator LevelFinished()
{
yield return new WaitForSeconds(1f);
panel.SetActive(true);
yield return new WaitForSeconds(5f);
panel.SetActive(false);
GoBack();
}
public static void GoBack(){
activeScene = SceneManager.GetActiveScene().buildIndex;
Debug.Log ("active : " + activeScene);
switch (activeScene)
{
case 1:
SceneManager.LoadScene(0);
break;
case 2:
SceneManager.LoadScene(1);
break;
case 3:
SceneManager.LoadScene(1);
break;
case 4:
SceneManager.LoadScene(2);
break;
case 5:
SceneManager.LoadScene(2);
break;
case 6:
SceneManager.LoadScene(3);
break;
case 7:
SceneManager.LoadScene(3);
break;
}
}
Then I call it on another script in Update function like this :
if (pieces.transform.childCount == 0)
{
for (int i = 0; i < 1; i++)
{
gameObject.transform.position = last_position;
score = GameObject.Find("GameManager/ExtraCanvas/LevelCompletedPanel/EarnedPointsText").GetComponent<Text>();
score.text = "10 puan kazandın !";
_GM.AddScore(10);
_GM.LevelCompleted();
}
}
I have more than one game, this is only one example, I call LevelCompleted() function on different places but when I build the project all I can see is background of this panel and EarnedPointsText, others are not visible. I've already changed everything's sorting layer even the particles'. I would appreciate any help. Thanks. [1]: /storage/temp/115668-screenshot-1.png
Answer by Karsten · Apr 24, 2018 at 08:42 PM
Make sure the panel in question is the last on the bottom of the root canvas in the scene hierarchy, the first is overdrawn by all following items, so the last UI element in the canvas will be drawn over every other . "The first is the last and the last is the first" ...
Thanks for your answer, unfortunately it didn't work. Panel is already at the bottom of its root canvas and I even tried SetAsLastSibling but also didn't work. I have InfoPanel and all I do is setting it active and this works. But with this LevelCompletedPanel, I get the panel but not everything inside of it.
I see in your screenshot your root canvas is a child of another game object, what kind is your root canvas? Is it screen space or world space / camera space? You can't see Congrats and the Particle tree but EarnedPointsText is visible , do i understand that right? However , your Canvas should be on top level ,not a child of any other game object when it is Screen Space or Camera Space.
Yes, you're right, only EarnedPointsText is visible. To be honest, I didnt know about that canvas should be on top level but I don't think this is the case because if so I couldn't have seen InfoPanel either. I have 2-3 canvases(including this one) in every scene and this one is attached to game manager. Also it is Screen Space - Camera.