Skip to content

Commit

Permalink
fix editor script potential issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonXuDeveloper committed Oct 20, 2023
1 parent 9cb3ff9 commit dda6391
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ private static async void DoChange()
var op = SceneManager.LoadSceneAsync(name);
while (SceneManager.GetActiveScene().path != path)
{
if (!Application.isPlaying) return;
EditorUtility.DisplayProgressBar("JEngine", Setting.GetString(SettingString.JumpToStartUpScene), op.progress);
await Task.Delay(100);
}
EditorUtility.ClearProgressBar();
DynamicGI.UpdateEnvironment();
}

var comp = Object.FindFirstObjectByType<InitJEngine>();
var comp = Object.FindObjectOfType<InitJEngine>();
if (comp == null)
{
Debug.LogWarning("没有找到InitJEngine脚本,无法检验秘钥是否正确");
// Debug.LogWarning("没有找到InitJEngine脚本,无法检验秘钥是否正确");
return;
}
var key = comp.key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class SetData
{
public static bool HasAdded;
private static string _path = "JEngine.proj";
private static JEngineProjData _data = new JEngineProjData();
private static JEngineProjData _data;

public static void UpdateData(Action<JEngineProjData> func)
{
Expand All @@ -23,54 +23,59 @@ public static void UpdateData(Action<JEngineProjData> func)

public static string GetPrefix()
{
//看看文件存不存在,不存在就创建和提示
string fPath = Path.Combine(Application.dataPath, _path);
if (!File.Exists(fPath))
if (_data == null)
{
_data = new JEngineProjData();
//兼容老版本
bool flag = false;
if (File.Exists(Path.Combine(Application.dataPath, "JEngine.lock")))
//看看文件存不存在,不存在就创建和提示
string fPath = Path.Combine(Application.dataPath, _path);
if (!File.Exists(fPath))
{
_data.Prefix = File.ReadAllText(Path.Combine(Application.dataPath, "JEngine.lock"));
_data.EncryptPassword = PlayerPrefs.GetString($"{_data.Prefix}.EncryptPassword", "");
File.Delete(Path.Combine(Application.dataPath, "JEngine.lock"));
}
else
{
_data.Prefix = Guid.NewGuid().ToString();
flag = true;
}
Span<byte> data = stackalloc byte[_data.Size()];
_data.AsBinary(ref data);
File.WriteAllBytes(fPath, data.ToArray());
if (flag)
{
//提示看文档
Debug.LogError(Setting.GetString(SettingString.NoticeText));
EditorUtility.DisplayDialog(Setting.GetString(SettingString.Notice),
Setting.GetString(SettingString.NoticeText), Setting.GetString(SettingString.Done));
if (Setting.Language == JEngineLanguage.English)
//兼容老版本
bool flag = false;
if (File.Exists(Path.Combine(Application.dataPath, "JEngine.lock")))
{
Application.OpenURL("https://docs.xgamedev.net/documents/0.8/");
_data.Prefix = File.ReadAllText(Path.Combine(Application.dataPath, "JEngine.lock"));
_data.EncryptPassword = PlayerPrefs.GetString($"{_data.Prefix}.EncryptPassword", "");
File.Delete(Path.Combine(Application.dataPath, "JEngine.lock"));
}
else
{
Application.OpenURL("https://docs.xgamedev.net/zh/documents/0.8/");
_data.Prefix = Guid.NewGuid().ToString();
flag = true;
}

Span<byte> data = stackalloc byte[_data.Size()];
_data.AsBinary(ref data);
File.WriteAllBytes(fPath, data.ToArray());
if (flag)
{
//提示看文档
Debug.LogError(Setting.GetString(SettingString.NoticeText));
EditorUtility.DisplayDialog(Setting.GetString(SettingString.Notice),
Setting.GetString(SettingString.NoticeText), Setting.GetString(SettingString.Done));
if (Setting.Language == JEngineLanguage.English)
{
Application.OpenURL("https://docs.xgamedev.net/documents/0.8/");
}
else
{
Application.OpenURL("https://docs.xgamedev.net/zh/documents/0.8/");
}
}

InjectDefineSymbol();
}
else
{
//读取文件
Span<byte> data = File.ReadAllBytes(fPath);
_data.FromBinary(ref data);
}
InjectDefineSymbol();
}
else
{
//读取文件
Span<byte> data = File.ReadAllBytes(fPath);
_data.FromBinary(ref data);
}

return _data.Prefix;
}

public static void Update()
{
string prefix = GetPrefix();
Expand Down

0 comments on commit dda6391

Please sign in to comment.