You've already forked taptap2024_GJ_chidouren
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.RandomPool;
|
|
using Game.Data;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace System.Utils
|
|
{
|
|
public class MultiGraphicControl : MonoBehaviour
|
|
{
|
|
[SerializeField, BoxGroup ("CustomTarget"), Title ("颜色控制目标")]
|
|
public List<ColorTarget> _targets;
|
|
|
|
private List<Color> _defaultColors;
|
|
private bool _isInit;
|
|
|
|
private Color DefaultColor (int index)
|
|
{
|
|
if (!this._isInit)
|
|
{
|
|
this._defaultColors = new List<Color> (this._targets.Count);
|
|
foreach (var colorTarget in this._targets)
|
|
{
|
|
if (colorTarget._graphic == null)
|
|
{
|
|
this._defaultColors.Add (Color.white);
|
|
}
|
|
else
|
|
{
|
|
this._defaultColors.Add (colorTarget._graphic.color);
|
|
}
|
|
}
|
|
|
|
this._isInit = true;
|
|
}
|
|
|
|
return this._defaultColors[index];
|
|
}
|
|
|
|
public void SetColor (Color color)
|
|
{
|
|
if (this._targets?.Count > 0)
|
|
{
|
|
for (int i = 0; i < this._targets.Count; i++)
|
|
{
|
|
var target = this._targets[i];
|
|
var defColor = this.DefaultColor(i);
|
|
|
|
if (target._graphic != null)
|
|
{
|
|
target._graphic.color = target._isCustomColor ? color * target._customColor : color * defColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void ResetDefaultColor ()
|
|
{
|
|
for (int i = 0; i < this._targets.Count; i++)
|
|
{
|
|
this._targets[i]._graphic.color = this.DefaultColor(i);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |