Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ProjectSettingsWindow to not lose settings on BuildTarget update #2427

Merged
merged 1 commit into from
Jul 11, 2018
Merged
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 @@ -63,6 +63,8 @@ public class ProjectSettingsWindow : AutoConfigureWindow<ProjectSettingsWindow.P
/// </summary>
private readonly InputManagerAxis[] obsoleteInputAxes = { };

private bool updateToolkitAxes;

#region Nested Types

public enum ProjectSetting
Expand Down Expand Up @@ -115,6 +117,8 @@ private class InputManagerAxis

protected override void ApplySettings()
{
SaveMenuSettings();

// Apply individual settings
if (Values[ProjectSetting.BuildWsaUwp])
{
Expand Down Expand Up @@ -148,7 +152,7 @@ protected override void LoadSettings()
case ProjectSetting.WsaUwpBuildToD3D:
case ProjectSetting.DotNetScriptingBackend:
case ProjectSetting.SetDefaultSpatialMappingLayer:
Values[(ProjectSetting)i] = true;
Values[(ProjectSetting)i] = EditorPrefsUtility.GetEditorPref(Names[(ProjectSetting)i], true);
break;
case ProjectSetting.TargetOccludedDevices:
Values[(ProjectSetting)i] = EditorPrefsUtility.GetEditorPref(Names[(ProjectSetting)i], false);
Expand All @@ -163,12 +167,10 @@ protected override void LoadSettings()
throw new ArgumentOutOfRangeException();
}
}

}

private void UpdateSettings(BuildTarget currentBuildTarget)
{
EditorPrefsUtility.SetEditorPref(Names[ProjectSetting.SharingServices], Values[ProjectSetting.SharingServices]);
if (Values[ProjectSetting.SharingServices])
{
string sharingServiceDirectory = Directory.GetParent(Path.GetFullPath(Application.dataPath)).FullName + "\\External\\HoloToolkit\\Sharing\\Server";
Expand Down Expand Up @@ -230,11 +232,9 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.PrivateNetworkClientServer, false);
}

bool useToolkitAxes = Values[ProjectSetting.UseInputManagerAxes];

if (useToolkitAxes != EditorPrefsUtility.GetEditorPref(Names[ProjectSetting.UseInputManagerAxes], false))
if (updateToolkitAxes)
{
EditorPrefsUtility.SetEditorPref(Names[ProjectSetting.UseInputManagerAxes], useToolkitAxes);
bool useToolkitAxes = Values[ProjectSetting.UseInputManagerAxes];

// Grabs the actual asset file into a SerializedObject, so we can iterate through it and edit it.
inputManagerAsset = new SerializedObject(AssetDatabase.LoadAssetAtPath("ProjectSettings/InputManager.asset", typeof(UnityEngine.Object)));
Expand Down Expand Up @@ -349,8 +349,6 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
}
}

EditorPrefsUtility.SetEditorPref(Names[ProjectSetting.TargetOccludedDevices], Values[ProjectSetting.TargetOccludedDevices]);

PlayerSettings.SetScriptingBackend(BuildTargetGroup.WSA,
Values[ProjectSetting.DotNetScriptingBackend]
? ScriptingImplementation.WinRTDotNET
Expand Down Expand Up @@ -579,7 +577,7 @@ private void RefreshLocalAxesList()
private bool SetSpatialMappingLayer()
{
UnityEngine.Object[] tagAssets = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
if ((tagAssets == null) ||
if ((tagAssets == null) ||
(tagAssets.Length == 0))
{
return false;
Expand Down Expand Up @@ -613,5 +611,18 @@ private bool SetSpatialMappingLayer()
spatialMappingLayer.stringValue = SpatialMappingLayerName;
return tagsManager.ApplyModifiedProperties();
}

/// <summary>
/// Saves the selected items into EditorPrefs.
/// </summary>
private void SaveMenuSettings()
{
updateToolkitAxes = Values[ProjectSetting.UseInputManagerAxes] != EditorPrefsUtility.GetEditorPref(Names[ProjectSetting.UseInputManagerAxes], false);

for (int i = (int)ProjectSetting.BuildWsaUwp; i <= (int)ProjectSetting.SetDefaultSpatialMappingLayer; i++)
{
EditorPrefsUtility.SetEditorPref(Names[(ProjectSetting)i], Values[(ProjectSetting)i]);
}
}
}
}