Active Line Metadata#
Game Creator / Dialogue / Active Line Metadata
Can Read
Cannot Write
Description#
Returns the metadata 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 Metadata")]
[Category("Game Creator/Dialogue/Active Line Metadata")]
[Description("Returns the metadata value of the current active line of the Dialogue component")]
[Image(typeof(IconBubbleSolid), ColorTheme.Type.TextLight, typeof(BadgeHash))]
[Serializable]
public class TypeNumberDialogueActiveLineMetadata : TypeNumber
{
[SerializeField] private GetGameObject m_Dialogue = new GetGameObject(
new TypeGameObjectDialogue()
);
[SerializeField] private GetString m_Metadata = new GetString("my-metadata");
public override double Get(Args args)
{
Dialogue dialogue = this.m_Dialogue.Get<Dialogue>(args);
if (dialogue == null) return 0;
string metadata = this.m_Metadata.Get(args);
return dialogue.CurrentNode != null && dialogue.CurrentNode.TryGetMetadata(metadata, out int value)
? value
: 0;
}
public override string ToString()
{
return $"Active {this.m_Dialogue}[{this.m_Metadata}]";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}