Skip to content

Commit 43e43b0

Browse files
Merge pull request #116 from vrchat-community/gro-851-sync-clientsim-repo-from-latest-release
Updates ClientSim source to match Worlds SDK 3.6.0
2 parents f0bc7e1 + 50f4198 commit 43e43b0

36 files changed

+964
-121
lines changed

Packages/com.vrchat.ClientSim/Editor/ProjectSettings/ClientSimProjectSettingsSetup.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,17 @@ private static ClientSimInputAxesSettings ReadProjectInputAxes()
8686
public static bool IsUsingCorrectInputTypeSettings()
8787
{
8888
SerializedObject serializedObject = new SerializedObject(AssetDatabase.LoadAssetAtPath<Object>("ProjectSettings/ProjectSettings.asset"));
89-
SerializedProperty newInputEnabledProp = serializedObject.FindProperty("enableNativePlatformBackendsForNewInputSystem");
90-
SerializedProperty oldInputDisabledProp = serializedObject.FindProperty("disableOldInputManagerSupport");
89+
SerializedProperty activeInputHandler = serializedObject.FindProperty("activeInputHandler");
9190

92-
return
93-
newInputEnabledProp.boolValue
94-
&& !oldInputDisabledProp.boolValue;
91+
return activeInputHandler.intValue != 1;
9592
}
9693

9794
public static void SetInputTypeSettings()
9895
{
9996
SerializedObject serializedObject = new SerializedObject(AssetDatabase.LoadAssetAtPath<Object>("ProjectSettings/ProjectSettings.asset"));
100-
SerializedProperty newInputEnabledProp = serializedObject.FindProperty("enableNativePlatformBackendsForNewInputSystem");
101-
SerializedProperty oldInputDisabledProp = serializedObject.FindProperty("disableOldInputManagerSupport");
97+
SerializedProperty activeInputHandler = serializedObject.FindProperty("activeInputHandler");
10298

103-
newInputEnabledProp.boolValue = true;
104-
oldInputDisabledProp.boolValue = false;
99+
activeInputHandler.intValue = 1;
105100

106101
serializedObject.ApplyModifiedProperties();
107102
}

Packages/com.vrchat.ClientSim/Editor/Windows/ClientSimSettingsWindow.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ClientSimSettingsWindow : EditorWindow
2929
private readonly GUIContent _showDesktopReticleGuiContent = new GUIContent("Show Desktop Reticle", "Show or hide the center Desktop reticle image.");
3030
private readonly GUIContent _showTooltipsGuiContent = new GUIContent("Show Tooltips", "If enabled, hovering over an interactable object or pickup will display a tooltip above the object.");
3131
private readonly GUIContent _invertMouseLookGuiContent = new GUIContent("Invert Mouse Look", "If enabled, moving the mouse up or down will invert the direction the player will look up and down.");
32-
private readonly GUIContent _playerHeightGuiContent = new GUIContent("Player Height", "How tall should the player be in meters. Default height is 1.9. Note that the player's collision capsule is 1.6 and never changes.");
32+
private readonly GUIContent _playerHeightGuiContent = new GUIContent("Initial Player Height", "How tall should the player be in meters at app start. Default height is 1.9. Note that the player's collision capsule is 1.6 and never changes.");
3333
private readonly GUIContent _currentLanguageGuiContent = new GUIContent("Current Language", "The language the player is currently using. Available languages include English, French, German, Italian, Japanese, Korean, and Spanish.");
3434
private int selectedLanguageIndex;
3535

@@ -44,6 +44,7 @@ public class ClientSimSettingsWindow : EditorWindow
4444

4545
private static Texture2D _warningIcon;
4646
private static ClientSimSettings _settings;
47+
private static IClientSimPlayerHeightManager _heightManager;
4748

4849
private Vector2 _scrollPosition;
4950
private GUIStyle _boxStyle;
@@ -79,7 +80,7 @@ private void OnEnable()
7980
// Reuse VRChat's warning icon.
8081
_warningIcon = Resources.Load<Texture2D>("2FAIcons/SDK_Warning_Triangle_icon");
8182
}
82-
83+
8384
_version = ClientSimResourceLoader.GetVersion();
8485
}
8586

@@ -382,10 +383,9 @@ private void DrawPlayerControllerSettings()
382383
_settings.showDesktopReticle = EditorGUILayout.Toggle(_showDesktopReticleGuiContent, _settings.showDesktopReticle);
383384
_settings.showTooltips = EditorGUILayout.Toggle(_showTooltipsGuiContent, _settings.showTooltips);
384385
_settings.invertMouseLook = EditorGUILayout.Toggle(_invertMouseLookGuiContent, _settings.invertMouseLook);
385-
_settings.playerHeight = EditorGUILayout.FloatField(_playerHeightGuiContent, _settings.playerHeight);
386-
_settings.playerHeight = Mathf.Clamp(_settings.playerHeight, 0.2f, 80f); // TODO make consts for these.
387-
selectedLanguageIndex = EditorGUILayout.Popup(_currentLanguageGuiContent, selectedLanguageIndex, _settings.availableLanguages);
388-
_settings.currentLanguage = _settings.availableLanguages[selectedLanguageIndex];
386+
_settings.playerStartHeight = EditorGUILayout.FloatField(_playerHeightGuiContent, _settings.playerStartHeight);
387+
selectedLanguageIndex = EditorGUILayout.Popup(_currentLanguageGuiContent, selectedLanguageIndex, _settings.GetAvailableDisplayLanguages());
388+
_settings.currentLanguage = _settings.GetLanguage(selectedLanguageIndex);
389389

390390
EditorGUI.EndDisabledGroup();
391391

Packages/com.vrchat.ClientSim/Runtime/CameraStacking/ClientSimStackedVRCameraSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ private void DestroyCameraStack()
7272

7373
private void AddCamera(int index)
7474
{
75-
GameObject cameraObj = Instantiate(new GameObject(), _mainSceneCamera.transform);
75+
var cameraObj = new GameObject();
76+
cameraObj.transform.parent = _mainSceneCamera.transform;
7677
Camera cam = cameraObj.AddComponent<Camera>();
7778
XRDevice.DisableAutoXRCameraTracking(cam, true);
7879

Packages/com.vrchat.ClientSim/Runtime/ClientSimRuntimeLoader.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using JetBrains.Annotations;
3+
using UnityEditor;
34
using UnityEngine;
45
using UnityEngine.SceneManagement;
6+
using VRC.Core;
57

68
namespace VRC.SDK3.ClientSim
79
{
@@ -22,6 +24,13 @@ private static void OnBeforeSceneLoad()
2224
StartClientSim(GetSettings(), GetEventDispatcher());
2325
}
2426

27+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
28+
private static void OnAfterSceneLoad()
29+
{
30+
// Delete all editor only objects before creating ClientSim.
31+
DestroyEditorOnly(GetSettings());
32+
}
33+
2534
#endregion
2635

2736
#region Test Methods
@@ -70,7 +79,6 @@ private static bool IsClientSimEnabled(ClientSimSettings settings)
7079
{
7180
return
7281
settings.enableClientSim &&
73-
Object.FindObjectOfType<PipelineSaver>() == null &&
7482
Application.isPlaying;
7583
}
7684

@@ -87,14 +95,32 @@ public static void StartClientSim(
8795

8896
// Delete all editor only objects before creating ClientSim.
8997
DestroyEditorOnly(settings);
90-
91-
// Create ClientSim Instance
98+
9299
ClientSimMain.CreateInstance(settings, eventDispatcher);
100+
101+
// TODO: Below is disabled for now because the rest of the ClientSim initialization code doesn't work if it's called with a delay.
102+
// Currently, not loading RemoteConfig will not cause any issues, but it may in the future, so this is left in as a reminder.
103+
104+
// Create ClientSim Instance later
105+
/*void CreateClientSimInstance() => ClientSimMain.CreateInstance(settings, eventDispatcher);
106+
107+
// If the Remote Config is not initialized, attempt init before starting ClientSim
108+
// Start ClientSim after attempt, regardless of success or failure
109+
if (!ConfigManager.RemoteConfig.IsInitialized())
110+
{
111+
API.SetOnlineMode(true);
112+
ConfigManager.RemoteConfig.Init(CreateClientSimInstance, CreateClientSimInstance);
113+
}
114+
// Otherwise, start ClientSim immediately
115+
else
116+
{
117+
CreateClientSimInstance();
118+
}*/
93119
}
94120

95121
private static void DestroyEditorOnly(ClientSimSettings settings)
96122
{
97-
if (!settings.deleteEditorOnly)
123+
if (!settings.enableClientSim || !settings.deleteEditorOnly)
98124
{
99125
return;
100126
}

Packages/com.vrchat.ClientSim/Runtime/Events/EventTypes/ClientSimOnPlayerEvents.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class ClientSimOnPlayerExitedStationEvent : IClientSimEvent
4242
public class ClientSimOnPlayerHeightUpdateEvent : IClientSimEvent
4343
{
4444
public float playerHeight;
45+
public bool exceedsManualScalingMaximum;
46+
public bool exceedsManualScalingMinimum;
4547
}
4648

4749
public class ClientSimOnTrackingScaleUpdateEvent : IClientSimEvent
@@ -54,4 +56,9 @@ public class ClientSimOnNewMasterEvent : IClientSimEvent
5456
public VRCPlayerApi oldMasterPlayer;
5557
public VRCPlayerApi newMasterPlayer;
5658
}
59+
60+
public class ClientSimOnToggleManualScalingEvent : IClientSimEvent
61+
{
62+
public bool manualScalingAllowed;
63+
}
5764
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using VRC.SDK3.Platform;
2+
3+
namespace VRC.SDK3.ClientSim
4+
{
5+
public class ClientSimScreenUpdateEvent : IClientSimEvent
6+
{
7+
public ScreenUpdateData data;
8+
}
9+
}

Packages/com.vrchat.ClientSim/Runtime/Events/EventTypes/ClientSimPlatformEvents.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace VRC.SDK3.ClientSim
2+
{
3+
public class IClientSimPlatformHelper
4+
{
5+
6+
}
7+
}

Packages/com.vrchat.ClientSim/Runtime/Helpers/ClientSimPlatformHelper.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.vrchat.ClientSim/Runtime/Helpers/ClientSimSpatialAudioHelper.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ClientSimSpatialAudioHelper : ONSPAudioSource
1414
private bool _useAudioSourceCurve;
1515
private ONSPAudioSource _onsp;
1616
private bool _forceUpdate = true;
17+
private bool _updateONSPParams;
1718

1819
public static void InitializeAudio(VRC_SpatialAudioSource obj)
1920
{
@@ -62,6 +63,7 @@ private void OnEnable()
6263
{
6364
// ONSP needs to reapply audio settings everytime the object is enabled.
6465
_forceUpdate = true;
66+
_updateONSPParams = true;
6567
}
6668

6769
// Late update to help with testing
@@ -92,6 +94,7 @@ private void UpdateSettings()
9294
_useAudioSourceCurve != _spatialAudioSource.UseAudioSourceVolumeCurve
9395
) {
9496
_forceUpdate = true;
97+
_updateONSPParams = true;
9598
}
9699

97100
_onsp.EnableSpatialization = _spatialAudioSource.EnableSpatialization;
@@ -100,8 +103,14 @@ private void UpdateSettings()
100103
_onsp.Near = _spatialAudioSource.Near;
101104
_onsp.Far = _spatialAudioSource.Far;
102105
_onsp.VolumetricRadius = _spatialAudioSource.VolumetricRadius;
103-
104-
_onsp.SetParameters(ref _audioSource);
106+
107+
// In unity 2022 - updating ONSP params every frame can cause a logspam
108+
// This is a workaround to only update when needed
109+
if (_updateONSPParams)
110+
{
111+
_onsp.SetParameters(ref _audioSource);
112+
_updateONSPParams = false;
113+
}
105114

106115
if (!_onsp.EnableSpatialization)
107116
{

0 commit comments

Comments
 (0)