Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - alabatusa

Pages: [1]
Share New Actions / [iTween Action] Tween Alpha of Object
« on: May 28, 2014, 09:47:45 PM »
Hi All,

My first "working" custom action. Basically used already in place iTween actions to generate an action which tweens the alpha of an object over time.

E.g where this could be used in a game, is say a coin pick up, rather than disappearing instantly on pick up fade out over desired time.

Hope it helps someone.
Note: For this to work the object material renderer must support transparency.

Code: [Select]
using UnityEngine;
namespace HutongGames.PlayMaker.Actions

[Tooltip("Varies GameObject's Alpha over time by fading.")]
public class iTweenAlphaBy: iTweenFsmAction
public FsmOwnerDefault gameObject;

[Tooltip("iTween ID. If set you can use iTween Stop action to stop it by its id.")]
public FsmString id;

[Tooltip("A Alpha value that GameObject will tween to.")]
public FsmFloat Alpha;
[Tooltip("The time in seconds the animation will take to complete.")]
public FsmFloat time;
[Tooltip("The time in seconds the animation will wait before beginning.")]
public FsmFloat delay;
[Tooltip("Can be used instead of time to allow animation based on speed. When you define speed the time variable is ignored.")]
public FsmFloat speed;
[Tooltip("The shape of the easing curve applied to the animation.")]
public iTween.EaseType easeType = iTween.EaseType.linear;
[Tooltip("The type of loop to apply once the animation has completed.")]
public iTween.LoopType loopType = iTween.LoopType.none;

public override void Reset()
id = new FsmString{UseVariable = true};
time = 1f;
delay = 0f;
loopType = iTween.LoopType.none;
Alpha = new FsmFloat { UseVariable = true };
speed = new FsmFloat { UseVariable = true };

public override void OnEnter()
if(loopType != iTween.LoopType.none) base.IsLoop(true);

public override void OnExit(){

void DoiTween()
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;

// init position

float amount = 0f;
if (Alpha.IsNone) {

} else {
amount = Alpha.Value;

itweenType = "alpha";
iTween.FadeTo(go, iTween.Hash(
"amount", amount,
"name", id.IsNone ? "" : id.Value,
speed.IsNone ? "time" : "speed", speed.IsNone ? time.IsNone ? 1f : time.Value : speed.Value,
"delay", delay.IsNone ? 0f : delay.Value,
"easetype", easeType,
"looptype", loopType,
"oncomplete", "iTweenOnComplete",
"oncompleteparams", itweenID,
"onstart", "iTweenOnStart",
"onstartparams", itweenID,
"ignoretimescale", realTime.IsNone ? false : realTime.Value 


Playmaker Help / Re: NGUI Fill Amount
« on: May 19, 2014, 04:41:29 AM »
Like I said. I know I can use the set property  component to acheive what I was after and have done so. My question was more on my coding and how I could achieve what I was doing by creating my own custom fsm action.

Playmaker Help / NGUI Fill Amount
« on: May 17, 2014, 09:55:53 AM »
Hi All.

Noobie Question. Im trying to make a playmaker script to set the fill amount of a filled type sprite in NGUI.  I have written the following. I keep getting the following error.

Assets/External Plugins/Playmaker NGUI Scripts/Scripts/Playmaker Actions/NguiSetFilledSpritefillamount.cs(52,24): error CS0029: Cannot implicitly convert type `HutongGames.PlayMaker.FsmFloat' to `float'

Any help to this would be appreciated. I am quite new to programming in general. I know I can use a "set property" action to target the fill amount, but i am asking this more in learning how to approach such a coding problem.

Code: [Select]
using HutongGames.PlayMaker;

/// <summary>
/// Sets the sprite fill value of a filled UISprite
/// </summary>
[Tooltip("Set the Fill Value of a UISprite")]
public class NguiSetFilledSpritefillamount : FsmStateAction
    [Tooltip("NGUI Sprite to set")]
    public FsmOwnerDefault NguiSprite;

    [Tooltip("Fill Amount")]
    public FsmFloat Floatamount;

    public override void Reset()
        NguiSprite = null;
        Floatamount = null;

    public override void OnUpdate()
        // set the sprite

    private void DoSetSpriteFillAmount()
        // exit if objects are null
        if ((NguiSprite == null) || (Floatamount == null))

        // get the sprite
        UISprite sprite = Fsm.GetOwnerDefaultTarget(NguiSprite).GetComponent<UISprite>();

        // exit if no sprite found
        if (sprite == null)

        // set  sprite to fill amount
sprite.fillAmount = Floatamount;

Pages: [1]