2017-05-06 00:14:03 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
namespace UnityEngine.UI.Extensions.Examples
|
|
|
|
|
{
|
|
|
|
|
public class TestAddingPoints : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public UILineRenderer LineRenderer;
|
|
|
|
|
public Text XValue;
|
|
|
|
|
public Text YValue;
|
2017-05-06 00:14:03 +08:00
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
// Use this for initialization
|
|
|
|
|
public void AddNewPoint()
|
|
|
|
|
{
|
|
|
|
|
var point = new Vector2() { x = float.Parse(XValue.text), y = float.Parse(YValue.text) };
|
|
|
|
|
var pointlist = new List<Vector2>(LineRenderer.Points);
|
|
|
|
|
pointlist.Add(point);
|
|
|
|
|
LineRenderer.Points = pointlist.ToArray();
|
|
|
|
|
}
|
2017-06-25 18:56:46 +08:00
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void ClearPoints()
|
|
|
|
|
{
|
|
|
|
|
LineRenderer.Points = new Vector2[0];
|
2018-01-20 20:08:44 +08:00
|
|
|
|
LineRenderer.SetAllDirty();
|
2017-08-02 17:21:45 +08:00
|
|
|
|
}
|
2017-06-25 18:56:46 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
}
|