2023-06-05 19:57:17 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UIElements;
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEditor.UIElements;
|
|
|
|
#endif
|
|
|
|
namespace BITKit
|
|
|
|
{
|
|
|
|
public class ReadFromTextAsset : BITAction
|
|
|
|
{
|
|
|
|
public TextAsset asset;
|
|
|
|
public Provider output;
|
|
|
|
public TranslateSO translateSO;
|
2023-06-29 14:57:11 +08:00
|
|
|
public override void Execute()
|
2023-06-05 19:57:17 +08:00
|
|
|
{
|
|
|
|
BITAppForUnity.ThrowIfNotPlaying();
|
|
|
|
var value = asset.text;
|
|
|
|
if (translateSO)
|
|
|
|
{
|
|
|
|
value = translateSO.Get(value);
|
|
|
|
}
|
|
|
|
output.Set<string>(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
[UnityEditor.CustomEditor(typeof(ReadFromTextAsset))]
|
|
|
|
public class ReadFromTextAssetInspector : BITInspector<ReadFromTextAsset>
|
|
|
|
{
|
|
|
|
public override VisualElement CreateInspectorGUI()
|
|
|
|
{
|
|
|
|
CreateSubTitle("TextAsset Reader");
|
|
|
|
FillDefaultInspector(root, serializedObject, true);
|
|
|
|
var excute = root.Create<Button>();
|
|
|
|
|
|
|
|
//excute.bindingPath = nameof(ReadFromTextAsset.Excute);
|
|
|
|
|
|
|
|
excute.text = "读取文本";
|
|
|
|
|
2023-06-29 14:57:11 +08:00
|
|
|
excute.clicked += agent.Execute;
|
2023-06-05 19:57:17 +08:00
|
|
|
return root;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|