From bd5bc95a66c7fc65f13849a53867d5b59250ed27 Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Fri, 27 Aug 2021 18:42:46 -0400 Subject: [PATCH 1/4] Build on all branches --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3aa3d17c..28073d6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,7 @@ name: build on: push: branches: - - main - - develop tags: - - '*' pull_request: jobs: From 0268fa3266ce8633e1a7a6389b261d7e1c59e46f Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Fri, 27 Aug 2021 18:40:17 -0400 Subject: [PATCH 2/4] Fix #119 --- Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs index ea8285c0..0d920a9f 100644 --- a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs +++ b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs @@ -29,7 +29,7 @@ internal class GameEnvironmentObjectManager : IInitializable, IDisposable { private static readonly int kReflectionProbeTexture1PropertyId = Shader.PropertyToID("_ReflectionProbeTexture1"); private static readonly int kReflectionProbeTexture2PropertyId = Shader.PropertyToID("_ReflectionProbeTexture2"); - private static readonly Cubemap kBlackCubemap = new Cubemap(0, TextureFormat.DXT1, false); + private static readonly Cubemap kBlackCubemap = new Cubemap(0, TextureFormat.DXT1Crunched, false); private readonly DiContainer _container; private readonly ILogger _logger; From 48a4f35d71dabefd6f26fabfebfe89b023926c7f Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Mon, 30 Aug 2021 22:07:16 -0400 Subject: [PATCH 3/4] Add show in smooth camera + show in mirrors toggles --- Source/CustomAvatar/Configuration/Settings.cs | 3 ++- .../HarmonyPatches/MirrorRendererSO.cs | 12 ++++++++++- .../CustomAvatarsSmoothCameraController.cs | 13 +++++++++++- Source/CustomAvatar/UI/GeneralSettingsHost.cs | 20 +++++++++++++++++++ Source/CustomAvatar/UI/Views/Settings.bsml | 16 ++++++++------- .../Zenject/CustomAvatarsInstaller.cs | 5 ++++- 6 files changed, 58 insertions(+), 11 deletions(-) diff --git a/Source/CustomAvatar/Configuration/Settings.cs b/Source/CustomAvatar/Configuration/Settings.cs index c3f25959..2566c22d 100644 --- a/Source/CustomAvatar/Configuration/Settings.cs +++ b/Source/CustomAvatar/Configuration/Settings.cs @@ -43,7 +43,8 @@ internal class Settings public bool calibrateFullBodyTrackingOnStart { get; set; } public ObservableValue enableLocomotion { get; } = new ObservableValue(true); public ObservableValue cameraNearClipPlane { get; } = new ObservableValue(0.1f); - public bool showAvatarInSmoothCamera { get; set; } = true; + public ObservableValue showAvatarInSmoothCamera { get; } = new ObservableValue(true); + public bool showAvatarInMirrors { get; set; } = true; public Lighting lighting { get; } = new Lighting(); public Mirror mirror { get; } = new Mirror(); public AutomaticFullBodyCalibration automaticCalibration { get; } = new AutomaticFullBodyCalibration(); diff --git a/Source/CustomAvatar/HarmonyPatches/MirrorRendererSO.cs b/Source/CustomAvatar/HarmonyPatches/MirrorRendererSO.cs index c6b5820a..fc529903 100644 --- a/Source/CustomAvatar/HarmonyPatches/MirrorRendererSO.cs +++ b/Source/CustomAvatar/HarmonyPatches/MirrorRendererSO.cs @@ -15,6 +15,7 @@ // along with this program. If not, see . using CustomAvatar.Avatar; +using CustomAvatar.Configuration; using HarmonyLib; using UnityEngine; @@ -23,9 +24,18 @@ namespace CustomAvatar.HarmonyPatches [HarmonyPatch(typeof(MirrorRendererSO), "CreateOrUpdateMirrorCamera")] internal static class MirrorRendererSO_CreateOrUpdateMirrorCamera { + internal static Settings settings { get; set; } + public static void Postfix(Camera ____mirrorCamera) { - ____mirrorCamera.cullingMask |= AvatarLayers.kAllLayersMask; + if (settings.showAvatarInMirrors) + { + ____mirrorCamera.cullingMask |= AvatarLayers.kAllLayersMask; + } + else + { + ____mirrorCamera.cullingMask &= ~AvatarLayers.kAllLayersMask; + } } } } diff --git a/Source/CustomAvatar/Rendering/CustomAvatarsSmoothCameraController.cs b/Source/CustomAvatar/Rendering/CustomAvatarsSmoothCameraController.cs index 36f199b4..df089b9e 100644 --- a/Source/CustomAvatar/Rendering/CustomAvatarsSmoothCameraController.cs +++ b/Source/CustomAvatar/Rendering/CustomAvatarsSmoothCameraController.cs @@ -57,6 +57,7 @@ public void Start() } _settings.cameraNearClipPlane.changed += OnCameraNearClipPlaneChanged; + _settings.showAvatarInSmoothCamera.changed += OnShowAvatarInSmoothCameraChanged; _mainSettingsModel.smoothCameraThirdPersonEnabled.didChangeEvent += OnSmoothCameraThirdPersonEnabled; UpdateSmoothCamera(); @@ -64,7 +65,12 @@ public void Start() public void OnDestroy() { - if (_settings != null) _settings.cameraNearClipPlane.changed -= OnCameraNearClipPlaneChanged; + if (_settings != null) + { + _settings.cameraNearClipPlane.changed -= OnCameraNearClipPlaneChanged; + _settings.showAvatarInSmoothCamera.changed -= OnShowAvatarInSmoothCameraChanged; + } + if (_mainSettingsModel) _mainSettingsModel.smoothCameraThirdPersonEnabled.didChangeEvent -= OnSmoothCameraThirdPersonEnabled; } @@ -73,6 +79,11 @@ private void OnCameraNearClipPlaneChanged(float value) UpdateSmoothCamera(); } + private void OnShowAvatarInSmoothCameraChanged(bool value) + { + UpdateSmoothCamera(); + } + private void OnSmoothCameraThirdPersonEnabled() { UpdateSmoothCamera(); diff --git a/Source/CustomAvatar/UI/GeneralSettingsHost.cs b/Source/CustomAvatar/UI/GeneralSettingsHost.cs index 5ac3567b..d6476737 100644 --- a/Source/CustomAvatar/UI/GeneralSettingsHost.cs +++ b/Source/CustomAvatar/UI/GeneralSettingsHost.cs @@ -57,6 +57,26 @@ public bool visibleInFirstPerson } } + public bool showAvatarInSmoothCamera + { + get => _settings.showAvatarInSmoothCamera; + set + { + _settings.showAvatarInSmoothCamera.value = value; + NotifyPropertyChanged(); + } + } + + public bool showAvatarInMirrors + { + get => _settings.showAvatarInMirrors; + set + { + _settings.showAvatarInMirrors = value; + NotifyPropertyChanged(); + } + } + public AvatarResizeMode resizeMode { get => _settings.resizeMode; diff --git a/Source/CustomAvatar/UI/Views/Settings.bsml b/Source/CustomAvatar/UI/Views/Settings.bsml index a236985e..f58ae34d 100644 --- a/Source/CustomAvatar/UI/Views/Settings.bsml +++ b/Source/CustomAvatar/UI/Views/Settings.bsml @@ -5,6 +5,8 @@ + + @@ -12,16 +14,16 @@ - - - + + + - + @@ -48,8 +50,8 @@ - - + + @@ -67,7 +69,7 @@ - + diff --git a/Source/CustomAvatar/Zenject/CustomAvatarsInstaller.cs b/Source/CustomAvatar/Zenject/CustomAvatarsInstaller.cs index 67f0e4e8..9cba0cca 100644 --- a/Source/CustomAvatar/Zenject/CustomAvatarsInstaller.cs +++ b/Source/CustomAvatar/Zenject/CustomAvatarsInstaller.cs @@ -18,6 +18,7 @@ using System.Linq; using CustomAvatar.Avatar; using CustomAvatar.Configuration; +using CustomAvatar.HarmonyPatches; using CustomAvatar.Lighting; using CustomAvatar.Logging; using CustomAvatar.Player; @@ -55,7 +56,9 @@ public override void InstallBindings() Container.Bind(typeof(ILogger<>)).FromMethodUntyped(CreateLogger).AsTransient().When(ShouldCreateLogger); // settings - Container.Bind().FromInstance(LoadSettings()); + Settings settings = LoadSettings(); + MirrorRendererSO_CreateOrUpdateMirrorCamera.settings = settings; + Container.Bind().FromInstance(settings); Container.BindInterfacesAndSelfTo().AsSingle(); if (XRSettings.loadedDeviceName.Equals("openvr", StringComparison.InvariantCultureIgnoreCase) && From 58ee8e652ac621e0c9e3a095d4f5d8b35e7259a0 Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Mon, 30 Aug 2021 22:07:24 -0400 Subject: [PATCH 4/4] Fix BSML indentation --- Source/.editorconfig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/.editorconfig b/Source/.editorconfig index 326a11ab..7fbc0e50 100644 --- a/Source/.editorconfig +++ b/Source/.editorconfig @@ -1,5 +1,11 @@ root = true +[*.bsml] +indent_size = 2 +indent_style = space +trim_trailing_whitespace = true +tab_width = 2 + [*.cs] # In general, the format for this file has the dotnet_diagnostic directive immediately preceding what it affects