Page 1 of 1
[SOLVED]UI Panel Animator
Posted: Tue Oct 06, 2020 7:29 am
by mschoenhals
Hi,
I really like how the panels in both Quest Machine and Dialogue System animate as they close and open. Is it possible to use the same animation for my other panels? If so, how would I go about doing that?
Thank you in advance.
Re: [HELP]UI Panel Animator
Posted: Tue Oct 06, 2020 9:25 am
by Tony Li
Hi,
Sure! You can use the same animator controller as on the Quest Machine UIs. It's named UIPanelAnimator.
The easiest way to set it up is:
- Add an Animator component to your UI.
- Assign UIPanelAnimator to it.
- Add a UIPanel component. Call its Open() method to open it, Close() to close it, or Toggle() to toggle it between open and closed.
The UIPanel component can also ensure that one of its UI elements is focused (selected) so you can navigate them with a joystick or keyboard, even if the player clicks away with the mouse.
Re: [HELP]UI Panel Animator
Posted: Wed Oct 07, 2020 7:49 am
by mschoenhals
Thanks for the reply Tony. It's not yet working. I'm calling Open/Close from OnTriggerEnter and OnTriggerExit using:
Code: Select all
shopCanvas.GetComponent<UIPanel>().Open();
shopCanvas.GetComponent<UIPanel>().Close();
Is that correct? It does open and close but no animation. I have the Animator attached to the canvas with UIPanelAnimator as the controller. It does open and close but no animation.
Re: [HELP]UI Panel Animator
Posted: Wed Oct 07, 2020 9:42 am
by Tony Li
Hi,
Set the UIPanel's Show Animation Trigger to "Show" (without quotes) and Hide Animation Trigger to "Hide". This is how the panel knows how to play the animations. (See the UIPanel on the Quest Dialogue UI prefab for an example.)
Re: [HELP]UI Panel Animator
Posted: Thu Oct 08, 2020 8:15 am
by mschoenhals
Hi Tony,
Thanks for the reply. The triggers are set to Show/Hide (default). That is, on the UI Panel, Show Animation Trigger is "Show" and Hide Animation Trigger is "Hide" (no quotes).
I have the UI Panel component and the Animator on the root canvas of the UI panel that I want to pop up and close. Animator controller is set to UIPanelAnimator (no avatar).
I have no events listed on UI Panel; that is, On Open() and On Close() are empty. Is there suppose to be something in those fields??
I'm calling this in code:
Code: Select all
shopCanvas.GetComponent<UIPanel>().Open();
shopCanvas.GetComponent<UIPanel>().Close();
The panel does open and close, but not with the animation.
Re: [HELP]UI Panel Animator
Posted: Thu Oct 08, 2020 9:30 am
by Tony Li
Hi,
Try putting the UI Panel and Animator components on the child of the canvas (i.e., the panel). For example, in Quest Machine's demo, the UI Panel component is on the dialogue UI itself, not the dialogue UI's parent canvas.
If that doesn't help, then let's do this test:
1. Make sure your UI is visible in the scene view.
2. Inspect your main panel GameObject.
3. Open an Animation window.
4. In the Animation window, select the show animation and play it. Does it play the show animation?
5. Repeat for the hide animation.
Re: [HELP]UI Panel Animator
Posted: Mon Oct 12, 2020 10:17 am
by mschoenhals
Hi Tony,
Thanks very much for your help. I've decided to go another way with this particular UI.