playMaker

Author Topic: LineRendererSetWidth  (Read 1423 times)

cwmanley

  • Full Member
  • ***
  • Posts: 107
LineRendererSetWidth
« on: January 22, 2016, 12:06:19 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 Width

using UnityEngine;

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

[Tooltip("Start Int")]
public FsmInt start;

[Tooltip("Start Color")]
public FsmInt end;


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.SetWidth public void SetWidth(float start, float end);
_lineRenderer.SetWidth(start.Value, end.Value);

}
}
}
« Last Edit: February 15, 2017, 02:33:01 PM by cwmanley »