Skip to content

Commit 3273593

Browse files
author
lawwong
committed
Handle version check www error, add recommend build target, disable Simulator by default
1 parent 50af6c0 commit 3273593

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VIUVersionCheck.cs

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ private static void InitializeSettins()
159159
// recommendedValue = true,
160160
//});
161161

162+
s_settings.Add(new RecommendedSetting<BuildTarget>()
163+
{
164+
settingTitle = "Build Target",
165+
skipCheckFunc = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Standalone || VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Android,
166+
currentValueFunc = () => EditorUserBuildSettings.activeBuildTarget,
167+
setValueFunc = v =>
168+
{
169+
#if UNITY_2017_1_OR_NEWER
170+
EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
171+
#elif UNITY_5_6_OR_NEWER
172+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
173+
#else
174+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows64);
175+
#endif
176+
},
177+
recommendedValue = BuildTarget.StandaloneWindows64,
178+
});
179+
162180
s_settings.Add(new RecommendedSetting<bool>()
163181
{
164182
settingTitle = "Load Binding Config on Start",
@@ -384,11 +402,11 @@ private static void CheckVersionAndSettings()
384402
return;
385403
}
386404

405+
// On Windows, PlaterSetting is stored at \HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x
406+
EditorPrefs.SetString(nextVersionCheckTimeKey, UtcDateTimeToStr(DateTime.UtcNow.AddMinutes(versionCheckIntervalMinutes)));
407+
387408
if (UrlSuccess(www))
388409
{
389-
// On Windows, PlaterSetting is stored at \HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x
390-
EditorPrefs.SetString(nextVersionCheckTimeKey, UtcDateTimeToStr(DateTime.UtcNow.AddMinutes(versionCheckIntervalMinutes)));
391-
392410
latestRepoInfo = JsonUtility.FromJson<RepoInfo>(www.text);
393411
}
394412

@@ -468,35 +486,46 @@ private static string UtcDateTimeToStr(DateTime utcDateTime)
468486

469487
private static bool UrlSuccess(WWW www)
470488
{
471-
if (!string.IsNullOrEmpty(www.error))
489+
try
472490
{
473-
// API rate limit exceeded, see https://developer.github.com/v3/#rate-limiting
474-
Debug.Log("url:" + www.url);
475-
Debug.Log("error:" + www.error);
476-
Debug.Log(www.text);
477-
478-
string responseHeader;
479-
if (www.responseHeaders.TryGetValue("X-RateLimit-Limit", out responseHeader))
491+
if (!string.IsNullOrEmpty(www.error))
480492
{
481-
Debug.Log("X-RateLimit-Limit:" + responseHeader);
482-
}
483-
if (www.responseHeaders.TryGetValue("X-RateLimit-Remaining", out responseHeader))
484-
{
485-
Debug.Log("X-RateLimit-Remaining:" + responseHeader);
493+
// API rate limit exceeded, see https://developer.github.com/v3/#rate-limiting
494+
Debug.Log("url:" + www.url);
495+
Debug.Log("error:" + www.error);
496+
Debug.Log(www.text);
497+
498+
if (www.responseHeaders != null)
499+
{
500+
string responseHeader;
501+
if (www.responseHeaders.TryGetValue("X-RateLimit-Limit", out responseHeader))
502+
{
503+
Debug.Log("X-RateLimit-Limit:" + responseHeader);
504+
}
505+
if (www.responseHeaders.TryGetValue("X-RateLimit-Remaining", out responseHeader))
506+
{
507+
Debug.Log("X-RateLimit-Remaining:" + responseHeader);
508+
}
509+
if (www.responseHeaders.TryGetValue("X-RateLimit-Reset", out responseHeader))
510+
{
511+
Debug.Log("X-RateLimit-Reset:" + TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(double.Parse(responseHeader))).ToString());
512+
}
513+
}
514+
515+
return false;
486516
}
487-
if (www.responseHeaders.TryGetValue("X-RateLimit-Reset", out responseHeader))
517+
518+
if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase))
488519
{
489-
Debug.Log("X-RateLimit-Reset:" + TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(double.Parse(responseHeader))).ToString());
520+
Debug.Log("url:" + www.url);
521+
Debug.Log("error:" + www.error);
522+
Debug.Log(www.text);
523+
return false;
490524
}
491-
492-
return false;
493525
}
494-
495-
if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase))
526+
catch (Exception e)
496527
{
497-
Debug.Log("url:" + www.url);
498-
Debug.Log("error:" + www.error);
499-
Debug.Log(www.text);
528+
Debug.LogWarning(e);
500529
return false;
501530
}
502531

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/VIUSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class VIUSettings : ScriptableObject
2727
public const KeyCode EXTERNAL_CAMERA_SWITCH_KEY_DEFAULT_VALUE = KeyCode.M;
2828
public const KeyCode EXTERNAL_CAMERA_SWITCH_KEY_MODIFIER_DEFAULT_VALUE = KeyCode.RightShift;
2929

30-
public const bool ACTIVATE_SIMULATOR_MODULE_DEFAULT_VALUE = true;
30+
public const bool ACTIVATE_SIMULATOR_MODULE_DEFAULT_VALUE = false;
3131
public const bool SIMULATOR_AUTO_TRACK_MAIN_CAMERA_DEFAULT_VALUE = true;
3232
public const bool ENABLE_SIMULATOR_KEYBOARD_MOUSE_CONTROL_DEFAULT_VALUE = true;
3333
public const bool SIMULATE_TRACKPAD_TOUCH_DEFAULT_VALUE = true;

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/VIUVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace HTC.UnityPlugin.Vive
66
{
77
public static class VIUVersion
88
{
9-
public static readonly Version current = new Version("1.8.0.1");
9+
public static readonly Version current = new Version("1.8.0.2");
1010
}
1111
}

0 commit comments

Comments
 (0)