Added building unlock buttons
This commit is contained in:
56
Assets/Scripts/Game/Buildings/LineDrawer.cs
Normal file
56
Assets/Scripts/Game/Buildings/LineDrawer.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class LineDrawer : MonoBehaviour
|
||||
{
|
||||
[Serializable] private class LineInfo
|
||||
{
|
||||
public RectTransform[] Points;
|
||||
}
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private Material LineMaterial;
|
||||
[SerializeField] private LineInfo[] Lines;
|
||||
|
||||
private List<LineRenderer> Renderers = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
foreach (LineInfo line in Lines)
|
||||
{
|
||||
GameObject go = new("LineRenderer(Script Spawned)");
|
||||
go.transform.SetParent(transform);
|
||||
|
||||
RectTransform rt = go.AddComponent<RectTransform>();
|
||||
rt.anchoredPosition = new Vector2(0, 0);
|
||||
|
||||
LineRenderer lr = go.AddComponent<LineRenderer>();
|
||||
lr.positionCount = line.Points.Length;
|
||||
lr.material = LineMaterial;
|
||||
lr.widthMultiplier = 0.1f;
|
||||
|
||||
Renderers.Add(lr);
|
||||
|
||||
for (int i = 0; i < line.Points.Length; i++)
|
||||
{
|
||||
lr.SetPosition(i, line.Points[i].position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
for (int i = 0; i < Lines.Length; i++)
|
||||
{
|
||||
LineRenderer lr = Renderers[i];
|
||||
for (int j = 0; j < Lines[i].Points.Length; j++)
|
||||
{
|
||||
lr.SetPosition(j, Lines[i].Points[j].position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user