Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Added checks for editor updating #313

Merged
merged 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public static ScriptableObject CreateAsset(this ScriptableObject scriptableObjec

AssetDatabase.CreateAsset(scriptableObject, assetPathAndName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}

EditorUtility.FocusProjectWindow();
Selection.activeObject = scriptableObject;
EditorGUIUtility.PingObject(scriptableObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ private static SceneAsset GetSceneObject(string sceneName, SceneAsset asset = nu
EditorBuildSettings.scenes = scenes;
Debug.Assert(EditorBuildSettings.scenes[0].guid == sceneGuid);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}
}

if (!EditorBuildSettings.scenes[0].enabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public static void ReplaceWithAssembly()
Debug.LogError("Failed to replace source code with assembly!");
}

AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}

EditorUtility.ClearProgressBar();
}

Expand Down Expand Up @@ -270,7 +274,11 @@ public static void ReplaceWithSource()
File.Delete(builtAssemblyPath);
File.Delete($"{builtAssemblyPath}{META}");

AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}

EditorUtility.ClearProgressBar();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ internal static async Task<Tuple<MixedRealityPackageInfo, bool>[]> GetCurrentMix

private static async Task AddPackageAsync(MixedRealityPackageInfo packageInfo)
{
var versionSeperator = new char[] { '.' };
var tag = (await GitUtilities.GetAllTagsFromRemoteAsync(packageInfo.Uri)).OrderBy(value => int.Parse(value.Split(versionSeperator)[0])).ThenBy(value => int.Parse(value.Split(versionSeperator)[1])).ThenBy(value => int.Parse(value.Split(versionSeperator)[2])).LastOrDefault();
var versionSeparator = new[] { '.' };
var tag = (await GitUtilities.GetAllTagsFromRemoteAsync(packageInfo.Uri))
.OrderBy(value => int.Parse(value.Split(versionSeparator)[0])) // Major
.ThenBy(value => int.Parse(value.Split(versionSeparator)[1])) // Minor
.ThenBy(value => int.Parse(value.Split(versionSeparator)[2])) // Revision
.LastOrDefault();
var addRequest = Client.Add($"{packageInfo.Name}@{packageInfo.Uri}#{tag}");

await addRequest.WaitUntil(request => request.IsCompleted, timeout: 30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ public static void RunSync(bool forceUpdate = false)

EditorUtility.SetDirty(Settings);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}

EditorApplication.UnlockReloadAssemblies();
MixedRealityPackageUtilities.CheckPackageManifest();
Expand Down Expand Up @@ -390,7 +394,12 @@ private static bool CreateSymbolicLink(string sourceAbsolutePath, string targetA
#endif

Debug.Log($"Successfully created symbolic link to {sourceAbsolutePath}");
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ private static void DisableSymbolicLink()

EditorUtility.SetDirty(SymbolicLinker.Settings);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}
}

private void OnGUI()
Expand Down Expand Up @@ -167,7 +171,11 @@ private void OnGUI()

EditorUtility.SetDirty(SymbolicLinker.Settings);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ public static bool LockReloadAssemblies
else
{
EditorApplication.UnlockReloadAssemblies();
EditorApplication.delayCall += () => AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
EditorApplication.delayCall += () =>
{
if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}
};

if (!Application.isBatchMode)
{
Expand Down