Skip to content

Commit ea2d0c9

Browse files
Pushed the new Odin Unity SDK 2.0 preview version
- Contains the Core SDK Version 2.0.0-beta-crypto2 - Now supports WebGL Platform - Contains specific WebGL Sample Scene
1 parent 4a47bb9 commit ea2d0c9

File tree

340 files changed

+36947
-14333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+36947
-14333
lines changed

Documentation/Documentation.pdf

-1.16 MB
Binary file not shown.

Documentation/Getting-Started.pdf

-2.65 MB
Binary file not shown.

Documentation/online.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
3+
<body>
4+
<script type="text/javascript"> window.location.href = "https://developers.4players.io/odin/"; </script>
5+
</body>
6+
7+
</html>

Documentation/Getting-Started.pdf.meta renamed to Documentation/online.html.meta

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

Documentation/webgl-sample.webp

179 KB
Binary file not shown.

Editor/MicrophoneReaderEditor.cs

Lines changed: 0 additions & 119 deletions
This file was deleted.

Editor/OdinAssetContext.cs

Lines changed: 70 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#if UNITY_EDITOR
22
using OdinNative.Unity;
33
using OdinNative.Unity.Audio;
4-
using System.Collections;
5-
using System.Collections.Generic;
64
using System.Linq;
75
using UnityEditor;
86
using UnityEngine;
@@ -11,66 +9,93 @@
119
public class OdinAssetContext : Editor
1210
{
1311
internal const string MenuTag = "Assets/Create/4Players ODIN";
14-
private static GameObject NewOdinManager(string guid = "a421abe223e2dee45b89e686a84e5545")
12+
internal const string MenuEditorTag = MenuTag + "/OdinEditor Helper";
13+
internal const string ContextTag = "Audio/4Players ODIN";
14+
private static GameObject NewOdinInstance(string guid = "f7d24aee5ad24a646a7b72d963a24b6a")
1515
{
1616
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
17-
if (!assetPath.EndsWith("OdinManager.prefab"))
17+
if (!assetPath.EndsWith("OdinInstance.prefab"))
1818
{
19-
Debug.LogError($"No OdinManager prefab! {assetPath}");
19+
Debug.LogError($"No OdinRoom prefab! {assetPath}");
2020
return null;
2121
}
2222

2323
Object asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject));
2424
return PrefabUtility.InstantiatePrefab(asset) as GameObject;
2525
}
2626

27-
[MenuItem(MenuTag + "/OdinManager/Prefab/Default")]
27+
[MenuItem(MenuEditorTag + "/Prefabs/Room")]
2828
public static GameObject CreateDefault()
2929
{
30-
GameObject odin = NewOdinManager();
30+
GameObject odin = NewOdinInstance();
3131
if(odin == null) return null;
3232

33-
OdinEditorConfig config = odin.GetComponent<OdinEditorConfig>();
34-
if(config != null) config.DeviceSampleRate = OdinNative.Core.MediaSampleRate.Hz48000;
35-
3633
return odin;
3734
}
3835

39-
[MenuItem(MenuTag + "/OdinManager/Prefab/Advanced")]
36+
[ContextMenu("OdinRoom")]
37+
public OdinRoom CreateRoom()
38+
{
39+
GameObject selected = Selection.activeGameObject;
40+
if (selected == null)
41+
{
42+
Debug.LogError($"Selection must be a gameobject!");
43+
return null;
44+
}
45+
return selected.AddComponent<OdinRoom>();
46+
}
47+
48+
[MenuItem(MenuEditorTag + "/Template/Advanced (Room, Mic, MixerGroup)")]
4049
public static GameObject CreateAdvanced()
4150
{
51+
Debug.Log($"Create Prefab...");
4252
GameObject odin = CreateDefault();
4353
if (odin == null) return null;
4454

45-
OdinHandler handler = odin.GetComponent<OdinHandler>();
55+
OdinRoom handler = odin.GetComponent<OdinRoom>();
4656
if (handler != null)
4757
{
48-
handler.Use3DAudio = true;
49-
handler.CreatePlayback = false;
50-
5158
Object obj = Selection.activeObject;
59+
Debug.Log("Set playback mixer settings...");
5260
if (obj is AudioMixer)
5361
{
5462
AudioMixer mixer = obj as AudioMixer;
55-
handler.PlaybackAudioMixer = mixer;
63+
Debug.Log("Looking for \"Odin\"-group...");
5664
var groups = mixer.FindMatchingGroups("Odin");
57-
if (groups.Length <= 0) groups = mixer.FindMatchingGroups("Master");
58-
handler.PlaybackAudioMixerGroup = groups.FirstOrDefault();
65+
if (groups.Length <= 0)
66+
{
67+
Debug.Log("Looking for \"Master\"-group...");
68+
groups = mixer.FindMatchingGroups("Master");
69+
}
70+
handler.AudioMixerGroup = groups.FirstOrDefault();
5971
}
6072
else if (obj is AudioMixerGroup)
6173
{
6274
AudioMixerGroup group = obj as AudioMixerGroup;
63-
handler.PlaybackAudioMixer = group.audioMixer;
64-
handler.PlaybackAudioMixerGroup = group;
75+
Debug.Log($"Set \"{group.name}\"-group...");
76+
handler.AudioMixerGroup = group;
6577
}
6678
else
6779
Debug.LogWarning("Selection has to be an AudioMixer or AudioMixerGroup! Skip playback mixer settings.");
80+
81+
var mic = odin.AddComponent<OdinMicrophoneReader>();
82+
if (mic.OnAudioData == null) mic.OnAudioData = new OdinNative.Unity.Events.UnityAudioData();
83+
if (mic.OnAudioData.GetPersistentEventCount() <= 0)
84+
{
85+
#if UNITY_EDITOR
86+
UnityEditor.Events.UnityEventTools.AddPersistentListener(mic.OnAudioData, handler.ProxyAudio);
87+
#else
88+
mic.OnAudioData.AddListener(handler.ProxyAudio);
89+
#endif
90+
}
91+
else
92+
Debug.LogWarning("Persistent event is already set! Skip microphone reader listener.");
6893
}
6994

7095
return odin;
7196
}
7297

