32 lines
849 B
C#
32 lines
849 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ChangeButtonColors : MonoBehaviour
|
|
{
|
|
[Tooltip("Drag the reference Button here whose colors you want to copy.")]
|
|
public Button referenceButton; // Drag & Drop the button in the inspector, that should be taken as color reference for all others
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
if (referenceButton == null)
|
|
{
|
|
Debug.LogError("No reference button assigned to ButtonColorAssigner.");
|
|
return;
|
|
}
|
|
|
|
ColorBlock referenceColors = referenceButton.colors;
|
|
|
|
Button[] buttons = GetComponents<Button>();
|
|
|
|
foreach (Button btn in buttons)
|
|
{
|
|
if (btn != referenceButton)
|
|
{
|
|
btn.colors = referenceColors;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|