How to get a Line Renderer startWidth / endWidth values ?


I’m shooting a laser as a Line Renderer and I would get its startWidth and its endWidth values in order to save them for later. Unfortunately, I saw that they only seem available to set, and not to get.

Is there a way to simply read these values ?

Thanks !

You unfortunately can’t do it with 5.4x Unity. However with the 5.5b you can do it this way:

using UnityEngine;
using System.Collections;

public class GetLineRendererWidth : MonoBehaviour
	private LineRenderer lineRenderer;

	void Start ()
		lineRenderer = gameObject.GetComponent<LineRenderer>();
		float startWidth = lineRenderer.startWidth;
		float endWidth = lineRenderer.endWidth;
		Debug.Log("Start width: " + startWidth + '	' + "End width: " + endWidth);

Download this script and attach it to the object containing the LineRenderer Component-
Download File “LineRendererAdvancedOptions.cs”