Active Line Actor Expression Sprite#
Game Creator / Dialogue / Active Line Actor Expression Sprite
Can Read
Cannot Write
Description#
Returns the Actor Expression Sprite 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 Expression Sprite")]
[Category("Game Creator/Dialogue/Active Line Actor Expression Sprite")]
[Description("Returns the Actor Expression Sprite value of the current active line of the Dialogue component")]
[Image(typeof(IconScriptActor), ColorTheme.Type.TextLight, typeof(BadgeHash))]
[Serializable]
public class TypeSpriteDialogueActiveLineActorExpressionSprite : TypeSprite
{
[SerializeField] private GetGameObject m_Dialogue = new GetGameObject(
new TypeGameObjectDialogue()
);
public override Sprite Get(Args args)
{
Dialogue dialogue = this.m_Dialogue.Get<Dialogue>(args);
if (dialogue == null || dialogue.CurrentNode is not NodeText nodeText) return null;
ScriptActor actor = RuntimeScript.GetActor(dialogue.CurrentRuntimeScript, nodeText.Actor);
if (actor == null) return null;
return actor.TryGetExpression(nodeText.Expression, out Expression expression)
? expression?.GetSprite(args)
: null;
}
public override string ToString()
{
return $"Active {this.m_Dialogue} Actor Expression Sprite";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}