DRHPS/code-csharp/en_US/INT_RunComponentFunctionAtEndOfChat.cs
2025-04-08 11:31:35 +08:00

34 lines
1019 B
C#

using UnityEngine;
public class INT_RunComponentFunctionAtEndOfChat : MonoBehaviour
{
[Header("WARNING! This component is removed once ran")]
[Space(20f)]
public INT_Chat TargetChat;
public CHATBOXTEXT TargetTextbox;
public Component TargetComponent;
[Space(5f)]
public string MethodName;
private void Update()
{
if (TargetChat.FinishedText && ChatboxManager.Instance.previouschatboxtext == TargetTextbox)
{
if (TargetComponent != null && TargetComponent.GetType().GetMethod(MethodName) != null)
{
TargetComponent.GetType().GetMethod(MethodName).Invoke(TargetComponent, null);
}
else
{
MonoBehaviour.print(TargetComponent.gameObject.name);
MonoBehaviour.print(MethodName);
MonoBehaviour.print("did you forget to make the method public?");
}
Object.Destroy(this);
}
}
}