Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: alabatusa on May 17, 2014, 12:55:53 PM

Title: NGUI Fill Amount
Post by: alabatusa on May 17, 2014, 12:55:53 PM
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.

Quote
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>
[ActionCategory("NGUI")]
[Tooltip("Set the Fill Value of a UISprite")]
public class NguiSetFilledSpritefillamount : FsmStateAction
{
    [RequiredField]
    [Tooltip("NGUI Sprite to set")]
    public FsmOwnerDefault NguiSprite;

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

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

    public override void OnUpdate()
    {
        // set the sprite
        DoSetSpriteFillAmount();
        Finish();
    }

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

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

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

        // set  sprite to fill amount
sprite.fillAmount = Floatamount;
    }
}
Title: Re: NGUI Fill Amount
Post by: play_edu on May 19, 2014, 12:55:32 AM
Hi,
Try with this if work

(http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=6175.0;attach=4152;image)
(http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=6175.0;attach=4154;image)
Title: Re: NGUI Fill Amount
Post by: alabatusa on May 19, 2014, 07: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.


Title: Re: NGUI Fill Amount
Post by: jeanfabre on May 26, 2014, 04:08:05 AM
Hi,

 you should simply inspire from the existing set of custom actions for ngui, have you studied them already?

bye,

 Jean