64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
using Newtonsoft.Json;
|
|
using Sirenix.OdinInspector;
|
|
using Sirenix.OdinInspector.Editor;
|
|
using UnityEngine;
|
|
|
|
namespace Editor.GenResourcePathEditor
|
|
{
|
|
public class GenConfigEditor : OdinEditorWindow
|
|
{
|
|
[UnityEditor.MenuItem("Tool/ZC/GenConfigEditor")]
|
|
private static void OpenWindow()
|
|
{
|
|
GetWindow<GenConfigEditor>().Show();
|
|
}
|
|
|
|
[FolderPath] public string configFolderPath;
|
|
public List<MallStoreItem> storeItems = new List<MallStoreItem>();
|
|
[ShowInInspector] public Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
|
[Button]
|
|
void GenConfig(string name)
|
|
{
|
|
var serializeObject = JsonConvert.SerializeObject(this.storeItems);
|
|
Debug.Log(serializeObject);
|
|
|
|
string path = $"{this.configFolderPath}/{name}.txt";
|
|
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
|
|
{
|
|
var bytes = Encoding.UTF8.GetBytes(serializeObject);
|
|
fs.Write(bytes);
|
|
fs.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class MallStoreItem
|
|
{
|
|
[ShowInInspector] public long id => this.GetHashCode();
|
|
[ShowInInspector] public string name;
|
|
[ShowInInspector] public string icon;
|
|
[ShowInInspector] public string desc;
|
|
[ShowInInspector] public List<MallScrollItem> data;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class MallScrollItem
|
|
{
|
|
[ShowInInspector] public long id => this.GetHashCode();
|
|
[ShowInInspector] public string name;
|
|
[ShowInInspector] public string icon;
|
|
[ShowInInspector] public string desc;
|
|
[ShowInInspector] public int count;
|
|
[ShowInInspector] public MallItemMessage data;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class MallItemMessage
|
|
{
|
|
}
|
|
} |