Update HotReload
This commit is contained in:
@@ -5,10 +5,34 @@ using System.Text;
|
||||
using SingularityGroup.HotReload.Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using SingularityGroup.HotReload.DTO;
|
||||
using SingularityGroup.HotReload.Localization;
|
||||
|
||||
namespace SingularityGroup.HotReload.Editor.Cli {
|
||||
internal static class CliUtils {
|
||||
static readonly string projectIdentifier = GetProjectIdentifier();
|
||||
|
||||
class Config {
|
||||
public bool singleInstance;
|
||||
}
|
||||
|
||||
public static string GetProjectIdentifier() {
|
||||
if (File.Exists(PackageConst.ConfigFilePath)) {
|
||||
var config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(PackageConst.ConfigFilePath));
|
||||
if (config.singleInstance) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var path = Path.GetFullPath(MultiplayerPlaymodeHelper.PathToMainProject("."));
|
||||
var name = new DirectoryInfo(path).Name;
|
||||
using (SHA256 sha256 = SHA256.Create()) {
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(path);
|
||||
byte[] hashBytes = sha256.ComputeHash(inputBytes);
|
||||
var hash = BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 6).ToUpper();
|
||||
return $"{name}-{hash}";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTempDownloadFilePath(string osxFileName) {
|
||||
if (UnityHelper.Platform == RuntimePlatform.OSXEditor) {
|
||||
// project specific temp directory that is writeable on MacOS (Path.GetTempPath() wasn't when run through HotReload.app)
|
||||
@@ -19,6 +43,16 @@ namespace SingularityGroup.HotReload.Editor.Cli {
|
||||
}
|
||||
|
||||
public static string GetHotReloadTempDir() {
|
||||
if (UnityHelper.Platform == RuntimePlatform.WindowsEditor) {
|
||||
// library path interfereces with VS Code file watcher (Source Control window doesn't auto refresh)
|
||||
// so we pick data path on windows instead
|
||||
if (projectIdentifier != null) {
|
||||
return Path.Combine(GetAppDataPath(), "HotReloadServerTemp", projectIdentifier);
|
||||
} else {
|
||||
return Path.Combine(GetAppDataPath(), "HotReloadServerTemp");
|
||||
}
|
||||
}
|
||||
// store in library path on mac and linux since it works there
|
||||
return Path.GetFullPath(Path.Combine(PackageConst.LibraryCachePath, "HotReloadServerTemp"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user