1
This commit is contained in:
46
Packages/Runtime/Components/ReadFromTextAsset.cs
Normal file
46
Packages/Runtime/Components/ReadFromTextAsset.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
public override void Excute()
|
||||
{
|
||||
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 = "读取文本";
|
||||
|
||||
excute.clicked += agent.Excute;
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user