Author Topic: triggering animations from non-NGUI camera  (Read 3298 times)

leathers

  • Guest
triggering animations from non-NGUI camera
« on: October 07, 2013, 11:23:32 PM »
Hello. I have NGUI working for interface widgets grouped under in the NGUI camera. I can also get everything working if I drag widgets outside of that hierarchy and use the UICamera script on the other cameras. But the UICamera script messes up my other camera scripts and the main camera looses its swipe navigation abilities. So I am looking for a work around.

So I want to put regular geometry with colliders in front of the non-NGUI cameras and when clicked, trigger animations on the NGUI panels (actually on the empty game objects that my panels are nested under)

That is all I am trying to do.. trigger certain panels to animate onto and off of screen.. They work when triggered from within the NGUI hierarchy, but I need them to ALSO animate when random, non-gui game objects are clicked.

My NGUI camera and all widgets are on their own layer (mygui), and my other cameras are all set to default layer. This is the script that I am using. I attach it to a cube with a box collider on it, and drag the animated game object tot he exposed variable.. and then I name the clip explicitly.

funny thing is, that this script works.. but only once. It gets the panel to animate onto screen. The panel has a close button I use to close, it.. and then I try and open it again with this script and only the debug log works.. but no more animation.. To bad the UIplayAnimation script won't work outside of the NGUI hierarchy either, or else I'd use that.. that would be perfect..

Any help would be much appreciated.. Sorry for the long explanation.


//------------------------------------
var target : GameObject;

function OnMouseDown()
{
// this works but only once each time scene is restarted..??

   target.animation.Play("NGUI_doc_in");
   Debug.Log("you have clicked on mesh to trigger anim");

// debug log seems to fire every time, but not the animation
   
}
//-------

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #1 on: October 08, 2013, 01:07:10 AM »
OnMouseDown is not an NGUI event. OnPress(bool isPressed) is.

Also I'm not sure what UICamera on the main camera has to do with messing up swipe navigation.

nicolethenerd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #2 on: November 01, 2013, 04:50:02 PM »
I'm working on the project w/ @leathers above - we're still stuck on this, and I'm not sure either of us understand your reply.

We are trying to attach UIPlayAnimation to an object in our game that is not a child of the UI Root (because it is not a part of the UI - touching an in-game object should trigger the appearance of a UI panel).  However, OnClick and OnPress are not firing in UIPlayAnimation.  Does UIPlayAnimation only work when it is attached to children of a UI Root?

Thanks!

(I think the swipe navigation turned out to be an unrelated issue)

nicolethenerd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #3 on: November 01, 2013, 05:16:58 PM »
update - looks like this is possible - generating buttons with the Widget wizard and dragging them out so they are not children of a UI Root still works.  This solves our immediate problem, but still haven't figured out what was wrong w/ the buttons we were making from scratch, though - they had Box Colliders and the UIPlayAnimation script - what are we missing here? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #4 on: November 01, 2013, 08:23:40 PM »
I'm not sure how else to explain what I said in the previous post.

OnMouseDown is not an event that's sent by NGUI. NGUI has no control over it. NGUI can't do anything with it. NGUI can't cancel it. You need to use NGUI events when working with NGUI.

nicolethenerd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #5 on: November 04, 2013, 11:11:55 AM »
Thanks.  That makes sense.

We still can't figure out why our button wasn't triggering OnPress, though - we have a workaround, which is to create a button through the NGUI wizard - but is there anything else we'd need to do to a game object besides adding a box collider and the UIPlayAnimation script to make it behave like an NGUI button?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: triggering animations from non-NGUI camera
« Reply #6 on: November 04, 2013, 12:04:00 PM »
PlayAnimation is not necessary. If you want a button, a collider is all it takes. If you want it to be visible, UIButton script is the easiest way to go. PlayAnimation will let you play a remote animation -- if that's what you want.