Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: msc4tech on December 06, 2011, 05:16:16 AM

Title: 2d toolkit change sprite image
Post by: msc4tech on December 06, 2011, 05:16:16 AM
this code change sprite by name


using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
   [ActionCategory("2D Toolkit")]
   [Tooltip("set sprite by name of tk2dSprite")]
   public class Set2DToolkitSpriteByName : FsmStateAction {
      [RequiredField]
      public FsmOwnerDefault gameObject;      
      [RequiredField]
      public FsmString spriteName;
      
      private GameObject go;
      private tk2dSprite sprite;
      
      public override void Reset() {
         gameObject = null;
         spriteName = null;
      }
      
      public override void OnEnter() {
         go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
         sprite = go.GetComponent<tk2dSprite>();
         sprite.spriteId=sprite.GetSpriteIdByName(spriteName.Value);
         Finish();
      }
   }
}
Title: Re: 2d toolkit change sprite image
Post by: jeanfabre on January 13, 2012, 03:09:25 AM
Hi Everyone,

 I have started porting 2d toolkit and currently gathering custom actions. The package will be available very soon :)

 Meanwhile, if you have wishes or requests for 2d toolkit and playmaker, this is the right time to ask for it :)

 Thanks for ms4Tech for the head start on them actions.

https://hutonggames.fogbugz.com/default.asp?W717 (https://hutonggames.fogbugz.com/default.asp?W717)

 Bye,

 Jean
Title: Re: 2d toolkit change sprite image
Post by: kiriri on October 31, 2012, 01:33:36 PM
I know I'm bumping the dead here, but why is this not in the wiki package? It still works flawlessly
Title: Re: 2d toolkit change sprite image
Post by: jeanfabre on November 01, 2012, 01:36:13 AM
Hi,

Thanks for reminding me. I haven't give yet a second rundown to it to include the various custom actions created since.

Can you bump again like mid november? I should have more time to allocate to this and update the wiki package with all the latest additions

bye,

 Jean
Title: Re: 2d toolkit change sprite image
Post by: MasterMedia on January 26, 2013, 06:38:18 PM
How did i switch a sprite image on a different sprite collection?
Title: Re: 2d toolkit change sprite image
Post by: jeanfabre on February 08, 2013, 03:09:15 AM
Hi,

 Uhm, I tried to look at this, but I can't find any convenient api to do that at runtime, the utilities seems to only exists in editors.

I can of cours elet you pick a library by index ( 0, 1, 2 etc), but that's not really convenient...

I have asked this to the 2dtoolkit guy, I'll see what is coming up from it.

http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1152.0.html

bye,

 Jean