73-
[MenuItem(MenuTag + "/OdinManager/Components/Basic")]
98+
[MenuItem(MenuEditorTag + "/Components/Basic (OdinRoom)")]
7499
public static GameObject CreateComponents()
75100
{
76101
GameObject obj = Selection.activeGameObject;
@@ -80,77 +105,56 @@ public static GameObject CreateComponents()
80105
return null;
81106
}
82107

83-
#if UNITY_6000_0_OR_NEWER
84-
OdinEditorConfig config = FindFirstObjectByType<OdinEditorConfig>();
85-
#else
86-
OdinEditorConfig[] configs = FindObjectsOfType<OdinEditorConfig>();
87-
OdinEditorConfig config = configs.Length <= 0 ? obj.AddComponent<OdinEditorConfig>() : configs[0];
88-
#endif
89-
if (config != null) config.DeviceSampleRate = OdinNative.Core.MediaSampleRate.Hz48000;
90-
91-
OdinHandler handler = obj.GetComponent<OdinHandler>();
92-
if(handler == null) handler = obj.AddComponent<OdinHandler>();
93-
if (handler != null)
94-
{
95-
handler.Use3DAudio = true;
96-
handler.CreatePlayback = false;
97-
}
108+
OdinRoom[] rooms = FindObjectsOfType<OdinRoom>();
109+
OdinRoom room = rooms.Length <= 0 ? obj.AddComponent<OdinRoom>() : rooms[0];
98110

99111
return obj;
100112
}
101113

102-
[MenuItem(MenuTag + "/OdinManager/Components/Extended")]
114+
[MenuItem(MenuEditorTag + "/Components/Extended (Room, Microphone)")]
103115
public static GameObject CreateFullComponents()
104116
{
105117
GameObject obj = CreateComponents();
106118

107-
OdinHandler handler = obj.GetComponent<OdinHandler>();
108-
109-
#if UNITY_6000_0_OR_NEWER
110-
MicrophoneReader[] micReaders = FindObjectsByType<MicrophoneReader>(FindObjectsSortMode.None);
111-
#else
112-
MicrophoneReader[] micReaders = FindObjectsOfType<MicrophoneReader>();
113-
#endif
114-
if (handler != null) handler.Microphone = micReaders.Length <= 0 ? obj.AddComponent<MicrophoneReader>() : micReaders[0];
119+
OdinRoom handler = obj.GetComponent<OdinRoom>();
120+
OdinMicrophoneReader[] micReaders = FindObjectsOfType<OdinMicrophoneReader>();
121+
if (handler != null)
122+
{
123+
var mic = micReaders.Length <= 0 ? obj.AddComponent<OdinMicrophoneReader>() : micReaders[0];
124+
if (mic.OnAudioData == null) mic.OnAudioData = new OdinNative.Unity.Events.UnityAudioData();
125+
if (mic.OnAudioData.GetPersistentEventCount() > 0)
126+
{
127+
Debug.LogWarning("Skip listener! Persistent event is already set.");
128+
return obj;
129+
}
130+
131+
#if UNITY_EDITOR
132+
UnityEditor.Events.UnityEventTools.AddPersistentListener(mic.OnAudioData, handler.ProxyAudio);
133+
#else
134+
mic.OnAudioData.AddListener(handler.ProxyAudio);
135+
#endif
136+
}
115137

116138
return obj;
117139
}
118140

119-
[MenuItem(MenuTag + "/OdinManager/Link AudioMixerGroup")]
141+
[MenuItem(MenuTag + "/Link AudioMixerGroup to OdinRoom")]
120142
public static void LinkAudioMixerGroup()
121143
{
122144
Object obj = Selection.activeObject;
123-
#if UNITY_6000_0_OR_NEWER
124-
foreach (OdinHandler handler in FindObjectsByType<OdinHandler>(FindObjectsSortMode.None))
125-
{
126-
if (obj is AudioMixerGroup)
127-
{
128-
AudioMixerGroup group = obj as AudioMixerGroup;
129-
handler.PlaybackAudioMixer = group.audioMixer;
130-
handler.PlaybackAudioMixerGroup = group;
131-
}
132-
else
133-
{
134-
Debug.LogWarning("Selection has to be an AudioMixerGroup!");
135-
break;
136-
}
137-
}
138-
#else
139-
foreach (OdinHandler handler in FindObjectsOfType<OdinHandler>())
145+
foreach (OdinRoom handler in FindObjectsOfType<OdinRoom>())
140146
{
141147
if (obj is AudioMixerGroup)
142148
{
143149
AudioMixerGroup group = obj as AudioMixerGroup;
144-
handler.PlaybackAudioMixer = group.audioMixer;
145-
handler.PlaybackAudioMixerGroup = group;
150+
handler.AudioMixerGroup = group;
146151
}
147152
else
148153
{
149154
Debug.LogWarning("Selection has to be an AudioMixerGroup!");
150155
break;
151156
}
152157
}
153-
#endif
154158
}
155159
}
156160
#endif

Editor/OdinBannerEditor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if UNITY_EDITOR
2-
using System;
32
using UnityEditor;
43
using UnityEngine;
54

0 commit comments

Comments
 (0)