Skip to content

Commit

Permalink
ref: добавлены build conditions для разделения платформ
Browse files Browse the repository at this point in the history
  • Loading branch information
im-ikao committed Nov 12, 2023
1 parent ccec19f commit 05f8b13
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

namespace UniHowl
{
// TODO: REFACTOR
namespace UniHowl
{
#if UNITY_WEBGL && UNITY_EDITOR
public static class AudioBuildProcess
{
[PostProcessBuild(int.MinValue)]
Expand Down Expand Up @@ -75,5 +73,5 @@ private static void CreateFolder(string root, string path)
}
}
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CrossplatformAudioMap : ScriptableObject
{
[SerializeField] private List<CrossplatformAudio> _audio = new();

//#if UNITY_WEBGL
#if UNITY_WEBGL
public IAudioMap<HowlAudio> ToHowlAudioMap()
{
var map = new HowlAudioMap();
Expand All @@ -24,7 +24,7 @@ public IAudioMap<HowlAudio> ToHowlAudioMap()

return map;
}
//#endif
#endif

#if !UNITY_WEBGL || UNITY_EDITOR
public IAudioMap<UnityAudio> ToUnityAudioMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace UniHowl.Spatial.Options
{

#if UNITY_WEBGL || UNITY_EDITOR
public class HowlSpatialAudioSourceBehaviourOption : MonoBehaviour, IBehaviourSpatialAudioSourceOptions
{
[SerializeField] private HowlSpatialAudioSourceOptions _options;
Expand Down Expand Up @@ -38,7 +40,6 @@ public void Initialize()
refDistance: _refDistance,
rollOffFactor: _rolloffFactor);
}
#if UNITY_EDITOR
private void OnValidate()
{
_options.PanningMode = _panningModel;
Expand All @@ -50,10 +51,12 @@ private void OnValidate()
_options.RefDistance = _refDistance;
_options.RollOffFactor = _rolloffFactor;
}
#endif

public ISpatialAudioSourceOptions GetOptions()
{
return _options;
}
}

#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace UniHowl.Spatial.Options
{
#if !UNITY_WEBGL || UNITY_EDITOR
public class UnitySpatialAudioSourceBehaviourOption : MonoBehaviour, IBehaviourSpatialAudioSourceOptions
{
private UnitySpatialAudioSourceOptions _options;
Expand Down Expand Up @@ -75,4 +76,6 @@ public ISpatialAudioSourceOptions GetOptions()
return _options;
}
}
}

#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace UniHowl
{
#if UNITY_WEBGL && !UNITY_EDITOR
public sealed class HowlAudioPlayer : Entity<Guid>, IAudioPlayer
{
private readonly string _id;
Expand Down Expand Up @@ -37,4 +38,5 @@ public HowlAudioPlayer(Guid id, IAudioMap<HowlAudio> map, string key, float volu
public void Load() => HowlAudioProxy.Load(_id);
public Guid GetId() => Id;
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace UniHowl
{
#if !UNITY_WEBGL || UNITY_EDITOR
public class UnityAudioPlayer : Entity<Guid>, IAudioPlayer
{
private readonly AudioSource _source;
Expand Down Expand Up @@ -105,4 +106,5 @@ public void Load()

public Guid GetId() => Id;
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void AutoInitialize()
{
_spatial = _fallbackPlayer switch
{
#if UNITY_WEBGL
#if UNITY_WEBGL && !UNITY_EDITOR
AudioPlayers.Howl => new HowlSpatialPositionSource(Id, this.transform, optionsProvider.GetOptions<HowlSpatialAudioSourceOptions>(AudioPlayers.Howl)),
#endif
#if !UNITY_WEBGL || UNITY_EDITOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +35,6 @@ private void SetRotation(Vector3 rotation)

HowlSpatialAudioProxy.AudioListenerSetRotation(rotation, _coordinateSystem);
}
#endif
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace UniHowl.Spatial
{
#if UNITY_WEBGL && !UNITY_EDITOR
public class HowlSpatialPositionSource : Entity<Guid>, ISpatialAudioSource
{
private readonly string _id;
Expand Down Expand Up @@ -50,4 +51,5 @@ public void SetPosition(Vector3 position)
HowlSpatialAudioProxy.SetPosition(_id, position);
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,4 +81,5 @@ public void SetDistanceMode(HowlDistanceMode mode)
};
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -73,5 +74,6 @@ public static class HowlAudioProxy
public static extern bool HowlGetMute(string soundSourceId);

#endregion

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -123,7 +124,7 @@ public float InnerAngle

public string ToJson() => JsonUtility.ToJson(_wrapper);
}
#endif
public enum HowlDistanceMode
{
Linear,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace UniHowl.Spatial.Options
{
#if !UNITY_WEBGL || UNITY_EDITOR
public class UnitySpatialAudioSourceOptions : ISpatialAudioSourceOptions
{
/// <summary>
Expand All @@ -28,4 +29,5 @@ public class UnitySpatialAudioSourceOptions : ISpatialAudioSourceOptions
public float MinDistance = 1;
public float MaxDistance = 500;
}
#endif
}

0 comments on commit 05f8b13

Please sign in to comment.