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.

55 lines
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace UltraCombos.Coloring
{
[RequireComponent(typeof(CanvasGroup))]
public class LineScaleManager : MonoBehaviour
{
public float maxSize = 1.0f;
public float minSize = 0.5f;
public Image colorImage;
public Button pointer;
public global::PaintCraft.Tools.LineConfig lineConfig;
CanvasGroup group;
bool is_active = true;
private void Start()
{
var slider = GetComponentInChildren<Slider>();
slider.value = 1;
slider.minValue = minSize;
slider.maxValue = maxSize;
slider.onValueChanged.AddListener(OnValueChanged);
group = GetComponent<CanvasGroup>();
}
private void Update()
{
colorImage.color = pointer.colors.normalColor;
}
private void FixedUpdate()
{
group.interactable = group.blocksRaycasts = is_active;
group.alpha = Mathf.Lerp(group.alpha, is_active ? 1.0f : 0.0f, Time.fixedDeltaTime * 8.0f);
}
public void OnValueChanged(float value)
{
colorImage.transform.localScale = Vector3.one * value;
lineConfig.Scale = value;
}
public void SetActive(bool v)
{
is_active = v;
}
}
}