Author Topic: Playing a TweenGroup via code  (Read 2901 times)

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Playing a TweenGroup via code
« on: February 12, 2014, 08:02:47 AM »
I have a window that contains two groups of tweens for it's 'lifecycle'.

I've searched around the forum and I'm having trouble pinning down the correct way to implement this. I'm clearly doing a noob error here...
I have a warning: Implicit downcast from 'UnityEngine.Component[]' to 'UITweener[]'.

Currently, I have a script similar to below:

  1. var myTweens : UITweener[];
  2.  
  3. function Start ()
  4. {
  5.     myTweens = transform.GetComponents(UITweener);
  6. }
  7.  
  8. function PlayGroup(groupToPlay : int)
  9. {
  10.         for (var i : int = 0; i < myTweens.Length; ++i)
  11.         {
  12.         var currentTweener : UITweener = myTweens[i];
  13.         if (currentTweener.tweenGroup == groupToPlay)
  14.         {
  15.                         currentTweener.Play(true);
  16.                 }
  17.         }
  18. }
  19.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Playing a TweenGroup via code
« Reply #1 on: February 13, 2014, 03:10:27 AM »
Sorry I can't suggest much regarding javascript code as I don't use it. In C# it would be:
  1. UITweener[] myTweens = GetComponents<UITweener>();
I'm guessing you are missing a cast, but I have no idea how to do it in JS.