Skip to content

Commit 7910cbe

Browse files
committed
feat(SDK): add option to exclude target build platforms
There was an issue with Unity 2017.2 where it would display a warning when trying to manage the VR settings due to the Facebook and Switch platform not being supported. The new Target Platform Group Exclusions will allow for these two platforms to be automatically excluded but also the array can be updated with additional platforms if required.
1 parent 97574c6 commit 7910cbe

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8156,6 +8156,7 @@ A helper class that simply holds references to both the SDK_ScriptingDefineSymbo
81568156
* **Auto Manage VR Settings:** Determines whether the VR settings of the Player Settings are automatically adjusted to allow for all the used SDKs in the SDK Setups list below.
81578157
* **Auto Load Setup:** Determines whether the SDK Setups list below is used whenever the SDK Manager is enabled. The first loadable Setup is then loaded.
81588158
* **Setups:** The list of SDK Setups to choose from.
8159+
* **Exclude Target Groups:** The list of Build Target Groups to exclude.
81598160

81608161
### Class Variables
81618162

Assets/VRTK/Source/Editor/VRTK_SDKManagerEditor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ public override void OnInspectorGUI()
408408
}
409409
}
410410

411+
using (new EditorGUILayout.VerticalScope("Box"))
412+
{
413+
VRTK_EditorUtilities.AddHeader("Target Platform Group Exclusions", false);
414+
SerializedProperty excludeTargetGroups = serializedObject.FindProperty("excludeTargetGroups");
415+
excludeTargetGroups.arraySize = EditorGUILayout.IntField("Size", excludeTargetGroups.arraySize);
416+
for (int i = 0; i < excludeTargetGroups.arraySize; i++)
417+
{
418+
EditorGUILayout.PropertyField(excludeTargetGroups.GetArrayElementAtIndex(i));
419+
}
420+
}
421+
411422
serializedObject.ApplyModifiedProperties();
412423
}
413424

Assets/VRTK/Source/Editor/VRTK_SDKSetupEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ private sealed class SDKSetupGameObjectsDisabler : AssetModificationProcessor
402402
[InitializeOnLoadMethod]
403403
private static void ListenToPlayModeChanges()
404404
{
405-
EditorApplication.playmodeStateChanged += () =>
405+
EditorApplication.playModeStateChanged += (PlayModeStateChange state) =>
406406
{
407407
if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
408408
{

Assets/VRTK/Source/Scripts/Utilities/SDK/VRTK_SDKManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ public static VRTK_SDKManager instance
180180
public bool autoLoadSetup = true;
181181
[Tooltip("The list of SDK Setups to choose from.")]
182182
public VRTK_SDKSetup[] setups = new VRTK_SDKSetup[0];
183+
[Tooltip("The list of Build Target Groups to exclude.")]
184+
public BuildTargetGroup[] excludeTargetGroups = new BuildTargetGroup[] { BuildTargetGroup.Switch, BuildTargetGroup.Facebook };
185+
183186
/// <summary>
184187
/// The loaded SDK Setup. `null` if no setup is currently loaded.
185188
/// </summary>
@@ -208,6 +211,7 @@ public VRTK_SDKSetup loadedSetup
208211
private Coroutine checkLeftControllerReadyRoutine = null;
209212
private Coroutine checkRightControllerReadyRoutine = null;
210213
private float checkControllerReadyDelay = 1f;
214+
private BuildTargetGroup[] targetGroupsToExclude;
211215

212216
/// <summary>
213217
/// The event invoked whenever the loaded SDK Setup changes.
@@ -357,6 +361,10 @@ public void ManageVRSettings(bool force)
357361

358362
foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
359363
{
364+
if (targetGroupsToExclude.Contains(targetGroup))
365+
{
366+
continue;
367+
}
360368
string[] deviceNames;
361369
deviceNamesByTargetGroup.TryGetValue(targetGroup, out deviceNames);
362370

@@ -944,6 +952,7 @@ private static void AutoManageScriptingDefineSymbolsAndManageVRSettings()
944952

945953
if (instance != null && !instance.ManageScriptingDefineSymbols(false, false))
946954
{
955+
instance.targetGroupsToExclude = instance.excludeTargetGroups;
947956
instance.ManageVRSettings(false);
948957
}
949958
}

0 commit comments

Comments
 (0)