[SOLVED]UI Panel Animator

Announcements, support questions, and discussion for Quest Machine.
Post Reply
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

[SOLVED]UI Panel Animator

Post 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.
Last edited by mschoenhals on Mon Oct 12, 2020 10:17 am, edited 1 time in total.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP]UI Panel Animator

Post 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.
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP]UI Panel Animator

Post 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP]UI Panel Animator

Post 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.)
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP]UI Panel Animator

Post 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP]UI Panel Animator

Post 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.
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP]UI Panel Animator

Post by mschoenhals »

Hi Tony,

Thanks very much for your help. I've decided to go another way with this particular UI. :D
Post Reply