Skip to content

Instantly share code, notes, and snippets.

@TarasOsiris
Last active August 29, 2015 13:58
Show Gist options
  • Save TarasOsiris/9952471 to your computer and use it in GitHub Desktop.
Save TarasOsiris/9952471 to your computer and use it in GitHub Desktop.
Playmaker action to set color of the SmoothMoves.Sprite.
using HutongGames.PlayMaker;
using UnityEngine;
[ActionCategory("SmoothMoves")]
[Tooltip("Sets the sprite color of the Sprite")]
public class SmoothMoves_SetSpriteColor : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(SmoothMoves.Sprite))]
[Tooltip("Game Object to set the color on.")]
public FsmOwnerDefault gameObject;
[UIHint(UIHint.FsmColor)]
[Tooltip("The color to set.")]
public FsmColor spriteColor;
private SmoothMoves.Sprite _smoothMovesSprite;
public override void Reset()
{
gameObject = null;
spriteColor = Color.white;
}
public override void OnEnter()
{
SetSpriteColor();
}
private void SetSpriteColor()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
Finish();
return;
}
_smoothMovesSprite = go.GetComponent<SmoothMoves.Sprite>();
if (_smoothMovesSprite == null)
{
LogWarning("Missing SmoothMoves sprite component on GameObject: [" + go.name + "]");
Finish();
return;
}
_smoothMovesSprite.SetColor(spriteColor.Value);
Finish();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment