BITKit/Packages/Runtime~/Unity/Common/Scripts/Config/Exec.cs

37 lines
962 B
C#
Raw Normal View History

2023-06-05 19:57:17 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2023-06-29 14:57:11 +08:00
2023-06-05 19:57:17 +08:00
using System.IO;
using Cysharp.Threading.Tasks;
namespace BITKit
{
2023-06-29 14:57:11 +08:00
public abstract class Exec : MonoBehaviour, IAction
2023-06-05 19:57:17 +08:00
{
2023-06-29 14:57:11 +08:00
public void Execute()
2023-06-05 19:57:17 +08:00
{
try
{
foreach (var file in GetFiles())
{
if (file.Extension is ".json")
{
BIT4Log.Log<AutoExec>($"正在加载配置文件:{file.Name}");
var json = File.ReadAllText(file.FullName);
DataParser.Set(json);
Data.Set(file.Name, json);
}
}
}
catch (System.Exception e)
{
BIT4Log.LogException(e);
}
}
public abstract FileInfo[] GetFiles();
void Start()
{
2023-06-29 14:57:11 +08:00
Execute();
2023-06-05 19:57:17 +08:00
}
}
}