diff --git a/build.gradle b/build.gradle index ef263cba..5f70e26e 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ project.ext { (OperatingSystem.WINDOWS): ["\\Program Files\\Unity\\Editor\\Unity.exe"] + (new FileNameFinder()).getFileNames( - "\\", "Program Files\\Unity\\Hub\\Editor\\*\\Editor\\Unity.exe"), + "\\Program Files\\Unity\\Hub\\Editor", "*\\Editor\\Unity.exe"), // previously don't work on windows (OperatingSystem.LINUX): ["/opt/Unity/Editor/Unity"]][operatingSystem] // Search for the Unity editor executable. @@ -61,9 +61,10 @@ project.ext { (OperatingSystem.MAC_OSX): "Unity.app/Contents/MacOS", (OperatingSystem.WINDOWS): "Editor", (OperatingSystem.LINUX): "Editor"][operatingSystem] - File unityRootDir = findFileProperty( - "UNITY_DIR", new File(unityExe.parentFile.absolutePath - - unityExeParentPath), true) + + // (string - string) will remove first occurance. We need to remove last occurance + File unityRootDir = findFileProperty("UNITY_DIR", + new File(unityExe.parentFile.absolutePath.substring(0,unityExe.parentFile.absolutePath.lastIndexOf(unityExeParentPath))), true) if (unityRootDir == null) { throw new StopActionException("Unity root directory (UNITY_DIR) not found.") } diff --git a/source/PlayServicesResolver/scripts/gradle-template.zip b/source/PlayServicesResolver/scripts/gradle-template.zip index fff63fa5..cba424ef 100644 Binary files a/source/PlayServicesResolver/scripts/gradle-template.zip and b/source/PlayServicesResolver/scripts/gradle-template.zip differ diff --git a/source/PlayServicesResolver/src/PlayServicesResolver.cs b/source/PlayServicesResolver/src/PlayServicesResolver.cs index 8581e0cb..1a088149 100644 --- a/source/PlayServicesResolver/src/PlayServicesResolver.cs +++ b/source/PlayServicesResolver/src/PlayServicesResolver.cs @@ -1,4 +1,4 @@ -// +// // Copyright (C) 2015 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -170,14 +170,12 @@ public static DependencyState ReadFromFile() { return true; } else if (elementName == "package" && parentElementName == "packages") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { packages.Add(reader.ReadContentAsString()); } return true; } else if (elementName == "file" && parentElementName == "files") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { files.Add(reader.ReadContentAsString()); } return true; @@ -1058,32 +1056,52 @@ private static void OnPostProcessScene() { /// Defaults to 1 second. private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { lock (typeof(PlayServicesResolver)) { - if (!autoResolving) { - RunOnMainThread.Cancel(autoResolveJobId); - autoResolveJobId = RunOnMainThread.Schedule( - () => { - lock (typeof(PlayServicesResolver)) { - autoResolving = true; + if (autoResolving) { + return; + } + + RunOnMainThread.Cancel(autoResolveJobId); + autoResolveJobId = RunOnMainThread.Schedule(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = true; + } + + int delaySec = GooglePlayServices.SettingsDialog.AutoResolutionDelay; + DateTimeOffset resolveTime = DateTimeOffset.Now.AddSeconds(delaySec); + bool shouldResolve = true; + RunOnMainThread.PollOnUpdateUntilComplete(() => { + // Only run AutoResolve() if we have a valid autoResolveJobId. + // If autoResolveJobId is 0, ScheduleResolve() + // has already been run and we should not run AutoResolve() + // again. + if(autoResolveJobId == 0) + return true; + + DateTimeOffset now = DateTimeOffset.Now; + if (resolveTime > now && PlayServicesResolver.AutomaticResolutionEnabled) { + float countDown = (float)(resolveTime - now).TotalSeconds; + if(EditorUtility.DisplayCancelableProgressBar("Skip dependency?","Auto Resolve Dependency in : " + (int)countDown,countDown / delaySec)) { + resolveTime = now; + shouldResolve = false; } - RunOnMainThread.PollOnUpdateUntilComplete(() => { - if (EditorApplication.isCompiling) return false; - // Only run AutoResolve() if we have a valid autoResolveJobId. - // If autoResolveJobId is 0, ScheduleResolve() - // has already been run and we should not run AutoResolve() - // again. - if (autoResolveJobId != 0) { - AutoResolve(() => { - lock (typeof(PlayServicesResolver)) { - autoResolving = false; - autoResolveJobId = 0; - } - }); + + return false; + } + + EditorUtility.ClearProgressBar(); + + if (EditorApplication.isCompiling) return false; + if (shouldResolve) { + AutoResolve(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = false; + autoResolveJobId = 0; } - return true; }); - }, - delayInMilliseconds); - } + } + return true; + }); + },delayInMilliseconds); } } @@ -1550,9 +1568,7 @@ private static void ScheduleResolve(bool forceResolution, bool closeWindowOnComp RunOnMainThread.Cancel(autoResolveJobId); autoResolveJobId = 0; // Remove any enqueued auto-resolve jobs. - resolutionJobs.RemoveAll((jobInfo) => { - return jobInfo != null && jobInfo.IsAutoResolveJob; - }); + resolutionJobs.RemoveAll((jobInfo) => jobInfo == null || jobInfo.IsAutoResolveJob); firstJob = resolutionJobs.Count == 0; resolutionJobs.Add( diff --git a/source/PlayServicesResolver/src/SettingsDialog.cs b/source/PlayServicesResolver/src/SettingsDialog.cs index 682f08b7..74c0e653 100644 --- a/source/PlayServicesResolver/src/SettingsDialog.cs +++ b/source/PlayServicesResolver/src/SettingsDialog.cs @@ -41,6 +41,7 @@ private class Settings { internal bool verboseLogging; internal bool autoResolutionDisabledWarning; internal bool promptBeforeAutoResolution; + internal int autoResolutionDelay; internal bool useProjectSettings; /// @@ -59,6 +60,7 @@ internal Settings() { verboseLogging = SettingsDialog.VerboseLogging; autoResolutionDisabledWarning = SettingsDialog.AutoResolutionDisabledWarning; promptBeforeAutoResolution = SettingsDialog.PromptBeforeAutoResolution; + autoResolutionDelay = SettingsDialog.AutoResolutionDelay; useProjectSettings = SettingsDialog.UseProjectSettings; } @@ -78,6 +80,7 @@ internal void Save() { SettingsDialog.VerboseLogging = verboseLogging; SettingsDialog.AutoResolutionDisabledWarning = autoResolutionDisabledWarning; SettingsDialog.PromptBeforeAutoResolution = promptBeforeAutoResolution; + SettingsDialog.AutoResolutionDelay = autoResolutionDelay; SettingsDialog.UseProjectSettings = useProjectSettings; } } @@ -92,10 +95,9 @@ internal void Save() { private const string PatchMainTemplateGradleKey = Namespace + "PatchMainTemplateGradle"; private const string UseJetifierKey = Namespace + "UseJetifier"; private const string VerboseLoggingKey = Namespace + "VerboseLogging"; - private const string AutoResolutionDisabledWarningKey = - Namespace + "AutoResolutionDisabledWarning"; - private const string PromptBeforeAutoResolutionKey = - Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDisabledWarningKey = Namespace + "AutoResolutionDisabledWarning"; + private const string PromptBeforeAutoResolutionKey = Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDelayKey = Namespace + "AutoResolutionDelay"; private const string UseGradleDaemonKey = Namespace + "UseGradleDaemon"; // List of preference keys, used to restore default settings. @@ -189,12 +191,16 @@ internal static bool AutoResolutionDisabledWarning { /// display a prompt. /// internal static bool PromptBeforeAutoResolution { - set { - projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); - } + set { projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); } get { return projectSettings.GetBool(PromptBeforeAutoResolutionKey, true); } } + const int MAXIMUM_AUTO_RESOLVE_DELAY_TIME = 30; + internal static int AutoResolutionDelay { + set { projectSettings.SetInt(AutoResolutionDelayKey,Math.Min(Math.Max(0,value),MAXIMUM_AUTO_RESOLVE_DELAY_TIME)); } + get { return Math.Min(Math.Max(0,projectSettings.GetInt(AutoResolutionDelayKey,0)),MAXIMUM_AUTO_RESOLVE_DELAY_TIME); } + } + internal static bool UseProjectSettings { get { return projectSettings.UseProjectSettings; } set { projectSettings.UseProjectSettings = value; } @@ -375,8 +381,12 @@ public void OnGUI() { EditorGUI.BeginDisabledGroup(!settings.enableAutoResolution); GUILayout.BeginHorizontal(); GUILayout.Label("Prompt Before Auto-Resolution", EditorStyles.boldLabel); - settings.promptBeforeAutoResolution = - EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + settings.promptBeforeAutoResolution = EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Auto Resolution Delay", EditorStyles.boldLabel); + settings.autoResolutionDelay = Mathf.Clamp(EditorGUILayout.IntField(settings.autoResolutionDelay),0,MAXIMUM_AUTO_RESOLVE_DELAY_TIME); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup();