Text color change back to original
Posted: Mon Apr 17, 2023 2:47 pm
Hi!
I made a custom Sequencer Comand to change 'Subtitle' and 'Response' texts. It changes the color properly, but when it continues to the next 'Dialogue Entry', the color change back to the original color. I don't know if I'm missing something or doing anything wrong.
Here are the scripts:
Custom Sequencer Comand
Change Text Color Script
Thanks in advance!
I made a custom Sequencer Comand to change 'Subtitle' and 'Response' texts. It changes the color properly, but when it continues to the next 'Dialogue Entry', the color change back to the original color. I don't know if I'm missing something or doing anything wrong.
Here are the scripts:
Custom Sequencer Comand
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class SequencerCommandChangeTextColor : SequencerCommand
{
string colorName;
public void Awake()
{
colorName = GetParameter(0);
ChangeTextColor.CTC.ChangeColor(colorName);
Stop();
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ChangeTextColor : MonoBehaviour
{
public static ChangeTextColor CTC;
[SerializeField] Text subtitleText;
[SerializeField] Text[] responseTexts;
[SerializeField] Color yellow;
[SerializeField] Color pink;
[SerializeField] Color green;
void Awake()
{
CTC = this;
}
public void ChangeColor(string color)
{
switch(color)
{
case "yellow":
ChangeText(yellow);
break;
case "pink":
ChangeText(pink);
break;
case "green":
ChangeText(green);
break;
case "white":
ChangeText(Color.white);
break;
default:
ChangeText(Color.white);
break;
}
}
private void ChangeText(Color color)
{
subtitleText.color = color;
foreach(Text responseText in responseTexts)
{
responseText.color = color;
}
}
}