Files
bansonic_beta_main/Assets/scripts/gamePlay_gameplay/SkillTriggerFeedBinder.cs
T

78 lines
2.4 KiB
C#

using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Attach this script to a Text object in the scene to manually set it as the output target
/// for the SkillTriggerFeedUI. This bypasses the automatic GameObject.Find logic.
/// </summary>
public class SkillTriggerFeedBinder : MonoBehaviour
{
[Tooltip("The Text component to use for displaying skill triggers. If null, tries to use GetComponent<Text>().")]
public Text targetText;
[Tooltip("Whether to enable skill trigger output.")]
public bool enableOutput = true;
[Header("Feed Colors")]
public Color characterNameColor = new Color(1f, 0.5f, 0f); // Orange
public Color skillNameColor = Color.cyan; // Cyan/Blue
public Color missColor = new Color(1f, 0.27f, 0f); // Orange Red
public Color deathColor = Color.black; // Black
[Header("Enemy Feed Colors")]
public Color enemyNameColor = Color.red; // Default red for enemies
public Color enemySpawnColor = Color.yellow; // Default yellow for spawn message
private void Awake()
{
if (targetText == null)
{
targetText = GetComponent<Text>();
}
if (targetText != null)
{
if (enableOutput)
{
UpdateColors();
SkillTriggerFeedUI.SetTargetText(targetText);
}
else
{
// Ensure UI is disabled if toggle is off
SkillTriggerFeedUI.SetTargetText(null);
}
}
else
{
Debug.LogWarning("[SkillTriggerFeedBinder] No Text component found or assigned. Skill feed will not be bound.");
}
}
private void OnValidate()
{
if (Application.isPlaying && targetText != null)
{
if (enableOutput)
{
UpdateColors();
SkillTriggerFeedUI.SetTargetText(targetText);
}
else
{
SkillTriggerFeedUI.SetTargetText(null);
}
}
}
private void UpdateColors()
{
SkillTriggerFeedUI.CharacterColor = characterNameColor;
SkillTriggerFeedUI.SkillColor = skillNameColor;
SkillTriggerFeedUI.MissColor = missColor;
SkillTriggerFeedUI.DeathColor = deathColor;
SkillTriggerFeedUI.EnemyNameColor = enemyNameColor;
SkillTriggerFeedUI.EnemySpawnColor = enemySpawnColor;
}
}