Text Asset#
Files / Text Asset
Can Read
Cannot Write
Description#
The contents of a Text Asset file
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_File), typeof(TextAsset), false)]
[Title("Text Asset")]
[Category("Files/Text Asset")]
[Description("The contents of a Text Asset file")]
[Image(typeof(IconTextAsset), ColorTheme.Type.TextLight)]
[Keywords("File", "Text", "Asset")]
[Keywords("TXT", "CSV", "JSON", "XML", "YAML")]
[Serializable]
public class TypeStringTextAsset : TypeString
{
[SerializeField] private TextAsset m_File;
public override string GetPreview(GameObject source) => this.m_File != null ? this.m_File.text : string.Empty;
public TypeStringTextAsset() : this(null)
{ }
public TypeStringTextAsset(TextAsset textAsset)
{
this.m_File = textAsset;
}
public override string Get(Args args)
{
return this.m_File != null ? this.m_File.text : string.Empty;
}
public override string ToString()
{
return this.m_File != null ? this.m_File.name : string.Empty;
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
}
}