From 793b8b7ed8b4e29722804e3b95fa6e9ffa6c43a2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 4 Jun 2020 18:27:47 +0800 Subject: [PATCH 01/11] Add preference --- ParrelSync/Editor/Preference.cs | 43 ++++++++++++++++++++++++++++ ParrelSync/Editor/Preference.cs.meta | 11 +++++++ 2 files changed, 54 insertions(+) create mode 100644 ParrelSync/Editor/Preference.cs create mode 100644 ParrelSync/Editor/Preference.cs.meta diff --git a/ParrelSync/Editor/Preference.cs b/ParrelSync/Editor/Preference.cs new file mode 100644 index 0000000..7366f1f --- /dev/null +++ b/ParrelSync/Editor/Preference.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ParrelSync +{ + public class Preference : EditorWindow + { + [MenuItem("ParrelSync/Preferences", priority = 1)] + private static void InitWindow() + { + Preference window = (Preference)EditorWindow.GetWindow(typeof(Preference)); + window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences"); + window.Show(); + } + + const string AssetModProtectionKey = "ParrelSync_AssetModProtect"; + bool EnableAssetModProtection { get { return EditorPrefs.GetBool(AssetModProtectionKey, true); } } + private void OnGUI() + { + GUILayout.BeginVertical("HelpBox"); + GUILayout.Label("Preferences"); + GUILayout.BeginVertical("GroupBox"); + bool IsAssetModProtectionEnabled = EnableAssetModProtection; + IsAssetModProtectionEnabled = GUILayout.Toggle(IsAssetModProtectionEnabled, + "Disable asset modification saving in clone editors."); + if(IsAssetModProtectionEnabled != EnableAssetModProtection) + { + EditorPrefs.SetBool(AssetModProtectionKey, IsAssetModProtectionEnabled); + Debug.Log("ParrelSync editor preference updated. EnableAssetModProtection: " + + EnableAssetModProtection); + } + GUILayout.EndVertical(); + if (GUILayout.Button("Clear Preferences")) + { + EditorPrefs.DeleteKey(AssetModProtectionKey); + Debug.Log("Removed editor preference: " + AssetModProtectionKey); + } + GUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/ParrelSync/Editor/Preference.cs.meta b/ParrelSync/Editor/Preference.cs.meta new file mode 100644 index 0000000..0166f9a --- /dev/null +++ b/ParrelSync/Editor/Preference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 24641be1c0410a745b529e61b508679f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 8e08fbc6ad8d2cbb3341e2ae73d081e43cdafa88 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:07:55 +0800 Subject: [PATCH 02/11] Update preference window --- ParrelSync/Editor/Preference.cs | 43 -------- ParrelSync/Editor/PreferencesWindow.cs | 99 +++++++++++++++++++ ...ence.cs.meta => PreferencesWindow.cs.meta} | 0 3 files changed, 99 insertions(+), 43 deletions(-) delete mode 100644 ParrelSync/Editor/Preference.cs create mode 100644 ParrelSync/Editor/PreferencesWindow.cs rename ParrelSync/Editor/{Preference.cs.meta => PreferencesWindow.cs.meta} (100%) diff --git a/ParrelSync/Editor/Preference.cs b/ParrelSync/Editor/Preference.cs deleted file mode 100644 index 7366f1f..0000000 --- a/ParrelSync/Editor/Preference.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace ParrelSync -{ - public class Preference : EditorWindow - { - [MenuItem("ParrelSync/Preferences", priority = 1)] - private static void InitWindow() - { - Preference window = (Preference)EditorWindow.GetWindow(typeof(Preference)); - window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences"); - window.Show(); - } - - const string AssetModProtectionKey = "ParrelSync_AssetModProtect"; - bool EnableAssetModProtection { get { return EditorPrefs.GetBool(AssetModProtectionKey, true); } } - private void OnGUI() - { - GUILayout.BeginVertical("HelpBox"); - GUILayout.Label("Preferences"); - GUILayout.BeginVertical("GroupBox"); - bool IsAssetModProtectionEnabled = EnableAssetModProtection; - IsAssetModProtectionEnabled = GUILayout.Toggle(IsAssetModProtectionEnabled, - "Disable asset modification saving in clone editors."); - if(IsAssetModProtectionEnabled != EnableAssetModProtection) - { - EditorPrefs.SetBool(AssetModProtectionKey, IsAssetModProtectionEnabled); - Debug.Log("ParrelSync editor preference updated. EnableAssetModProtection: " - + EnableAssetModProtection); - } - GUILayout.EndVertical(); - if (GUILayout.Button("Clear Preferences")) - { - EditorPrefs.DeleteKey(AssetModProtectionKey); - Debug.Log("Removed editor preference: " + AssetModProtectionKey); - } - GUILayout.EndVertical(); - } - } -} \ No newline at end of file diff --git a/ParrelSync/Editor/PreferencesWindow.cs b/ParrelSync/Editor/PreferencesWindow.cs new file mode 100644 index 0000000..524d4bc --- /dev/null +++ b/ParrelSync/Editor/PreferencesWindow.cs @@ -0,0 +1,99 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ParrelSync +{ + /// + /// For adding value caching for functions + /// + public class BoolPreference + { + public string key { get; private set; } + public bool defaultValue { get; private set; } + public BoolPreference(string key, bool defaultValue) + { + this.key = key; + this.defaultValue = defaultValue; + } + + private bool? valueCache = null; + + public bool GetValue() + { + if (valueCache == null) + valueCache = EditorPrefs.GetBool(key, defaultValue); + + return (bool)valueCache; + } + + public void SetValue(bool value) + { + if (valueCache == value) + return; + + EditorPrefs.SetBool(key, value); + valueCache = value; + Debug.Log("Editor preference updated. key: " + key + ", value: " + value); + } + + public void ClearValue() + { + EditorPrefs.DeleteKey(key); + valueCache = null; + } + } + + public class PreferencesWindow : EditorWindow + { + [MenuItem("ParrelSync/Preferences", priority = 1)] + private static void InitWindow() + { + PreferencesWindow window = (PreferencesWindow)EditorWindow.GetWindow(typeof(PreferencesWindow)); + window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences"); + window.Show(); + } + + public BoolPreference AssetModPref = new BoolPreference("ParrelSync_AssetModProtect", true); + + public BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownCloneProjectsOpenStatus", true); + public BoolPreference UnityLockFileOPenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); + + private void OnGUI() + { + GUILayout.BeginVertical("HelpBox"); + GUILayout.Label("Preferences"); + GUILayout.BeginVertical("GroupBox"); + + AssetModPref.SetValue( + EditorGUILayout.ToggleLeft("Disable asset saving in clone editors (recommended)", + AssetModPref.GetValue()) + ); + + ClonProOpenStasPref.SetValue( + EditorGUILayout.ToggleLeft("Show clone project open status in clone manager", + ClonProOpenStasPref.GetValue()) + ); + + if (ClonProOpenStasPref.GetValue()) + { + EditorGUI.indentLevel++; + UnityLockFileOPenStasPref.SetValue( + EditorGUILayout.ToggleLeft("Check is UnityLockFile locked by other program", + UnityLockFileOPenStasPref.GetValue()) + ); + EditorGUI.indentLevel--; + } + + GUILayout.EndVertical(); + if (GUILayout.Button("Reset to default")) + { + AssetModPref.ClearValue(); + ClonProOpenStasPref.ClearValue(); + UnityLockFileOPenStasPref.ClearValue(); + } + GUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/ParrelSync/Editor/Preference.cs.meta b/ParrelSync/Editor/PreferencesWindow.cs.meta similarity index 100% rename from ParrelSync/Editor/Preference.cs.meta rename to ParrelSync/Editor/PreferencesWindow.cs.meta From 037505cab745446b03d96b27d96d41ad2d4f77af Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:12:20 +0800 Subject: [PATCH 03/11] Update preference window --- ParrelSync/Editor/PreferencesWindow.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ParrelSync/Editor/PreferencesWindow.cs b/ParrelSync/Editor/PreferencesWindow.cs index 524d4bc..0d30bda 100644 --- a/ParrelSync/Editor/PreferencesWindow.cs +++ b/ParrelSync/Editor/PreferencesWindow.cs @@ -55,9 +55,9 @@ private static void InitWindow() window.Show(); } - public BoolPreference AssetModPref = new BoolPreference("ParrelSync_AssetModProtect", true); + public BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true); - public BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownCloneProjectsOpenStatus", true); + public BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownClonesOpenStatus", true); public BoolPreference UnityLockFileOPenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); private void OnGUI() @@ -92,6 +92,7 @@ private void OnGUI() AssetModPref.ClearValue(); ClonProOpenStasPref.ClearValue(); UnityLockFileOPenStasPref.ClearValue(); + Debug.Log("Editor preferences cleared"); } GUILayout.EndVertical(); } From 8892b74015afc6b4d60f6d4e70e874775af37d6b Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:13:46 +0800 Subject: [PATCH 04/11] Update preference window --- ParrelSync/Editor/PreferencesWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParrelSync/Editor/PreferencesWindow.cs b/ParrelSync/Editor/PreferencesWindow.cs index 0d30bda..fc94c02 100644 --- a/ParrelSync/Editor/PreferencesWindow.cs +++ b/ParrelSync/Editor/PreferencesWindow.cs @@ -80,7 +80,7 @@ private void OnGUI() { EditorGUI.indentLevel++; UnityLockFileOPenStasPref.SetValue( - EditorGUILayout.ToggleLeft("Check is UnityLockFile locked by other program", + EditorGUILayout.ToggleLeft("Check is UnityLockFile opened", UnityLockFileOPenStasPref.GetValue()) ); EditorGUI.indentLevel--; From 2ef52b9f541692e2bcfa2df27e95d934ef202cb6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:19:32 +0800 Subject: [PATCH 05/11] Update preference window --- .../Editor/{PreferencesWindow.cs => Preferences.cs} | 12 ++++++------ ...PreferencesWindow.cs.meta => Preferences.cs.meta} | 0 2 files changed, 6 insertions(+), 6 deletions(-) rename ParrelSync/Editor/{PreferencesWindow.cs => Preferences.cs} (82%) rename ParrelSync/Editor/{PreferencesWindow.cs.meta => Preferences.cs.meta} (100%) diff --git a/ParrelSync/Editor/PreferencesWindow.cs b/ParrelSync/Editor/Preferences.cs similarity index 82% rename from ParrelSync/Editor/PreferencesWindow.cs rename to ParrelSync/Editor/Preferences.cs index fc94c02..efcc2e4 100644 --- a/ParrelSync/Editor/PreferencesWindow.cs +++ b/ParrelSync/Editor/Preferences.cs @@ -6,7 +6,7 @@ namespace ParrelSync { /// - /// For adding value caching for functions + /// To add value caching for functions /// public class BoolPreference { @@ -45,20 +45,20 @@ public void ClearValue() } } - public class PreferencesWindow : EditorWindow + public class Preferences : EditorWindow { [MenuItem("ParrelSync/Preferences", priority = 1)] private static void InitWindow() { - PreferencesWindow window = (PreferencesWindow)EditorWindow.GetWindow(typeof(PreferencesWindow)); + Preferences window = (Preferences)EditorWindow.GetWindow(typeof(Preferences)); window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences"); window.Show(); } - public BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true); + public static BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true); - public BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownClonesOpenStatus", true); - public BoolPreference UnityLockFileOPenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); + public static BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownClonesOpenStatus", true); + public static BoolPreference UnityLockFileOPenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); private void OnGUI() { diff --git a/ParrelSync/Editor/PreferencesWindow.cs.meta b/ParrelSync/Editor/Preferences.cs.meta similarity index 100% rename from ParrelSync/Editor/PreferencesWindow.cs.meta rename to ParrelSync/Editor/Preferences.cs.meta From 8be9f3da1f3e9c7d3bbba9625cbe90c6a9fd45fe Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:38:15 +0800 Subject: [PATCH 06/11] Update preferences --- .../ParrelSyncAssetModificationProcessor.cs | 2 +- ParrelSync/Editor/ClonesManagerWindow.cs | 36 +++++++++++++------ ParrelSync/Editor/Preferences.cs | 19 +++++++--- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs b/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs index b1ac953..d716c73 100644 --- a/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs +++ b/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs @@ -11,7 +11,7 @@ public class ParrelSyncAssetModificationProcessor : UnityEditor.AssetModificatio { public static string[] OnWillSaveAssets(string[] paths) { - if (ClonesManager.IsClone()) + if (ClonesManager.IsClone() && Preferences.AssetModPref.GetValue()) { if (!EditorQuit.IsQuiting) { diff --git a/ParrelSync/Editor/ClonesManagerWindow.cs b/ParrelSync/Editor/ClonesManagerWindow.cs index cccc1ae..a413242 100644 --- a/ParrelSync/Editor/ClonesManagerWindow.cs +++ b/ParrelSync/Editor/ClonesManagerWindow.cs @@ -34,7 +34,7 @@ private static void InitWindow() private void OnGUI() { - if(Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.LinuxEditor) + if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.LinuxEditor) { EditorGUILayout.HelpBox( "Sorry, but " + ClonesManager.ProjectName + " doesn't support Mac and Linux currently.\n" + @@ -49,7 +49,7 @@ private void OnGUI() /// If it is a clone project... if (ClonesManager.IsClone()) - { + { //Find out the original project name and show the help box string originalProjectPath = ClonesManager.GetOriginalProjectPath(); if (originalProjectPath == string.Empty) @@ -105,7 +105,7 @@ private void OnGUI() //List all clones clonesScrollPos = - EditorGUILayout.BeginScrollView(clonesScrollPos); + EditorGUILayout.BeginScrollView(clonesScrollPos); var cloneProjectsPath = ClonesManager.GetCloneProjectsPath(); for (int i = 0; i < cloneProjectsPath.Count; i++) { @@ -113,23 +113,35 @@ private void OnGUI() GUILayout.BeginVertical("GroupBox"); string cloneProjectPath = cloneProjectsPath[i]; - //Determine whether it is opened in another instance by checking the UnityLockFile + bool? isOpenInAnotherInstance = null; + if (Preferences.ClonProOpenStasPref.GetValue()) + { + //Determine whether it is opened in another instance by checking the UnityLockFile + string UnityLockFilePath = Path.Combine(cloneProjectPath, "Temp", "UnityLockfile"); - string UnityLockFilePath = Path.Combine(cloneProjectPath, "Temp", "UnityLockfile"); - bool isOpenInAnotherInstance = File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath); + if (Preferences.UnityLockFileOpenStasPref.GetValue()) + isOpenInAnotherInstance = File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath); + else + isOpenInAnotherInstance = File.Exists(UnityLockFilePath); - if (isOpenInAnotherInstance) - EditorGUILayout.LabelField("Clone " + i + " (Running)", EditorStyles.boldLabel); + if (isOpenInAnotherInstance == true) + EditorGUILayout.LabelField("Clone " + i + " (Running)", EditorStyles.boldLabel); + else + EditorGUILayout.LabelField("Clone " + i); + } else + { EditorGUILayout.LabelField("Clone " + i); + } + GUILayout.BeginHorizontal(); EditorGUILayout.TextField("Clone project path", cloneProjectPath, EditorStyles.textField); if (GUILayout.Button("View Folder", GUILayout.Width(80))) { - ClonesManager.OpenProjectInFileExplorer(cloneProjectPath); + ClonesManager.OpenProjectInFileExplorer(cloneProjectPath); } GUILayout.EndHorizontal(); @@ -165,7 +177,9 @@ private void OnGUI() EditorGUILayout.Space(); EditorGUILayout.Space(); - EditorGUI.BeginDisabledGroup(isOpenInAnotherInstance); + if (isOpenInAnotherInstance != null) + EditorGUI.BeginDisabledGroup((bool)isOpenInAnotherInstance); + if (GUILayout.Button("Open in New Editor")) { ClonesManager.OpenProject(cloneProjectPath); @@ -184,7 +198,7 @@ private void OnGUI() ClonesManager.DeleteClone(cloneProjectPath); } } - + GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); GUILayout.EndVertical(); diff --git a/ParrelSync/Editor/Preferences.cs b/ParrelSync/Editor/Preferences.cs index efcc2e4..4b2cea2 100644 --- a/ParrelSync/Editor/Preferences.cs +++ b/ParrelSync/Editor/Preferences.cs @@ -55,10 +55,21 @@ private static void InitWindow() window.Show(); } + /// + /// Disable asset saving in clone editors? + /// public static BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true); + /// + /// Show Project clones open status? + /// public static BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownClonesOpenStatus", true); - public static BoolPreference UnityLockFileOPenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); + /// + /// If show project clones open status, + /// in addition of checking the existence of UnityLockFile, + /// also check is the lock file opened by another program. + /// + public static BoolPreference UnityLockFileOpenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); private void OnGUI() { @@ -79,9 +90,9 @@ private void OnGUI() if (ClonProOpenStasPref.GetValue()) { EditorGUI.indentLevel++; - UnityLockFileOPenStasPref.SetValue( + UnityLockFileOpenStasPref.SetValue( EditorGUILayout.ToggleLeft("Check is UnityLockFile opened", - UnityLockFileOPenStasPref.GetValue()) + UnityLockFileOpenStasPref.GetValue()) ); EditorGUI.indentLevel--; } @@ -91,7 +102,7 @@ private void OnGUI() { AssetModPref.ClearValue(); ClonProOpenStasPref.ClearValue(); - UnityLockFileOPenStasPref.ClearValue(); + UnityLockFileOpenStasPref.ClearValue(); Debug.Log("Editor preferences cleared"); } GUILayout.EndVertical(); From eb204e758c934fd9f638b3d9946f0fcf6eededb4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:42:59 +0800 Subject: [PATCH 07/11] Update preferences --- ParrelSync/Editor/Preferences.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ParrelSync/Editor/Preferences.cs b/ParrelSync/Editor/Preferences.cs index 4b2cea2..ac89fad 100644 --- a/ParrelSync/Editor/Preferences.cs +++ b/ParrelSync/Editor/Preferences.cs @@ -73,6 +73,14 @@ private static void InitWindow() private void OnGUI() { + if (ClonesManager.IsClone()) + { + EditorGUILayout.HelpBox( + "This is a clone project. Please use the original project editor to change preferences.", + MessageType.Info); + return; + } + GUILayout.BeginVertical("HelpBox"); GUILayout.Label("Preferences"); GUILayout.BeginVertical("GroupBox"); From efd8ba9efddc6a28114ce33a3eafbcc4a4d38b22 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 20:49:33 +0800 Subject: [PATCH 08/11] Update preference window --- ParrelSync/Editor/Preferences.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParrelSync/Editor/Preferences.cs b/ParrelSync/Editor/Preferences.cs index ac89fad..11dc198 100644 --- a/ParrelSync/Editor/Preferences.cs +++ b/ParrelSync/Editor/Preferences.cs @@ -86,7 +86,7 @@ private void OnGUI() GUILayout.BeginVertical("GroupBox"); AssetModPref.SetValue( - EditorGUILayout.ToggleLeft("Disable asset saving in clone editors (recommended)", + EditorGUILayout.ToggleLeft("(recommended) Disable asset saving in clone editors, require re-open clone editors", AssetModPref.GetValue()) ); From 265f980c0d009f8f8cdc5b9003591debf14a3813 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Thu, 9 Jul 2020 23:58:14 +0800 Subject: [PATCH 09/11] Update preferences --- ParrelSync/Editor/ClonesManagerWindow.cs | 32 ++++++++++-------------- ParrelSync/Editor/Preferences.cs | 32 +++++++----------------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/ParrelSync/Editor/ClonesManagerWindow.cs b/ParrelSync/Editor/ClonesManagerWindow.cs index a413242..9395e04 100644 --- a/ParrelSync/Editor/ClonesManagerWindow.cs +++ b/ParrelSync/Editor/ClonesManagerWindow.cs @@ -113,28 +113,22 @@ private void OnGUI() GUILayout.BeginVertical("GroupBox"); string cloneProjectPath = cloneProjectsPath[i]; - bool? isOpenInAnotherInstance = null; - if (Preferences.ClonProOpenStasPref.GetValue()) - { - //Determine whether it is opened in another instance by checking the UnityLockFile - string UnityLockFilePath = Path.Combine(cloneProjectPath, "Temp", "UnityLockfile"); + + + //Determine whether it is opened in another instance by checking the UnityLockFile + string UnityLockFilePath = Path.Combine(cloneProjectPath, "Temp", "UnityLockfile"); + bool isOpenInAnotherInstance = false; + if (Preferences.AlsoCheckUnityLockFileStaPref.GetValue()) + isOpenInAnotherInstance = File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath); + else + isOpenInAnotherInstance = File.Exists(UnityLockFilePath); - if (Preferences.UnityLockFileOpenStasPref.GetValue()) - isOpenInAnotherInstance = File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath); - else - isOpenInAnotherInstance = File.Exists(UnityLockFilePath); - if (isOpenInAnotherInstance == true) - EditorGUILayout.LabelField("Clone " + i + " (Running)", EditorStyles.boldLabel); - else - EditorGUILayout.LabelField("Clone " + i); - } + if (isOpenInAnotherInstance == true) + EditorGUILayout.LabelField("Clone " + i + " (Running)", EditorStyles.boldLabel); else - { EditorGUILayout.LabelField("Clone " + i); - } - GUILayout.BeginHorizontal(); @@ -177,8 +171,8 @@ private void OnGUI() EditorGUILayout.Space(); EditorGUILayout.Space(); - if (isOpenInAnotherInstance != null) - EditorGUI.BeginDisabledGroup((bool)isOpenInAnotherInstance); + + EditorGUI.BeginDisabledGroup(isOpenInAnotherInstance); if (GUILayout.Button("Open in New Editor")) { diff --git a/ParrelSync/Editor/Preferences.cs b/ParrelSync/Editor/Preferences.cs index 11dc198..fa6a5cd 100644 --- a/ParrelSync/Editor/Preferences.cs +++ b/ParrelSync/Editor/Preferences.cs @@ -61,15 +61,10 @@ private static void InitWindow() public static BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true); /// - /// Show Project clones open status? + /// In addition of checking the existence of UnityLockFile, + /// also check is the is the UnityLockFile being opened. /// - public static BoolPreference ClonProOpenStasPref = new BoolPreference("ParrelSync_ShownClonesOpenStatus", true); - /// - /// If show project clones open status, - /// in addition of checking the existence of UnityLockFile, - /// also check is the lock file opened by another program. - /// - public static BoolPreference UnityLockFileOpenStasPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); + public static BoolPreference AlsoCheckUnityLockFileStaPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true); private void OnGUI() { @@ -86,31 +81,22 @@ private void OnGUI() GUILayout.BeginVertical("GroupBox"); AssetModPref.SetValue( - EditorGUILayout.ToggleLeft("(recommended) Disable asset saving in clone editors, require re-open clone editors", + EditorGUILayout.ToggleLeft("(recommended) Disable asset saving in clone editors- require re-open clone editors", AssetModPref.GetValue()) ); - ClonProOpenStasPref.SetValue( - EditorGUILayout.ToggleLeft("Show clone project open status in clone manager", - ClonProOpenStasPref.GetValue()) + + AlsoCheckUnityLockFileStaPref.SetValue( + EditorGUILayout.ToggleLeft("Also check UnityLockFile lock status while checking clone projects running status", + AlsoCheckUnityLockFileStaPref.GetValue()) ); - if (ClonProOpenStasPref.GetValue()) - { - EditorGUI.indentLevel++; - UnityLockFileOpenStasPref.SetValue( - EditorGUILayout.ToggleLeft("Check is UnityLockFile opened", - UnityLockFileOpenStasPref.GetValue()) - ); - EditorGUI.indentLevel--; - } GUILayout.EndVertical(); if (GUILayout.Button("Reset to default")) { AssetModPref.ClearValue(); - ClonProOpenStasPref.ClearValue(); - UnityLockFileOpenStasPref.ClearValue(); + AlsoCheckUnityLockFileStaPref.ClearValue(); Debug.Log("Editor preferences cleared"); } GUILayout.EndVertical(); From 475b92c4587de7c3dd31c3f48d33d97016c39329 Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Fri, 10 Jul 2020 00:07:22 +0800 Subject: [PATCH 10/11] Correct typo --- .../AssetModBlock/ParrelSyncAssetModificationProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs b/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs index e50b6e2..ac9d19d 100644 --- a/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs +++ b/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs @@ -20,7 +20,7 @@ public static string[] OnWillSaveAssets(string[] paths) "Asset modifications saving are blocked in the clone instance. \n\n" + "This is a clone of the original project. \n" + "Making changes to asset files via the clone editor is not recommended. \n" + - "Please use the original editor instance if you want to make changes the project files.", + "Please use the original editor window if you want to make changes to the project files.", "ok" ); foreach (var path in paths) From ca38fa2f2171dfefbd9bf582617f2dbab414872b Mon Sep 17 00:00:00 2001 From: "DESKTOP-ESM69JQ\\ubnnjh" Date: Fri, 10 Jul 2020 00:08:57 +0800 Subject: [PATCH 11/11] Update version text --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index d5e98f7..785cda8 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.3.2 \ No newline at end of file +1.3.3 \ No newline at end of file