Active Line has Metadata#
Game Creator / Dialogue / Active Line has Metadata
Can Read
Cannot Write
Description#
Returns true if the current running Text has the specified metadata key
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
using VisualScript.Runtime;
namespace GameCreator.Runtime.Dialogue
{
[Get]
[Title("Active Line has Metadata")]
[Category("Game Creator/Dialogue/Active Line has Metadata")]
[Description("Returns true if the current running Text has the specified metadata key")]
[Image(typeof(IconBubbleSolid), ColorTheme.Type.TextLight, typeof(BadgeHash))]
[Serializable]
public class TypeBoolDialogueActiveLineHasMetadata : TypeBool
{
[SerializeField] private GetGameObject m_Dialogue = new GetGameObject(
new TypeGameObjectDialogue()
);
[SerializeField] private GetString m_Metadata = new GetString("my-metadata");
public override bool Get(Args args)
{
Dialogue dialogue = this.m_Dialogue.Get<Dialogue>(args);
if (dialogue == null) return false;
string metadata = this.m_Metadata.Get(args);
return dialogue.CurrentNode != null && dialogue.CurrentNode.HasMetadata(metadata);
}
public override string ToString()
{
return $"Active {this.m_Dialogue} has {this.m_Metadata}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}