playMaker

Author Topic: NGUI set play direction on button animation[SOLVED]  (Read 8223 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
NGUI set play direction on button animation[SOLVED]
« on: October 26, 2012, 03:07:06 AM »
Hi,

 Following a request:
http://hutonggames.com/playmakerforum/index.php?topic=1356.msg11020#msg11020

 Please find below a simple action that allow you to set the play direction of a NGUI button animation tween.

 Because there can be more than one of this component per button, you will need to explicitly drag the component itself, not just the gameObject, in which case would pick the first component in the stack.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;
using AnimationOrTween;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("NGUI")]
[Tooltip("Sets the direction of a button tween animation.")]
public class NGuiSetButtonTweenDirection : FsmStateAction
{
[ObjectType(typeof(UIButtonTween))]
[Tooltip("Because there can be more than one tweener, you will need to explicitly reference it below by dragging the component itself, not the gameObject")]
public FsmObject OrButtonTweenComponent;

public Direction playDirection;

public override void Reset()
{

OrButtonTweenComponent = null;

playDirection = Direction.Forward;

}

public override void OnEnter()
{
DoSetPlayDirection();

Finish();
}


void DoSetPlayDirection()
{

UIButtonTween tween = OrButtonTweenComponent.Value as UIButtonTween;

if (tween == null)
{
return;
}else{

tween.playDirection = playDirection;
}

}
}
}


bye,

 Jean
« Last Edit: October 26, 2012, 07:44:33 AM by jeanfabre »

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI set play direction on button animation
« Reply #1 on: October 26, 2012, 03:23:38 AM »
Awesome thanks!

I was just about to re-look into this and attempt it myself as it was holding me back a fair bit, now to make all those awesome UI animations I dreamed about :P

thanks again to playmaker, this is really becoming a life saver!

thanks jean

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: NGUI set play direction on button animation
« Reply #2 on: October 26, 2012, 04:15:43 AM »
When I first used this script I could not get it working for the UIButtonPlayAnimation script from NGUI, after going through the code I noticed reference to tween button, I replaces a few lines with the animation button name and it now works.

not sure if each type of animation script will need their own action as I gather that the one jean made was for a tween animation script that I have not tested, but for the button animation this works.

again this action uses 90% of jeans works and have edited a couple of lines.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI set play direction on button animation
« Reply #3 on: October 26, 2012, 07:44:22 AM »
Hi,

 yes, you will need it for each different type of class you want, sorry I though you wanted it for the button tween animation. I am glad you found your way in the action to modify it, way to go !

bye,

 Jean