Active Line Text#
Game Creator / Dialogue / Active Line Text
Can Read
Cannot Write
Description#
Returns the Text value of the current active line of the Dialogue component
Note
The current node requires to be a normal Text line. Choices and other nodes will return an empty string.
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
using VisualScript.Runtime;
namespace GameCreator.Runtime.Dialogue
{
[Get]
[Title("Active Line Text")]
[Category("Game Creator/Dialogue/Active Line Text")]
[Description("Returns the Text value of the current active line of the Dialogue component")]
[Image(typeof(IconBubbleSolid), ColorTheme.Type.TextLight, typeof(BadgeHash))]
[Note("The current node requires to be a normal Text line. Choices and other nodes will return an empty string.")]
[Serializable]
public class TypeStringDialogueActiveLineText : TypeString
{
[SerializeField] private GetGameObject m_Dialogue = new GetGameObject(
new TypeGameObjectDialogue()
);
public override string Get(Args args)
{
Dialogue dialogue = this.m_Dialogue.Get<Dialogue>(args);
if (dialogue == null || dialogue.CurrentNode is not NodeText nodeText) return string.Empty;
return nodeText.GetText();
}
public override string ToString()
{
return $"Active {this.m_Dialogue} Text";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}