playMaker

Author Topic: NGUI Fill Amount  (Read 4851 times)

alabatusa

  • Playmaker Newbie
  • *
  • Posts: 3
NGUI Fill Amount
« 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;
    }
}

play_edu

  • Full Member
  • ***
  • Posts: 116
Re: NGUI Fill Amount
« Reply #1 on: May 19, 2014, 12:55:32 AM »
Hi,
Try with this if work



alabatusa

  • Playmaker Newbie
  • *
  • Posts: 3
Re: NGUI Fill Amount
« Reply #2 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.



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI Fill Amount
« Reply #3 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