From 05f8b1353dc097b07bd335d1f9750883ae0c3251 Mon Sep 17 00:00:00 2001 From: Aleksei Kostrykin Date: Sun, 12 Nov 2023 21:13:39 +0300 Subject: [PATCH] =?UTF-8?q?ref:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20build=20conditions=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D1=82=D1=84=D0=BE=D1=80=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UniHowl/Application/Editor/AudioBuildProcess.cs | 6 ++---- .../UniHowl/Application/Models/CrossplatformAudioMap.cs | 4 ++-- .../Options/HowlSpatialAudioSourceBehaviourOption.cs | 7 +++++-- .../Options/UnitySpatialAudioSourceBehaviourOption.cs | 5 ++++- .../UniHowl/Application/Player/HowlAudioPlayer.cs | 2 ++ .../UniHowl/Application/Player/UnityAudioPlayer.cs | 2 ++ .../UniHowl/Application/Source/CrossplatformAudioSource.cs | 2 +- .../Application/Source/CrossplatformSpatialAudioSource.cs | 2 +- .../Application/Spatial/HowlSpatialAudioListenerSource.cs | 4 ++-- .../Application/Spatial/HowlSpatialPositionSource.cs | 2 ++ .../CREEXTEAM/UniHowl/Example/Scripts/RotateAround.cs | 6 ------ .../Dto/HowlerSpatialAudioSourceOptionsWrapper.cs | 2 ++ .../CREEXTEAM/UniHowl/Infrastructure/HowlAudioProxy.cs | 4 +++- .../UniHowl/Infrastructure/HowlSpatialAudioProxy.cs | 2 ++ .../Options/HowlSpatialAudioSourceOptions.cs | 3 ++- .../Options/UnitySpatialAudioSourceOptions.cs | 2 ++ 16 files changed, 34 insertions(+), 21 deletions(-) diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Editor/AudioBuildProcess.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Editor/AudioBuildProcess.cs index 46efecc..67f878d 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Editor/AudioBuildProcess.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Editor/AudioBuildProcess.cs @@ -6,9 +6,7 @@ namespace UniHowl { -// TODO: REFACTOR - namespace UniHowl - { +#if UNITY_WEBGL && UNITY_EDITOR public static class AudioBuildProcess { [PostProcessBuild(int.MinValue)] @@ -75,5 +73,5 @@ private static void CreateFolder(string root, string path) } } } - } + #endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Models/CrossplatformAudioMap.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Models/CrossplatformAudioMap.cs index eb873f5..c7b6215 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Models/CrossplatformAudioMap.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Models/CrossplatformAudioMap.cs @@ -12,7 +12,7 @@ public class CrossplatformAudioMap : ScriptableObject { [SerializeField] private List _audio = new(); -//#if UNITY_WEBGL +#if UNITY_WEBGL public IAudioMap ToHowlAudioMap() { var map = new HowlAudioMap(); @@ -24,7 +24,7 @@ public IAudioMap ToHowlAudioMap() return map; } -//#endif +#endif #if !UNITY_WEBGL || UNITY_EDITOR public IAudioMap ToUnityAudioMap() diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/HowlSpatialAudioSourceBehaviourOption.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/HowlSpatialAudioSourceBehaviourOption.cs index 7c95ed3..6291359 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/HowlSpatialAudioSourceBehaviourOption.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/HowlSpatialAudioSourceBehaviourOption.cs @@ -6,6 +6,8 @@ namespace UniHowl.Spatial.Options { + +#if UNITY_WEBGL || UNITY_EDITOR public class HowlSpatialAudioSourceBehaviourOption : MonoBehaviour, IBehaviourSpatialAudioSourceOptions { [SerializeField] private HowlSpatialAudioSourceOptions _options; @@ -38,7 +40,6 @@ public void Initialize() refDistance: _refDistance, rollOffFactor: _rolloffFactor); } -#if UNITY_EDITOR private void OnValidate() { _options.PanningMode = _panningModel; @@ -50,10 +51,12 @@ private void OnValidate() _options.RefDistance = _refDistance; _options.RollOffFactor = _rolloffFactor; } -#endif + public ISpatialAudioSourceOptions GetOptions() { return _options; } } + +#endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/UnitySpatialAudioSourceBehaviourOption.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/UnitySpatialAudioSourceBehaviourOption.cs index 7de304b..4077c58 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/UnitySpatialAudioSourceBehaviourOption.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Options/UnitySpatialAudioSourceBehaviourOption.cs @@ -6,6 +6,7 @@ namespace UniHowl.Spatial.Options { +#if !UNITY_WEBGL || UNITY_EDITOR public class UnitySpatialAudioSourceBehaviourOption : MonoBehaviour, IBehaviourSpatialAudioSourceOptions { private UnitySpatialAudioSourceOptions _options; @@ -75,4 +76,6 @@ public ISpatialAudioSourceOptions GetOptions() return _options; } } -} \ No newline at end of file + +#endif +} diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/HowlAudioPlayer.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/HowlAudioPlayer.cs index 8f095f0..27a6ce6 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/HowlAudioPlayer.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/HowlAudioPlayer.cs @@ -3,6 +3,7 @@ namespace UniHowl { + #if UNITY_WEBGL && !UNITY_EDITOR public sealed class HowlAudioPlayer : Entity, IAudioPlayer { private readonly string _id; @@ -37,4 +38,5 @@ public HowlAudioPlayer(Guid id, IAudioMap map, string key, float volu public void Load() => HowlAudioProxy.Load(_id); public Guid GetId() => Id; } + #endif } diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/UnityAudioPlayer.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/UnityAudioPlayer.cs index 30be7ac..0a1afd8 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/UnityAudioPlayer.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Player/UnityAudioPlayer.cs @@ -4,6 +4,7 @@ namespace UniHowl { +#if !UNITY_WEBGL || UNITY_EDITOR public class UnityAudioPlayer : Entity, IAudioPlayer { private readonly AudioSource _source; @@ -105,4 +106,5 @@ public void Load() public Guid GetId() => Id; } +#endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformAudioSource.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformAudioSource.cs index 2a91765..cacda2f 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformAudioSource.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformAudioSource.cs @@ -115,7 +115,7 @@ public void Init(AudioConfiguration configuration) _player = _fallbackPlayer switch { -#if UNITY_WEBGL +#if UNITY_WEBGL && !UNITY_EDITOR AudioPlayers.Howl => new HowlAudioPlayer(Id, configuration.Audio.ToHowlAudioMap(), _soundKey, _volume, diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformSpatialAudioSource.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformSpatialAudioSource.cs index 674f0e1..d0c7038 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformSpatialAudioSource.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Source/CrossplatformSpatialAudioSource.cs @@ -44,7 +44,7 @@ public void Init(AudioConfiguration configuration, { _spatial = _fallbackPlayer switch { -#if UNITY_WEBGL +#if UNITY_WEBGL && !UNITY_EDITOR AudioPlayers.Howl => new HowlSpatialPositionSource(Id, this.transform, optionsProvider.GetOptions(AudioPlayers.Howl)), #endif #if !UNITY_WEBGL || UNITY_EDITOR diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialAudioListenerSource.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialAudioListenerSource.cs index 90dbd3b..a0bdbeb 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialAudioListenerSource.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialAudioListenerSource.cs @@ -3,9 +3,9 @@ namespace UniHowl.Spatial { +#if UNITY_WEBGL && !UNITY_EDITOR public class HowlSpatialAudioListenerSource : MonoBehaviour { -#if UNITY_WEBGL && !UNITY_EDITOR private static readonly Vector3 _coordinateSystem = Vector3.up; private Vector3 _latestPosition; private Vector3 _latestRotation; @@ -35,6 +35,6 @@ private void SetRotation(Vector3 rotation) HowlSpatialAudioProxy.AudioListenerSetRotation(rotation, _coordinateSystem); } -#endif } +#endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialPositionSource.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialPositionSource.cs index f88e243..41bb114 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialPositionSource.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Application/Spatial/HowlSpatialPositionSource.cs @@ -6,6 +6,7 @@ namespace UniHowl.Spatial { +#if UNITY_WEBGL && !UNITY_EDITOR public class HowlSpatialPositionSource : Entity, ISpatialAudioSource { private readonly string _id; @@ -50,4 +51,5 @@ public void SetPosition(Vector3 position) HowlSpatialAudioProxy.SetPosition(_id, position); } } +#endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Example/Scripts/RotateAround.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Example/Scripts/RotateAround.cs index 35104a2..b226d9a 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Example/Scripts/RotateAround.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Example/Scripts/RotateAround.cs @@ -1,9 +1,3 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -using System.Collections; -using System.Collections.Generic; using UnityEngine; public enum RotateAroundDirection diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Dto/HowlerSpatialAudioSourceOptionsWrapper.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Dto/HowlerSpatialAudioSourceOptionsWrapper.cs index 9735449..dcecdb3 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Dto/HowlerSpatialAudioSourceOptionsWrapper.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Dto/HowlerSpatialAudioSourceOptionsWrapper.cs @@ -3,6 +3,7 @@ namespace Plugins.CREEXTEAM.UniHowl.Infrastructure.Dto { +#if UNITY_WEBGL || UNITY_EDITOR // Why this strange object? // I wouldn’t want to drag along a custom serializer, and in order not to constantly create garbage, // we created such a wrapper to json object @@ -80,4 +81,5 @@ public void SetDistanceMode(HowlDistanceMode mode) }; } } + #endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlAudioProxy.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlAudioProxy.cs index 7d07353..b06ebc4 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlAudioProxy.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlAudioProxy.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; using UnityEngine; +#if UNITY_WEBGL && !UNITY_EDITOR public static class HowlAudioProxy { public static void SetGlobalMute(bool state) => HowlGlobalMute(state); @@ -73,5 +74,6 @@ public static class HowlAudioProxy public static extern bool HowlGetMute(string soundSourceId); #endregion - } + +#endif diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlSpatialAudioProxy.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlSpatialAudioProxy.cs index 05e71ab..4ec49fd 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlSpatialAudioProxy.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/HowlSpatialAudioProxy.cs @@ -5,6 +5,7 @@ namespace Plugins.CREEXTEAM.UniHowl.Infrastructure { +#if UNITY_WEBGL && !UNITY_EDITOR public static class HowlSpatialAudioProxy { public static void SetPan(string sourceId, HowlSpatialAudioSourceOptions options) @@ -40,4 +41,5 @@ public static void AudioListenerSetRotation(Vector3 rotation, Vector3 coordinate public static extern bool HowlAudioListenerSetRotation(float x, float y, float z, float xUp, float yUp, float zUp); } + #endif } \ No newline at end of file diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/HowlSpatialAudioSourceOptions.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/HowlSpatialAudioSourceOptions.cs index a8db329..e3fbc78 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/HowlSpatialAudioSourceOptions.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/HowlSpatialAudioSourceOptions.cs @@ -5,6 +5,7 @@ namespace UniHowl.Spatial.Options { +#if UNITY_WEBGL || UNITY_EDITOR // Why is not inherited from some universal class? // Because in cross-platform games we can sacrifice some features for the sake of performance or platform support [Serializable] @@ -123,7 +124,7 @@ public float InnerAngle public string ToJson() => JsonUtility.ToJson(_wrapper); } - +#endif public enum HowlDistanceMode { Linear, diff --git a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/UnitySpatialAudioSourceOptions.cs b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/UnitySpatialAudioSourceOptions.cs index df72ab3..984701d 100644 --- a/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/UnitySpatialAudioSourceOptions.cs +++ b/Assets/Plugins/CREEXTEAM/UniHowl/Infrastructure/Options/UnitySpatialAudioSourceOptions.cs @@ -4,6 +4,7 @@ namespace UniHowl.Spatial.Options { +#if !UNITY_WEBGL || UNITY_EDITOR public class UnitySpatialAudioSourceOptions : ISpatialAudioSourceOptions { /// @@ -28,4 +29,5 @@ public class UnitySpatialAudioSourceOptions : ISpatialAudioSourceOptions public float MinDistance = 1; public float MaxDistance = 500; } +#endif } \ No newline at end of file