Created
November 27, 2014 11:32
-
-
Save TarasOsiris/28eb0084e5c1437a7b27 to your computer and use it in GitHub Desktop.
Updates NGUI Label with provided parameters. Playmaker Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using HutongGames.PlayMaker; | |
[ActionCategory("NGUI")] | |
[HutongGames.PlayMaker.Tooltip("Updates NGUI Label with provided parameters")] | |
public class NGUI_UpdateLabel : FsmStateAction | |
{ | |
[RequiredField] | |
[CheckForComponent(typeof(UILabel))] | |
[HutongGames.PlayMaker.Tooltip("Game Object to update.")] | |
public FsmOwnerDefault gameObject; | |
[UIHint(UIHint.FsmString)] | |
[HutongGames.PlayMaker.Tooltip("UILabel text to set")] | |
public FsmString labelText; | |
[UIHint(UIHint.FsmColor)] | |
[HutongGames.PlayMaker.Tooltip("The color to set.")] | |
public FsmColor labelColor; | |
private UILabel _label; | |
public override void Reset() | |
{ | |
gameObject = null; | |
labelText = string.Empty; | |
labelColor = Color.white; | |
} | |
public override void OnEnter() | |
{ | |
var go = Fsm.GetOwnerDefaultTarget(gameObject); | |
if (go == null) | |
{ | |
Finish(); | |
return; | |
} | |
_label = go.GetComponent<UILabel>(); | |
if (_label == null) | |
{ | |
LogWarning("Missing UILabel component on GameObject: [" + go.name + "]"); | |
Finish(); | |
return; | |
} | |
_label.text = labelText.Value; | |
_label.color = labelColor.Value; | |
Finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment