You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

using PaintCraft.Tools;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace UltraCombos.Coloring
{
public class BrushManager : MonoBehaviour
{
public LineConfig lineConfig;
public LineScaleManager lineScale;
public List<Brush> brushes = new List<Brush>();
List<Toggle> options;
private void Start()
{
options = new List<Toggle>(GetComponentsInChildren<Toggle>());
foreach (var opt in options)
{
opt.onValueChanged.AddListener(OnOptionChanged);
}
SetBrush(brushes.Count - 1);
}
private void Update()
{
var is_brush = !lineConfig.Brush.name.Equals("Bucket Tool");
lineScale.SetActive(is_brush);
}
public void OnOptionChanged(bool v)
{
var index = options.FindIndex(x => x.isOn);
if (index >= 0)
{
SetBrush(index);
}
}
public void SetBrush(int i)
{
lineConfig.Brush = brushes[Mathf.Clamp(i, 0, brushes.Count - 1)];
}
}
}