playMaker

Author Topic: LineRendererSetColor  (Read 1392 times)

cwmanley

  • Full Member
  • ***
  • Posts: 107
LineRendererSetColor
« on: January 22, 2016, 12:07:34 AM »
On the Ecosystem or https://snipt.net/cwmanley/ //TODO


Code: [Select]
// License: Attribution 4.0 International (CC BY 4.0)
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/
// Keywords: Line Renderer Color

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Effects")]
[Tooltip("Set the line color at the start and at the end.")]
public class LineRendererSetColors : FsmStateAction
{
[RequiredField]
[Tooltip("The GameObject with Line Renderer")]
[CheckForComponent(typeof(LineRenderer))]
public FsmOwnerDefault gameObject;



[Tooltip("Start Color")]
public FsmColor startColor;

[Tooltip("Start Color")]
public FsmColor endColor;


public bool everyFrame;

LineRenderer _lineRenderer;


public override void Reset()
{
gameObject = null;
everyFrame = false;
}

public override void OnEnter()
{
DoAction();

if (!everyFrame)
{
Finish();
}
}

public override void OnUpdate()
{
DoAction();
}

void DoAction()
{

// Get Game Object.
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

// Get Component.
_lineRenderer = go.GetComponent<LineRenderer>();

//lineRenderer.SetColors(c1, c2)
_lineRenderer.SetColors(startColor.Value, endColor.Value);

}
}
}
« Last Edit: February 15, 2017, 02:31:57 PM by cwmanley »