Active Line Actor Name#
Game Creator / Dialogue / Active Line Actor Name
Can Read
Cannot Write
Description#
Returns the Actor Name value of the current active line of the Dialogue component
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
using VisualScript.Runtime;
namespace GameCreator.Runtime.Dialogue
{
[Get]
[Title("Active Line Actor Name")]
[Category("Game Creator/Dialogue/Active Line Actor Name")]
[Description("Returns the Actor Name value of the current active line of the Dialogue component")]
[Image(typeof(IconScriptActor), ColorTheme.Type.TextLight, typeof(BadgeHash))]
[Serializable]
public class TypeStringDialogueActiveLineActorName : 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;
ScriptActor actor = RuntimeScript.GetActor(dialogue.CurrentRuntimeScript, nodeText.Actor);
return actor?.GetName(dialogue.CurrentRuntimeScript.Args);
}
public override string ToString()
{
return $"Active {this.m_Dialogue} Actor Name";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}