Last active
August 29, 2015 13:58
-
-
Save TarasOsiris/9952471 to your computer and use it in GitHub Desktop.
Playmaker action to set color of the SmoothMoves.Sprite.
This file contains hidden or 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 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