using System; using System.Collections; using System.Collections.Generic; using DG.Tweening; using NaughtyAttributes.Test; using TMPro; using UnityEngine; public class Glove : MonoBehaviour { [SerializeField] private GameObject[] _cylinders; [SerializeField] private Transform _graphics; private TrailRenderer[] _trails; private Renderer[] _renderers; // TODO: refactor to settings object [SerializeField] private float _baseTrailTime; [SerializeField] private float _blinkTrailTime; [SerializeField] private float _pulseTime; [SerializeField] private Material _trailMat; [SerializeField] private float _emissionScale; [SerializeField] private float _rotationSpeed; [SerializeField] private float _scaleFactor; [SerializeField] private Light _light; [SerializeField] private float _lightIntensity; private const string EMISSION_COLOR = "_EmissionColor"; private void Start() { _trails = GetComponentsInChildren(); _renderers = GetComponentsInChildren(); foreach (var trail in _trails) { trail.time = _baseTrailTime; } _lightIntensity = 0; } private void LateUpdate() { _graphics.Rotate(Vector3.up * (Time.deltaTime * _rotationSpeed)); } public void Pulse() { _graphics.transform.localScale = Vector3.one * _scaleFactor; _graphics.DOScale(Vector3.one, _pulseTime); foreach (var trail in _trails) { trail.time = _blinkTrailTime; trail.DOTime(_baseTrailTime, _pulseTime); } _light.intensity = // var baseEmission = _trailMat.GetColor(EMISSION_COLOR); // var pulseEmission = baseEmission * _emissionScale; // foreach (var renderer in _renderers) // { // renderer.material.SetColor(EMISSION_COLOR, pulseEmission); // renderer.material.DOColor(baseEmission, _pulseTime); // } } }