|
@@ -6,7 +6,6 @@ using UnityEngine;
|
|
|
|
|
|
public static class EditorUser
|
|
|
{
|
|
|
-
|
|
|
[MenuItem("用户/Blue/自动定位", false)]
|
|
|
static void BlueAutoImmersalSet()
|
|
|
{
|
|
@@ -85,8 +84,8 @@ public static class EditorUser
|
|
|
|
|
|
private static void WriteUserListConfig(string UserName)
|
|
|
{
|
|
|
- string folderPath = Application.dataPath + "/StreamingAssets";
|
|
|
- string filePath = Application.dataPath + "/StreamingAssets" + "/BlueUserListConfig.txt";
|
|
|
+ string folderPath = Application.dataPath + "/Resources";
|
|
|
+ string filePath = folderPath + "/BlueUserListConfig.txt";
|
|
|
|
|
|
if (!Directory.Exists(folderPath))
|
|
|
Directory.CreateDirectory(folderPath);
|
|
@@ -111,9 +110,10 @@ public static class EditorUser
|
|
|
private static BlueUserConfig mBlueUserConfig;
|
|
|
private static void WriteUserConfig(BlueUserType blueUserType)
|
|
|
{
|
|
|
- string filePath = Application.dataPath + "/StreamingAssets" + "/BlueUserConfig.txt";
|
|
|
- string filePathList = Application.dataPath + "/StreamingAssets" + "/BlueUserListConfig.txt";
|
|
|
- string jsonString = File.ReadAllText(filePathList);
|
|
|
+ string filePathRes = Application.dataPath + "/Resources" + "/BlueUserConfig.txt";
|
|
|
+ string filePathStr = Application.dataPath + "/StreamingAssets" + "/BlueUserConfig.txt";
|
|
|
+ string filePathList = Application.dataPath + "/Resources" + "/BlueUserListConfig.txt";
|
|
|
+ string jsonString = Resources.Load<TextAsset>("BlueUserListConfig").text;
|
|
|
List<BlueUserConfig> BlueUserListConfig = JsonConvert.DeserializeObject<List<BlueUserConfig>>(jsonString);
|
|
|
foreach(var BlueUserConfig in BlueUserListConfig)
|
|
|
{
|
|
@@ -127,12 +127,27 @@ public static class EditorUser
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
string jsonData = JsonConvert.SerializeObject(mBlueUserConfig);
|
|
|
- if (File.Exists(filePath))
|
|
|
- File.WriteAllText(filePath, jsonData);
|
|
|
+ if (File.Exists(filePathRes))
|
|
|
+ File.WriteAllText(filePathRes, jsonData);
|
|
|
else
|
|
|
{
|
|
|
- FileStream file = new FileStream(filePath, FileMode.Create);
|
|
|
+ FileStream file = new FileStream(filePathRes, FileMode.Create);
|
|
|
+ byte[] bts = System.Text.Encoding.UTF8.GetBytes(jsonData);
|
|
|
+ file.Write(bts, 0, bts.Length);
|
|
|
+ if (file != null)
|
|
|
+ {
|
|
|
+ file.Flush();
|
|
|
+ file.Close();
|
|
|
+ file.Dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (File.Exists(filePathStr))
|
|
|
+ File.WriteAllText(filePathStr, jsonData);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FileStream file = new FileStream(filePathStr, FileMode.Create);
|
|
|
byte[] bts = System.Text.Encoding.UTF8.GetBytes(jsonData);
|
|
|
file.Write(bts, 0, bts.Length);
|
|
|
if (file != null)
|