4.5.3
This commit is contained in:
8
Scripts/Editor.meta
Executable file
8
Scripts/Editor.meta
Executable file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5daecada1ea129e47a5e0decc073a3af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
105
Scripts/Editor/Build.cs
Executable file
105
Scripts/Editor/Build.cs
Executable file
@ -0,0 +1,105 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine; // deleteme?
|
||||
using UnityEditor;
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
using UnityEditor.Build;
|
||||
#endif
|
||||
using UnityEditor.Callbacks;
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public static class Build
|
||||
{
|
||||
public static void BuildSteamAudio()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
var lastArg = args[args.Length - 1];
|
||||
|
||||
var fileName = "SteamAudio.unitypackage";
|
||||
if (lastArg != "SteamAudio.Build.BuildSteamAudio")
|
||||
{
|
||||
fileName = lastArg + "/" + fileName;
|
||||
}
|
||||
|
||||
var assets = new string[] { "Assets/Plugins" };
|
||||
|
||||
AssetDatabase.ExportPackage(assets, fileName, ExportPackageOptions.Recurse);
|
||||
}
|
||||
}
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class Defines
|
||||
{
|
||||
// Define the constant STEAMAUDIO_ENABLED for all platforms that are supported by
|
||||
// Steam Audio. User scripts should check if this constant is defined
|
||||
// (using #if STEAMAUDIO_ENABLED) before using any of the Steam Audio C# classes.
|
||||
static Defines()
|
||||
{
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
NamedBuildTarget[] supportedPlatforms = {
|
||||
NamedBuildTarget.Standalone,
|
||||
NamedBuildTarget.Android,
|
||||
NamedBuildTarget.iOS,
|
||||
};
|
||||
|
||||
foreach (var supportedPlatform in supportedPlatforms)
|
||||
{
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbols(supportedPlatform);
|
||||
if (!defines.Contains("STEAMAUDIO_ENABLED"))
|
||||
{
|
||||
if (defines.Length > 0)
|
||||
{
|
||||
defines += ";";
|
||||
}
|
||||
|
||||
defines += "STEAMAUDIO_ENABLED";
|
||||
|
||||
PlayerSettings.SetScriptingDefineSymbols(supportedPlatform, defines);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static class BuildProcessor
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath)
|
||||
{
|
||||
if (buildTarget == BuildTarget.iOS)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
var projectPath = PBXProject.GetPBXProjectPath(buildPath);
|
||||
|
||||
var project = new PBXProject();
|
||||
project.ReadFromFile(projectPath);
|
||||
|
||||
var file = project.AddFile("usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk);
|
||||
var target = project.TargetGuidByName("UnityFramework");
|
||||
project.AddFileToBuild(target, file);
|
||||
|
||||
project.WriteToFile(projectPath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/Build.cs.meta
Executable file
11
Scripts/Editor/Build.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cf552bb6c6d7894c8e64136a5d4a41c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Scripts/Editor/SOFAFileEditor.cs
Executable file
33
Scripts/Editor/SOFAFileEditor.cs
Executable file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
/*
|
||||
* Custom editor GUI for SOFAFile assets.
|
||||
*/
|
||||
[CustomEditor(typeof(SOFAFile))]
|
||||
public class SOFAFileEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sofaName"));
|
||||
EditorGUILayout.LabelField("Size", Common.HumanReadableDataSize(serializedObject.FindProperty("data").arraySize));
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SOFAFileEditor.cs.meta
Executable file
11
Scripts/Editor/SOFAFileEditor.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad7854f3d94e96f4795542d446b68921
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Scripts/Editor/SOFAFileImporter.cs
Executable file
50
Scripts/Editor/SOFAFileImporter.cs
Executable file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
using UnityEditor.Experimental.AssetImporters;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
/*
|
||||
* Imports .sofa files as SOFAFile asset objects.
|
||||
*/
|
||||
[ScriptedImporter(2, "sofa")]
|
||||
public class SOFAFileImporter : ScriptedImporter
|
||||
{
|
||||
[Range(-12.0f, 12.0f)]
|
||||
public float hrtfVolumeGainDB = 0.0f;
|
||||
public HRTFNormType hrtfNormalizationType = HRTFNormType.None;
|
||||
|
||||
public override void OnImportAsset(AssetImportContext ctx)
|
||||
{
|
||||
var sofaFile = ScriptableObject.CreateInstance<SOFAFile>();
|
||||
|
||||
sofaFile.sofaName = Path.GetFileName(ctx.assetPath);
|
||||
sofaFile.data = File.ReadAllBytes(ctx.assetPath);
|
||||
sofaFile.volume = hrtfVolumeGainDB;
|
||||
sofaFile.normType = hrtfNormalizationType;
|
||||
|
||||
ctx.AddObjectToAsset("sofa file", sofaFile);
|
||||
ctx.SetMainObject(sofaFile);
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SOFAFileImporter.cs.meta
Executable file
11
Scripts/Editor/SOFAFileImporter.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1731f5ddf70efee4c8320ac591373b56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Scripts/Editor/SOFAFileImporterEditor.cs
Executable file
41
Scripts/Editor/SOFAFileImporterEditor.cs
Executable file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
using UnityEditor.Experimental.AssetImporters;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
/*
|
||||
* Custom editor GUI for SOFAFile import settings.
|
||||
*/
|
||||
[CustomEditor(typeof(SOFAFileImporter))]
|
||||
public class SOFAFileImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("hrtfVolumeGainDB"), new UnityEngine.GUIContent("HRTF Volume Gain (dB)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("hrtfNormalizationType"), new UnityEngine.GUIContent("HRTF Normalization Type"));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
ApplyRevertGUI();
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SOFAFileImporterEditor.cs.meta
Executable file
11
Scripts/Editor/SOFAFileImporterEditor.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3653cc84febdd64e8064c9e17883043
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Scripts/Editor/SerializedDataInspector.cs
Executable file
41
Scripts/Editor/SerializedDataInspector.cs
Executable file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SerializedData))]
|
||||
public class SerializedDataInspector : Editor
|
||||
{
|
||||
SerializedProperty mData;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mData = serializedObject.FindProperty("data");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var size = mData.arraySize;
|
||||
EditorGUILayout.LabelField("Serialized Data", Common.HumanReadableDataSize(size));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SerializedDataInspector.cs.meta
Executable file
11
Scripts/Editor/SerializedDataInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9184af0375b7f6140be4f789b5fc7083
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Scripts/Editor/SteamAudioAmbisonicSourceInspector.cs
Executable file
50
Scripts/Editor/SteamAudioAmbisonicSourceInspector.cs
Executable file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioAmbisonicSource))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SteamAudioAmbisonicSourceInspector : Editor
|
||||
{
|
||||
SerializedProperty mApplyHRTF;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mApplyHRTF = serializedObject.FindProperty("applyHRTF");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (SteamAudioSettings.Singleton.audioEngine != AudioEngineType.Unity)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"This component requires the audio engine to be set to Unity. Click" +
|
||||
"Steam Audio > Settings to change this.", MessageType.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(mApplyHRTF);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioAmbisonicSourceInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioAmbisonicSourceInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93bd07e672dff904ea2291dd4ac45a45
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
97
Scripts/Editor/SteamAudioBakedListenerInspector.cs
Executable file
97
Scripts/Editor/SteamAudioBakedListenerInspector.cs
Executable file
@ -0,0 +1,97 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioBakedListener))]
|
||||
public class SteamAudioBakedListenerInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mInfluenceRadius;
|
||||
SerializedProperty mUseAllProbeBatches;
|
||||
SerializedProperty mProbeBatches;
|
||||
|
||||
bool mStatsFoldout = false;
|
||||
bool mShouldShowProgressBar = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mInfluenceRadius = serializedObject.FindProperty("influenceRadius");
|
||||
mUseAllProbeBatches = serializedObject.FindProperty("useAllProbeBatches");
|
||||
mProbeBatches = serializedObject.FindProperty("probeBatches");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var oldGUIEnabled = GUI.enabled;
|
||||
GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
|
||||
var tgt = target as SteamAudioBakedListener;
|
||||
|
||||
EditorGUILayout.PropertyField(mInfluenceRadius);
|
||||
EditorGUILayout.PropertyField(mUseAllProbeBatches);
|
||||
if (!mUseAllProbeBatches.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mProbeBatches);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Bake"))
|
||||
{
|
||||
tgt.BeginBake();
|
||||
mShouldShowProgressBar = true;
|
||||
}
|
||||
|
||||
GUI.enabled = oldGUIEnabled;
|
||||
|
||||
if (mShouldShowProgressBar && !Baker.IsBakeActive())
|
||||
{
|
||||
mShouldShowProgressBar = false;
|
||||
}
|
||||
|
||||
if (mShouldShowProgressBar)
|
||||
{
|
||||
Baker.DrawProgressBar();
|
||||
}
|
||||
|
||||
Repaint();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
mStatsFoldout = EditorGUILayout.Foldout(mStatsFoldout, "Baked Data Statistics");
|
||||
if (mStatsFoldout && !Baker.IsBakeActive())
|
||||
{
|
||||
for (var i = 0; i < tgt.GetProbeBatchesUsed().Length; ++i)
|
||||
{
|
||||
EditorGUILayout.LabelField(tgt.GetProbeBatchesUsed()[i].gameObject.name, Common.HumanReadableDataSize(tgt.GetProbeDataSizes()[i]));
|
||||
}
|
||||
EditorGUILayout.LabelField("Total Size", Common.HumanReadableDataSize(tgt.GetTotalDataSize()));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioBakedListenerInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioBakedListenerInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e99d6d8163e0e24cadf1add0983102e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
97
Scripts/Editor/SteamAudioBakedSourceInspector.cs
Executable file
97
Scripts/Editor/SteamAudioBakedSourceInspector.cs
Executable file
@ -0,0 +1,97 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioBakedSource))]
|
||||
public class SteamAudioBakedSourceInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mInfluenceRadius;
|
||||
SerializedProperty mUseAllProbeBatches;
|
||||
SerializedProperty mProbeBatches;
|
||||
|
||||
bool mStatsFoldout = false;
|
||||
bool mShouldShowProgressBar = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mInfluenceRadius = serializedObject.FindProperty("influenceRadius");
|
||||
mUseAllProbeBatches = serializedObject.FindProperty("useAllProbeBatches");
|
||||
mProbeBatches = serializedObject.FindProperty("probeBatches");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var oldGUIEnabled = GUI.enabled;
|
||||
GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
|
||||
var tgt = target as SteamAudioBakedSource;
|
||||
|
||||
EditorGUILayout.PropertyField(mInfluenceRadius);
|
||||
EditorGUILayout.PropertyField(mUseAllProbeBatches);
|
||||
if (!mUseAllProbeBatches.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mProbeBatches);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Bake"))
|
||||
{
|
||||
tgt.BeginBake();
|
||||
mShouldShowProgressBar = true;
|
||||
}
|
||||
|
||||
GUI.enabled = oldGUIEnabled;
|
||||
|
||||
if (mShouldShowProgressBar && !Baker.IsBakeActive())
|
||||
{
|
||||
mShouldShowProgressBar = false;
|
||||
}
|
||||
|
||||
if (mShouldShowProgressBar)
|
||||
{
|
||||
Baker.DrawProgressBar();
|
||||
}
|
||||
|
||||
Repaint();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
mStatsFoldout = EditorGUILayout.Foldout(mStatsFoldout, "Baked Data Statistics");
|
||||
if (mStatsFoldout && !Baker.IsBakeActive())
|
||||
{
|
||||
for (var i = 0; i < tgt.GetProbeBatchesUsed().Length; ++i)
|
||||
{
|
||||
EditorGUILayout.LabelField(tgt.GetProbeBatchesUsed()[i].gameObject.name, Common.HumanReadableDataSize(tgt.GetProbeDataSizes()[i]));
|
||||
}
|
||||
EditorGUILayout.LabelField("Total Size", Common.HumanReadableDataSize(tgt.GetTotalDataSize()));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioBakedSourceInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioBakedSourceInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3333927edc4e4ec4e880a1ff9e9a7a2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
75
Scripts/Editor/SteamAudioDynamicObjectInspector.cs
Executable file
75
Scripts/Editor/SteamAudioDynamicObjectInspector.cs
Executable file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioDynamicObject))]
|
||||
public class SteamAudioDynamicObjectInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mAsset;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mAsset = serializedObject.FindProperty("asset");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(mAsset);
|
||||
|
||||
if (mAsset.objectReferenceValue == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"This Dynamic Object has not been exported to an asset yet. Please click Export Dynamic Object " +
|
||||
"to do so.", MessageType.Warning);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Export Dynamic Object"))
|
||||
{
|
||||
if (mAsset.objectReferenceValue == null)
|
||||
{
|
||||
var name = (target as SteamAudioDynamicObject).gameObject.scene.name + "_" + target.name;
|
||||
mAsset.objectReferenceValue = SerializedData.PromptForNewAsset(name);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
SteamAudioManager.ExportDynamicObject(target as SteamAudioDynamicObject, false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Export Dynamic Object as OBJ"))
|
||||
{
|
||||
SteamAudioManager.ExportDynamicObject(target as SteamAudioDynamicObject, true);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioDynamicObjectInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioDynamicObjectInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 980be31a5041c924094140b19f4276cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
70
Scripts/Editor/SteamAudioGeometryInspector.cs
Executable file
70
Scripts/Editor/SteamAudioGeometryInspector.cs
Executable file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioGeometry))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SteamAudioGeometryInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mMaterial;
|
||||
SerializedProperty mExportAllChildren;
|
||||
SerializedProperty mTerrainSimplificationLevel;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mMaterial = serializedObject.FindProperty("material");
|
||||
mExportAllChildren = serializedObject.FindProperty("exportAllChildren");
|
||||
mTerrainSimplificationLevel = serializedObject.FindProperty("terrainSimplificationLevel");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var tgt = target as SteamAudioGeometry;
|
||||
|
||||
EditorGUILayout.PropertyField(mMaterial);
|
||||
|
||||
if (tgt.transform.childCount != 0)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mExportAllChildren);
|
||||
}
|
||||
|
||||
if (tgt.gameObject.GetComponent<Terrain>() != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTerrainSimplificationLevel);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Geometry Statistics", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField("Vertices", tgt.GetNumVertices().ToString());
|
||||
EditorGUILayout.LabelField("Triangles", tgt.GetNumTriangles().ToString());
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioGeometryInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioGeometryInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58fcd8cc93a64734490ae21a46fb412d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
108
Scripts/Editor/SteamAudioListenerInspector.cs
Executable file
108
Scripts/Editor/SteamAudioListenerInspector.cs
Executable file
@ -0,0 +1,108 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioListener))]
|
||||
public class SteamAudioListenerInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mCurrentBakedListener;
|
||||
SerializedProperty mApplyReverb;
|
||||
SerializedProperty mReverbType;
|
||||
SerializedProperty mUseAllProbeBatches;
|
||||
SerializedProperty mProbeBatches;
|
||||
|
||||
bool mStatsFoldout = false;
|
||||
bool mShouldShowProgressBar = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mCurrentBakedListener = serializedObject.FindProperty("currentBakedListener");
|
||||
mApplyReverb = serializedObject.FindProperty("applyReverb");
|
||||
mReverbType = serializedObject.FindProperty("reverbType");
|
||||
mUseAllProbeBatches = serializedObject.FindProperty("useAllProbeBatches");
|
||||
mProbeBatches = serializedObject.FindProperty("probeBatches");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(mCurrentBakedListener);
|
||||
|
||||
EditorGUILayout.PropertyField(mApplyReverb);
|
||||
if (mApplyReverb.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mReverbType);
|
||||
}
|
||||
|
||||
var oldGUIEnabled = GUI.enabled;
|
||||
GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
|
||||
var tgt = target as SteamAudioListener;
|
||||
|
||||
EditorGUILayout.PropertyField(mUseAllProbeBatches);
|
||||
if (!mUseAllProbeBatches.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mProbeBatches);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Bake"))
|
||||
{
|
||||
tgt.BeginBake();
|
||||
mShouldShowProgressBar = true;
|
||||
}
|
||||
|
||||
GUI.enabled = oldGUIEnabled;
|
||||
|
||||
if (mShouldShowProgressBar && !Baker.IsBakeActive())
|
||||
{
|
||||
mShouldShowProgressBar = false;
|
||||
}
|
||||
|
||||
if (mShouldShowProgressBar)
|
||||
{
|
||||
Baker.DrawProgressBar();
|
||||
}
|
||||
|
||||
Repaint();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
mStatsFoldout = EditorGUILayout.Foldout(mStatsFoldout, "Baked Data Statistics");
|
||||
if (mStatsFoldout && !Baker.IsBakeActive())
|
||||
{
|
||||
for (var i = 0; i < tgt.GetProbeBatchesUsed().Length; ++i)
|
||||
{
|
||||
EditorGUILayout.LabelField(tgt.GetProbeBatchesUsed()[i].gameObject.name, Common.HumanReadableDataSize(tgt.GetProbeDataSizes()[i]));
|
||||
}
|
||||
EditorGUILayout.LabelField("Total Size", Common.HumanReadableDataSize(tgt.GetTotalDataSize()));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioListenerInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioListenerInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68c66682e05a3a744896f1452c21c860
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
57
Scripts/Editor/SteamAudioManagerInspector.cs
Executable file
57
Scripts/Editor/SteamAudioManagerInspector.cs
Executable file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioManager))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SteamAudioManagerInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mCurrentHRTF;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mCurrentHRTF = serializedObject.FindProperty("currentHRTF");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var tgt = target as SteamAudioManager;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("HRTF Settings", EditorStyles.boldLabel);
|
||||
mCurrentHRTF.intValue = EditorGUILayout.Popup("Current HRTF", mCurrentHRTF.intValue, tgt.hrtfNames);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.HelpBox(
|
||||
"This component should not be added manually to any GameObject. It is automatically created and" +
|
||||
"destroyed by Steam Audio.", MessageType.Warning);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioManagerInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioManagerInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5adb5adac336b84fa2308b30315459d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
59
Scripts/Editor/SteamAudioMaterialInspector.cs
Executable file
59
Scripts/Editor/SteamAudioMaterialInspector.cs
Executable file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioMaterial))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SteamAudioMaterialInspector : Editor
|
||||
{
|
||||
SerializedProperty lowFreqAbsorption;
|
||||
SerializedProperty midFreqAbsorption;
|
||||
SerializedProperty highFreqAbsorption;
|
||||
SerializedProperty scattering;
|
||||
SerializedProperty lowFreqTransmission;
|
||||
SerializedProperty midFreqTransmission;
|
||||
SerializedProperty highFreqTransmission;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
lowFreqAbsorption = serializedObject.FindProperty("lowFreqAbsorption");
|
||||
midFreqAbsorption = serializedObject.FindProperty("midFreqAbsorption");
|
||||
highFreqAbsorption = serializedObject.FindProperty("highFreqAbsorption");
|
||||
scattering = serializedObject.FindProperty("scattering");
|
||||
lowFreqTransmission = serializedObject.FindProperty("lowFreqTransmission");
|
||||
midFreqTransmission = serializedObject.FindProperty("midFreqTransmission");
|
||||
highFreqTransmission = serializedObject.FindProperty("highFreqTransmission");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(lowFreqAbsorption);
|
||||
EditorGUILayout.PropertyField(midFreqAbsorption);
|
||||
EditorGUILayout.PropertyField(highFreqAbsorption);
|
||||
EditorGUILayout.PropertyField(scattering);
|
||||
EditorGUILayout.PropertyField(lowFreqTransmission);
|
||||
EditorGUILayout.PropertyField(midFreqTransmission);
|
||||
EditorGUILayout.PropertyField(highFreqTransmission);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
12
Scripts/Editor/SteamAudioMaterialInspector.cs.meta
Executable file
12
Scripts/Editor/SteamAudioMaterialInspector.cs.meta
Executable file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d390cf1bb6f67ca47b6b5d3c43ec5956
|
||||
timeCreated: 1499375927
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Scripts/Editor/SteamAudioMixerReturnGUI.cs
Executable file
74
Scripts/Editor/SteamAudioMixerReturnGUI.cs
Executable file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class SteamAudioMixerReturnGUI : IAudioEffectPluginGUI
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Steam Audio Mixer Return";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Vendor
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Valve Corporation";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Enables accelerated mixing of reflections for sources spatialized using Steam Audio.";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnGUI(IAudioEffectPlugin plugin)
|
||||
{
|
||||
if (SteamAudioSettings.Singleton.audioEngine != AudioEngineType.Unity)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"This Audio Mixer effect requires the audio engine to be set to Unity. Click" +
|
||||
"Steam Audio > Settings to change this.", MessageType.Warning);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var binauralValue = 0.0f;
|
||||
|
||||
plugin.GetFloatParameter("Binaural", out binauralValue);
|
||||
|
||||
var binaural = (binauralValue == 1.0f);
|
||||
|
||||
binaural = EditorGUILayout.Toggle("Apply HRTF", binaural);
|
||||
|
||||
binauralValue = (binaural) ? 1.0f : 0.0f;
|
||||
|
||||
plugin.SetFloatParameter("Binaural", binauralValue);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
12
Scripts/Editor/SteamAudioMixerReturnGUI.cs.meta
Executable file
12
Scripts/Editor/SteamAudioMixerReturnGUI.cs.meta
Executable file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03cab73d8173c364bb30b17574e2f240
|
||||
timeCreated: 1499881264
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
143
Scripts/Editor/SteamAudioProbeBatchInspector.cs
Executable file
143
Scripts/Editor/SteamAudioProbeBatchInspector.cs
Executable file
@ -0,0 +1,143 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioProbeBatch))]
|
||||
public class SteamAudioProbeBatchInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mPlacementStrategy;
|
||||
SerializedProperty mHorizontalSpacing;
|
||||
SerializedProperty mHeightAboveFloor;
|
||||
SerializedProperty mAsset;
|
||||
|
||||
bool mShouldShowProgressBar = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mPlacementStrategy = serializedObject.FindProperty("placementStrategy");
|
||||
mHorizontalSpacing = serializedObject.FindProperty("horizontalSpacing");
|
||||
mHeightAboveFloor = serializedObject.FindProperty("heightAboveFloor");
|
||||
mAsset = serializedObject.FindProperty("asset");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var oldGUIEnabled = GUI.enabled;
|
||||
GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
|
||||
var tgt = target as SteamAudioProbeBatch;
|
||||
|
||||
EditorGUILayout.PropertyField(mAsset);
|
||||
|
||||
EditorGUILayout.PropertyField(mPlacementStrategy);
|
||||
if ((ProbeGenerationType) mPlacementStrategy.enumValueIndex == ProbeGenerationType.UniformFloor)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mHorizontalSpacing);
|
||||
EditorGUILayout.PropertyField(mHeightAboveFloor);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Generate Probes"))
|
||||
{
|
||||
tgt.GenerateProbes();
|
||||
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
if (tgt.GetNumProbes() > 0)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Baked Pathing Settings", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Bake"))
|
||||
{
|
||||
tgt.BeginBake();
|
||||
mShouldShowProgressBar = true;
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = oldGUIEnabled;
|
||||
|
||||
if (mShouldShowProgressBar && !Baker.IsBakeActive())
|
||||
{
|
||||
mShouldShowProgressBar = false;
|
||||
}
|
||||
|
||||
if (mShouldShowProgressBar)
|
||||
{
|
||||
Baker.DrawProgressBar();
|
||||
}
|
||||
|
||||
Repaint();
|
||||
|
||||
if (tgt.GetNumProbes() > 0)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Probe Statistics", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField("Probes", tgt.GetNumProbes().ToString());
|
||||
EditorGUILayout.LabelField("Data Size", Common.HumanReadableDataSize(tgt.probeDataSize));
|
||||
|
||||
if (tgt.GetNumLayers() > 0)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Detailed Statistics", EditorStyles.boldLabel);
|
||||
for (var i = 0; i < tgt.GetNumLayers(); ++i)
|
||||
{
|
||||
var layerInfo = tgt.GetInfoForLayer(i);
|
||||
|
||||
var name = "";
|
||||
if (layerInfo.identifier.type == BakedDataType.Pathing)
|
||||
{
|
||||
name = "Pathing";
|
||||
}
|
||||
else if (layerInfo.identifier.variation == BakedDataVariation.Reverb)
|
||||
{
|
||||
name = "Reverb";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = layerInfo.gameObject.name;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(name, Common.HumanReadableDataSize(layerInfo.dataSize));
|
||||
if (GUILayout.Button("Clear"))
|
||||
{
|
||||
tgt.DeleteBakedDataForIdentifier(layerInfo.identifier);
|
||||
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioProbeBatchInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioProbeBatchInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db54b1d0b8cefcf4486eccd5e7c185f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Scripts/Editor/SteamAudioReverbGUI.cs
Executable file
74
Scripts/Editor/SteamAudioReverbGUI.cs
Executable file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class SteamAudioReverbGUI : IAudioEffectPluginGUI
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Steam Audio Reverb";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Vendor
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Valve Corporation";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Listener-centric reverb using Steam Audio.";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnGUI(IAudioEffectPlugin plugin)
|
||||
{
|
||||
if (SteamAudioSettings.Singleton.audioEngine != AudioEngineType.Unity)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"This Audio Mixer effect requires the audio engine to be set to Unity. Click" +
|
||||
"Steam Audio > Settings to change this.", MessageType.Warning);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var binauralValue = 0.0f;
|
||||
|
||||
plugin.GetFloatParameter("Binaural", out binauralValue);
|
||||
|
||||
var binaural = (binauralValue == 1.0f);
|
||||
|
||||
binaural = EditorGUILayout.Toggle("Apply HRTF", binaural);
|
||||
|
||||
binauralValue = (binaural) ? 1.0f : 0.0f;
|
||||
|
||||
plugin.SetFloatParameter("Binaural", binauralValue);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
12
Scripts/Editor/SteamAudioReverbGUI.cs.meta
Executable file
12
Scripts/Editor/SteamAudioReverbGUI.cs.meta
Executable file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f194df3638411045b8624f4e62e44fd
|
||||
timeCreated: 1499886452
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
233
Scripts/Editor/SteamAudioSettingsInspector.cs
Executable file
233
Scripts/Editor/SteamAudioSettingsInspector.cs
Executable file
@ -0,0 +1,233 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioSettings))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SteamAudioSettingsInspector : Editor
|
||||
{
|
||||
SerializedProperty mAudioEngine;
|
||||
SerializedProperty mPerspectiveCorrection;
|
||||
SerializedProperty mPerspectiveCorrectionFactor;
|
||||
SerializedProperty mHRTFVolumeNormalizationType;
|
||||
SerializedProperty mHRTFVolumeGainDB;
|
||||
SerializedProperty mSOFAFiles;
|
||||
SerializedProperty mDefaultMaterial;
|
||||
SerializedProperty mSceneType;
|
||||
SerializedProperty mLayerMask;
|
||||
SerializedProperty mMaxOcclusionSamples;
|
||||
SerializedProperty mRealTimeRays;
|
||||
SerializedProperty mRealTimeBounces;
|
||||
SerializedProperty mRealTimeDuration;
|
||||
SerializedProperty mRealTimeAmbisonicOrder;
|
||||
SerializedProperty mRealTimeMaxSources;
|
||||
SerializedProperty mRealTimeCPUCoresPercentage;
|
||||
SerializedProperty mRealTimeIrradianceMinDistance;
|
||||
SerializedProperty mBakeConvolution;
|
||||
SerializedProperty mBakeParametric;
|
||||
SerializedProperty mBakingRays;
|
||||
SerializedProperty mBakingBounces;
|
||||
SerializedProperty mBakingDuration;
|
||||
SerializedProperty mBakingAmbisonicOrder;
|
||||
SerializedProperty mBakingCPUCoresPercentage;
|
||||
SerializedProperty mBakingIrradianceMinDistance;
|
||||
SerializedProperty mBakingVisibilitySamples;
|
||||
SerializedProperty mBakingVisibilityRadius;
|
||||
SerializedProperty mBakingVisibilityThreshold;
|
||||
SerializedProperty mBakingVisibilityRange;
|
||||
SerializedProperty mBakingPathRange;
|
||||
SerializedProperty mBakedPathingCPUCoresPercentage;
|
||||
SerializedProperty mSimulationUpdateInterval;
|
||||
SerializedProperty mReflectionEffectType;
|
||||
SerializedProperty mHybridReverbTransitionTime;
|
||||
SerializedProperty mHybridReverbOverlapPercent;
|
||||
SerializedProperty mDeviceType;
|
||||
SerializedProperty mMaxReservedCUs;
|
||||
SerializedProperty mFractionCUsForIRUpdate;
|
||||
SerializedProperty mBakingBatchSize;
|
||||
SerializedProperty mTANDuration;
|
||||
SerializedProperty mTANAmbisonicOrder;
|
||||
SerializedProperty mTANMaxSources;
|
||||
SerializedProperty mEnableValidation;
|
||||
|
||||
#if !UNITY_2019_2_OR_NEWER
|
||||
static string[] sSceneTypes = new string[] { "Phonon", "Embree", "Radeon Rays", "Unity" };
|
||||
#endif
|
||||
|
||||
#if !UNITY_2019_2_OR_NEWER
|
||||
static string[] sReflectionEffectTypes = new string[] { "Convolution", "Parametric", "Hybrid", "TrueAudio Next" };
|
||||
#endif
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mAudioEngine = serializedObject.FindProperty("audioEngine");
|
||||
mPerspectiveCorrection = serializedObject.FindProperty("perspectiveCorrection");
|
||||
mPerspectiveCorrectionFactor = serializedObject.FindProperty("perspectiveCorrectionFactor");
|
||||
mHRTFVolumeGainDB = serializedObject.FindProperty("hrtfVolumeGainDB");
|
||||
mHRTFVolumeNormalizationType = serializedObject.FindProperty("hrtfNormalizationType");
|
||||
mSOFAFiles = serializedObject.FindProperty("SOFAFiles");
|
||||
mDefaultMaterial = serializedObject.FindProperty("defaultMaterial");
|
||||
mSceneType = serializedObject.FindProperty("sceneType");
|
||||
mLayerMask = serializedObject.FindProperty("layerMask");
|
||||
mMaxOcclusionSamples = serializedObject.FindProperty("maxOcclusionSamples");
|
||||
mRealTimeRays = serializedObject.FindProperty("realTimeRays");
|
||||
mRealTimeBounces = serializedObject.FindProperty("realTimeBounces");
|
||||
mRealTimeDuration = serializedObject.FindProperty("realTimeDuration");
|
||||
mRealTimeAmbisonicOrder = serializedObject.FindProperty("realTimeAmbisonicOrder");
|
||||
mRealTimeMaxSources = serializedObject.FindProperty("realTimeMaxSources");
|
||||
mRealTimeCPUCoresPercentage = serializedObject.FindProperty("realTimeCPUCoresPercentage");
|
||||
mRealTimeIrradianceMinDistance = serializedObject.FindProperty("realTimeIrradianceMinDistance");
|
||||
mBakeConvolution = serializedObject.FindProperty("bakeConvolution");
|
||||
mBakeParametric = serializedObject.FindProperty("bakeParametric");
|
||||
mBakingRays = serializedObject.FindProperty("bakingRays");
|
||||
mBakingBounces = serializedObject.FindProperty("bakingBounces");
|
||||
mBakingDuration = serializedObject.FindProperty("bakingDuration");
|
||||
mBakingAmbisonicOrder = serializedObject.FindProperty("bakingAmbisonicOrder");
|
||||
mBakingCPUCoresPercentage = serializedObject.FindProperty("bakingCPUCoresPercentage");
|
||||
mBakingIrradianceMinDistance = serializedObject.FindProperty("bakingIrradianceMinDistance");
|
||||
mBakingVisibilitySamples = serializedObject.FindProperty("bakingVisibilitySamples");
|
||||
mBakingVisibilityRadius = serializedObject.FindProperty("bakingVisibilityRadius");
|
||||
mBakingVisibilityThreshold = serializedObject.FindProperty("bakingVisibilityThreshold");
|
||||
mBakingVisibilityRange = serializedObject.FindProperty("bakingVisibilityRange");
|
||||
mBakingPathRange = serializedObject.FindProperty("bakingPathRange");
|
||||
mBakedPathingCPUCoresPercentage = serializedObject.FindProperty("bakedPathingCPUCoresPercentage");
|
||||
mSimulationUpdateInterval = serializedObject.FindProperty("simulationUpdateInterval");
|
||||
mReflectionEffectType = serializedObject.FindProperty("reflectionEffectType");
|
||||
mHybridReverbTransitionTime = serializedObject.FindProperty("hybridReverbTransitionTime");
|
||||
mHybridReverbOverlapPercent = serializedObject.FindProperty("hybridReverbOverlapPercent");
|
||||
mDeviceType = serializedObject.FindProperty("deviceType");
|
||||
mMaxReservedCUs = serializedObject.FindProperty("maxReservedComputeUnits");
|
||||
mFractionCUsForIRUpdate = serializedObject.FindProperty("fractionComputeUnitsForIRUpdate");
|
||||
mBakingBatchSize = serializedObject.FindProperty("bakingBatchSize");
|
||||
mTANDuration = serializedObject.FindProperty("TANDuration");
|
||||
mTANAmbisonicOrder = serializedObject.FindProperty("TANAmbisonicOrder");
|
||||
mTANMaxSources = serializedObject.FindProperty("TANMaxSources");
|
||||
mEnableValidation = serializedObject.FindProperty("EnableValidation");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(mAudioEngine);
|
||||
EditorGUILayout.PropertyField(mPerspectiveCorrection, new UnityEngine.GUIContent("Enable Perspective Correction"));
|
||||
|
||||
if (mPerspectiveCorrection.boolValue)
|
||||
EditorGUILayout.PropertyField(mPerspectiveCorrectionFactor);
|
||||
|
||||
EditorGUILayout.PropertyField(mHRTFVolumeGainDB, new UnityEngine.GUIContent("HRTF Volume Gain (dB)"));
|
||||
EditorGUILayout.PropertyField(mHRTFVolumeNormalizationType, new UnityEngine.GUIContent("HRTF Normalization Type"));
|
||||
|
||||
EditorGUILayout.PropertyField(mSOFAFiles, true);
|
||||
EditorGUILayout.PropertyField(mDefaultMaterial);
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
EditorGUILayout.PropertyField(mSceneType);
|
||||
#else
|
||||
SceneTypeField();
|
||||
#endif
|
||||
|
||||
if (((SceneType) mSceneType.enumValueIndex) == SceneType.Custom)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mLayerMask);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mMaxOcclusionSamples);
|
||||
|
||||
EditorGUILayout.PropertyField(mRealTimeRays);
|
||||
EditorGUILayout.PropertyField(mRealTimeBounces);
|
||||
EditorGUILayout.PropertyField(mRealTimeDuration);
|
||||
EditorGUILayout.PropertyField(mRealTimeAmbisonicOrder);
|
||||
EditorGUILayout.PropertyField(mRealTimeMaxSources);
|
||||
EditorGUILayout.PropertyField(mRealTimeCPUCoresPercentage);
|
||||
EditorGUILayout.PropertyField(mRealTimeIrradianceMinDistance);
|
||||
|
||||
EditorGUILayout.PropertyField(mBakeConvolution);
|
||||
EditorGUILayout.PropertyField(mBakeParametric);
|
||||
EditorGUILayout.PropertyField(mBakingRays);
|
||||
EditorGUILayout.PropertyField(mBakingBounces);
|
||||
EditorGUILayout.PropertyField(mBakingDuration);
|
||||
EditorGUILayout.PropertyField(mBakingAmbisonicOrder);
|
||||
EditorGUILayout.PropertyField(mBakingCPUCoresPercentage);
|
||||
EditorGUILayout.PropertyField(mBakingIrradianceMinDistance);
|
||||
|
||||
EditorGUILayout.PropertyField(mBakingVisibilitySamples);
|
||||
EditorGUILayout.PropertyField(mBakingVisibilityRadius);
|
||||
EditorGUILayout.PropertyField(mBakingVisibilityThreshold);
|
||||
EditorGUILayout.PropertyField(mBakingVisibilityRange);
|
||||
EditorGUILayout.PropertyField(mBakingPathRange);
|
||||
EditorGUILayout.PropertyField(mBakedPathingCPUCoresPercentage);
|
||||
|
||||
EditorGUILayout.PropertyField(mSimulationUpdateInterval);
|
||||
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
EditorGUILayout.PropertyField(mReflectionEffectType);
|
||||
#else
|
||||
ReflectionEffectTypeField();
|
||||
#endif
|
||||
|
||||
if (((ReflectionEffectType) mReflectionEffectType.enumValueIndex) == ReflectionEffectType.Hybrid)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mHybridReverbTransitionTime);
|
||||
EditorGUILayout.PropertyField(mHybridReverbOverlapPercent);
|
||||
}
|
||||
|
||||
if (((SceneType) mSceneType.enumValueIndex) == SceneType.RadeonRays ||
|
||||
((ReflectionEffectType) mReflectionEffectType.enumValueIndex) == ReflectionEffectType.TrueAudioNext)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDeviceType);
|
||||
EditorGUILayout.PropertyField(mMaxReservedCUs);
|
||||
EditorGUILayout.PropertyField(mFractionCUsForIRUpdate);
|
||||
|
||||
if (((SceneType) mSceneType.enumValueIndex) == SceneType.RadeonRays)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mBakingBatchSize);
|
||||
}
|
||||
|
||||
if (((ReflectionEffectType) mReflectionEffectType.enumValueIndex) == ReflectionEffectType.TrueAudioNext)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTANDuration);
|
||||
EditorGUILayout.PropertyField(mTANAmbisonicOrder);
|
||||
EditorGUILayout.PropertyField(mTANMaxSources);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mEnableValidation);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
#if !UNITY_2019_2_OR_NEWER
|
||||
void SceneTypeField()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Ray Tracer Settings", EditorStyles.boldLabel);
|
||||
mSceneType.enumValueIndex = EditorGUILayout.Popup(mSceneType.displayName, mSceneType.enumValueIndex, sSceneTypes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !UNITY_2019_2_OR_NEWER
|
||||
void ReflectionEffectTypeField()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Reflection Effect Settings", EditorStyles.boldLabel);
|
||||
mReflectionEffectType.enumValueIndex = EditorGUILayout.Popup(mReflectionEffectType.displayName, mReflectionEffectType.enumValueIndex, sReflectionEffectTypes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioSettingsInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioSettingsInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4874c09ead1502c4b966e1bb4e7ad3da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
346
Scripts/Editor/SteamAudioSourceInspector.cs
Executable file
346
Scripts/Editor/SteamAudioSourceInspector.cs
Executable file
@ -0,0 +1,346 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioSource))]
|
||||
public class SteamAudioSourceInspector : Editor
|
||||
{
|
||||
SerializedProperty mDirectBinaural;
|
||||
SerializedProperty mInterpolation;
|
||||
SerializedProperty mPerspectiveCorrection;
|
||||
SerializedProperty mDistanceAttenuation;
|
||||
SerializedProperty mDistanceAttenuationInput;
|
||||
SerializedProperty mAirAbsorption;
|
||||
SerializedProperty mAirAbsorptionInput;
|
||||
SerializedProperty mAirAbsorptionLow;
|
||||
SerializedProperty mAirAbsorptionMid;
|
||||
SerializedProperty mAirAbsorptionHigh;
|
||||
SerializedProperty mDirectivity;
|
||||
SerializedProperty mDirectivityInput;
|
||||
SerializedProperty mDipoleWeight;
|
||||
SerializedProperty mDipolePower;
|
||||
SerializedProperty mDirectivityValue;
|
||||
SerializedProperty mOcclusion;
|
||||
SerializedProperty mOcclusionInput;
|
||||
SerializedProperty mOcclusionType;
|
||||
SerializedProperty mOcclusionRadius;
|
||||
SerializedProperty mOcclusionSamples;
|
||||
SerializedProperty mOcclusionValue;
|
||||
SerializedProperty mTransmission;
|
||||
SerializedProperty mTransmissionType;
|
||||
SerializedProperty mTransmissionInput;
|
||||
SerializedProperty mTransmissionLow;
|
||||
SerializedProperty mTransmissionMid;
|
||||
SerializedProperty mTransmissionHigh;
|
||||
SerializedProperty mTransmissionRays;
|
||||
SerializedProperty mDirectMixLevel;
|
||||
SerializedProperty mReflections;
|
||||
SerializedProperty mReflectionsType;
|
||||
SerializedProperty mUseDistanceCurveForReflections;
|
||||
SerializedProperty mCurrentBakedSource;
|
||||
SerializedProperty mApplyHRTFToReflections;
|
||||
SerializedProperty mReflectionsMixLevel;
|
||||
SerializedProperty mPathing;
|
||||
SerializedProperty mPathingProbeBatch;
|
||||
SerializedProperty mPathValidation;
|
||||
SerializedProperty mFindAlternatePaths;
|
||||
SerializedProperty mApplyHRTFToPathing;
|
||||
SerializedProperty mPathingMixLevel;
|
||||
|
||||
Texture2D mDirectivityPreview = null;
|
||||
float[] mDirectivitySamples = null;
|
||||
Vector2[] mDirectivityPositions = null;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mDirectBinaural = serializedObject.FindProperty("directBinaural");
|
||||
mInterpolation = serializedObject.FindProperty("interpolation");
|
||||
mPerspectiveCorrection = serializedObject.FindProperty("perspectiveCorrection");
|
||||
mDistanceAttenuation = serializedObject.FindProperty("distanceAttenuation");
|
||||
mDistanceAttenuationInput = serializedObject.FindProperty("distanceAttenuationInput");
|
||||
mAirAbsorption = serializedObject.FindProperty("airAbsorption");
|
||||
mAirAbsorptionInput = serializedObject.FindProperty("airAbsorptionInput");
|
||||
mAirAbsorptionLow = serializedObject.FindProperty("airAbsorptionLow");
|
||||
mAirAbsorptionMid = serializedObject.FindProperty("airAbsorptionMid");
|
||||
mAirAbsorptionHigh = serializedObject.FindProperty("airAbsorptionHigh");
|
||||
mDirectivity = serializedObject.FindProperty("directivity");
|
||||
mDirectivityInput = serializedObject.FindProperty("directivityInput");
|
||||
mDipoleWeight = serializedObject.FindProperty("dipoleWeight");
|
||||
mDipolePower = serializedObject.FindProperty("dipolePower");
|
||||
mDirectivityValue = serializedObject.FindProperty("directivityValue");
|
||||
mOcclusion = serializedObject.FindProperty("occlusion");
|
||||
mOcclusionInput = serializedObject.FindProperty("occlusionInput");
|
||||
mOcclusionType = serializedObject.FindProperty("occlusionType");
|
||||
mOcclusionRadius = serializedObject.FindProperty("occlusionRadius");
|
||||
mOcclusionSamples = serializedObject.FindProperty("occlusionSamples");
|
||||
mOcclusionValue = serializedObject.FindProperty("occlusionValue");
|
||||
mTransmission = serializedObject.FindProperty("transmission");
|
||||
mTransmissionType = serializedObject.FindProperty("transmissionType");
|
||||
mTransmissionInput = serializedObject.FindProperty("transmissionInput");
|
||||
mTransmissionLow = serializedObject.FindProperty("transmissionLow");
|
||||
mTransmissionMid = serializedObject.FindProperty("transmissionMid");
|
||||
mTransmissionHigh = serializedObject.FindProperty("transmissionHigh");
|
||||
mTransmissionRays = serializedObject.FindProperty("maxTransmissionSurfaces");
|
||||
mDirectMixLevel = serializedObject.FindProperty("directMixLevel");
|
||||
mReflections = serializedObject.FindProperty("reflections");
|
||||
mReflectionsType = serializedObject.FindProperty("reflectionsType");
|
||||
mUseDistanceCurveForReflections = serializedObject.FindProperty("useDistanceCurveForReflections");
|
||||
mCurrentBakedSource = serializedObject.FindProperty("currentBakedSource");
|
||||
mApplyHRTFToReflections = serializedObject.FindProperty("applyHRTFToReflections");
|
||||
mReflectionsMixLevel = serializedObject.FindProperty("reflectionsMixLevel");
|
||||
mPathing = serializedObject.FindProperty("pathing");
|
||||
mPathingProbeBatch = serializedObject.FindProperty("pathingProbeBatch");
|
||||
mPathValidation = serializedObject.FindProperty("pathValidation");
|
||||
mFindAlternatePaths = serializedObject.FindProperty("findAlternatePaths");
|
||||
mApplyHRTFToPathing = serializedObject.FindProperty("applyHRTFToPathing");
|
||||
mPathingMixLevel = serializedObject.FindProperty("pathingMixLevel");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var audioEngineIsUnity = (SteamAudioSettings.Singleton.audioEngine == AudioEngineType.Unity);
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDirectBinaural);
|
||||
EditorGUILayout.PropertyField(mInterpolation);
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity && SteamAudioSettings.Singleton.perspectiveCorrection)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mPerspectiveCorrection);
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDistanceAttenuation);
|
||||
if (mDistanceAttenuation.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDistanceAttenuationInput);
|
||||
}
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mAirAbsorption);
|
||||
if (mAirAbsorption.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mAirAbsorptionInput);
|
||||
if ((AirAbsorptionInput)mAirAbsorptionInput.enumValueIndex == AirAbsorptionInput.UserDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mAirAbsorptionLow);
|
||||
EditorGUILayout.PropertyField(mAirAbsorptionMid);
|
||||
EditorGUILayout.PropertyField(mAirAbsorptionHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDirectivity);
|
||||
if (mDirectivity.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDirectivityInput);
|
||||
|
||||
if ((DirectivityInput) mDirectivityInput.enumValueIndex == DirectivityInput.SimulationDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDipoleWeight);
|
||||
EditorGUILayout.PropertyField(mDipolePower);
|
||||
DrawDirectivity(mDipoleWeight.floatValue, mDipolePower.floatValue);
|
||||
}
|
||||
else if ((DirectivityInput) mDirectivityInput.enumValueIndex == DirectivityInput.UserDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDirectivityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mOcclusion);
|
||||
if (mOcclusion.boolValue)
|
||||
{
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mOcclusionInput);
|
||||
}
|
||||
|
||||
if (!audioEngineIsUnity ||
|
||||
(OcclusionInput) mOcclusionInput.enumValueIndex == OcclusionInput.SimulationDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mOcclusionType);
|
||||
if ((OcclusionType) mOcclusionType.enumValueIndex == OcclusionType.Volumetric)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mOcclusionRadius);
|
||||
EditorGUILayout.PropertyField(mOcclusionSamples);
|
||||
}
|
||||
}
|
||||
else if ((OcclusionInput) mOcclusionInput.enumValueIndex == OcclusionInput.UserDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mOcclusionValue);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mTransmission);
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
if (mTransmission.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTransmissionType);
|
||||
EditorGUILayout.PropertyField(mTransmissionInput);
|
||||
if ((TransmissionInput)mTransmissionInput.enumValueIndex == TransmissionInput.UserDefined)
|
||||
{
|
||||
if (mTransmissionType.enumValueIndex == (int)TransmissionType.FrequencyDependent)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTransmissionLow);
|
||||
EditorGUILayout.PropertyField(mTransmissionMid);
|
||||
EditorGUILayout.PropertyField(mTransmissionHigh);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTransmissionMid);
|
||||
}
|
||||
}
|
||||
else if ((TransmissionInput) mTransmissionInput.enumValueIndex == TransmissionInput.SimulationDefined)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mTransmissionRays);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mDirectMixLevel);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mReflections);
|
||||
if (mReflections.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mReflectionsType);
|
||||
|
||||
if (audioEngineIsUnity &&
|
||||
mDistanceAttenuation.boolValue &&
|
||||
(DistanceAttenuationInput) mDistanceAttenuationInput.enumValueIndex == DistanceAttenuationInput.CurveDriven)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mUseDistanceCurveForReflections);
|
||||
}
|
||||
|
||||
if ((ReflectionsType) mReflectionsType.enumValueIndex == ReflectionsType.BakedStaticSource)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mCurrentBakedSource);
|
||||
}
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mApplyHRTFToReflections);
|
||||
EditorGUILayout.PropertyField(mReflectionsMixLevel);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(mPathing);
|
||||
if (mPathing.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mPathingProbeBatch);
|
||||
EditorGUILayout.PropertyField(mPathValidation);
|
||||
EditorGUILayout.PropertyField(mFindAlternatePaths);
|
||||
|
||||
if (audioEngineIsUnity)
|
||||
{
|
||||
EditorGUILayout.PropertyField(mApplyHRTFToPathing);
|
||||
EditorGUILayout.PropertyField(mPathingMixLevel);
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void DrawDirectivity(float dipoleWeight, float dipolePower)
|
||||
{
|
||||
if (mDirectivityPreview == null)
|
||||
{
|
||||
mDirectivityPreview = new Texture2D(65, 65);
|
||||
}
|
||||
|
||||
if (mDirectivitySamples == null)
|
||||
{
|
||||
mDirectivitySamples = new float[360];
|
||||
mDirectivityPositions = new Vector2[360];
|
||||
}
|
||||
|
||||
for (var i = 0; i < mDirectivitySamples.Length; ++i)
|
||||
{
|
||||
var theta = (i / 360.0f) * (2.0f * Mathf.PI);
|
||||
mDirectivitySamples[i] = Mathf.Pow(Mathf.Abs((1.0f - dipoleWeight) + dipoleWeight * Mathf.Cos(theta)), dipolePower);
|
||||
|
||||
var r = 31 * Mathf.Abs(mDirectivitySamples[i]);
|
||||
var x = r * Mathf.Cos(theta) + 32;
|
||||
var y = r * Mathf.Sin(theta) + 32;
|
||||
mDirectivityPositions[i] = new Vector2(-y, x);
|
||||
}
|
||||
|
||||
for (var v = 0; v < mDirectivityPreview.height; ++v)
|
||||
{
|
||||
for (var u = 0; u < mDirectivityPreview.width; ++u)
|
||||
{
|
||||
mDirectivityPreview.SetPixel(u, v, Color.gray);
|
||||
}
|
||||
}
|
||||
|
||||
for (var u = 0; u < mDirectivityPreview.width; ++u)
|
||||
{
|
||||
mDirectivityPreview.SetPixel(u, 32, Color.black);
|
||||
}
|
||||
|
||||
for (var v = 0; v < mDirectivityPreview.height; ++v)
|
||||
{
|
||||
mDirectivityPreview.SetPixel(32, v, Color.black);
|
||||
}
|
||||
|
||||
for (var i = 0; i < mDirectivitySamples.Length; ++i)
|
||||
{
|
||||
var color = (mDirectivitySamples[i] > 0.0f) ? Color.red : Color.blue;
|
||||
mDirectivityPreview.SetPixel((int) mDirectivityPositions[i].x, (int) mDirectivityPositions[i].y, color);
|
||||
}
|
||||
|
||||
mDirectivityPreview.Apply();
|
||||
|
||||
EditorGUILayout.PrefixLabel("Preview");
|
||||
EditorGUILayout.Space();
|
||||
var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
|
||||
var center = rect.center;
|
||||
center.x += 4;
|
||||
rect.center = center;
|
||||
rect.width = 65;
|
||||
rect.height = 65;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUI.DrawPreviewTexture(rect, mDirectivityPreview);
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioSourceInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioSourceInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a0b6df87f513414b805186eba677e7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
75
Scripts/Editor/SteamAudioStaticMeshInspector.cs
Executable file
75
Scripts/Editor/SteamAudioStaticMeshInspector.cs
Executable file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[CustomEditor(typeof(SteamAudioStaticMesh))]
|
||||
public class SteamAudioStaticMeshInspector : Editor
|
||||
{
|
||||
#if STEAMAUDIO_ENABLED
|
||||
SerializedProperty mAsset;
|
||||
SerializedProperty mSceneNameWhenExported;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
mAsset = serializedObject.FindProperty("asset");
|
||||
mSceneNameWhenExported = serializedObject.FindProperty("sceneNameWhenExported");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(mAsset);
|
||||
|
||||
var scene = (target as SteamAudioStaticMesh).gameObject.scene;
|
||||
|
||||
if (mAsset.objectReferenceValue == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"This scene has not been exported. Click Steam Audio > Export Active Scene to export.",
|
||||
MessageType.Warning);
|
||||
}
|
||||
else if (mSceneNameWhenExported.stringValue != scene.name)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
string.Format("This geometry was last exported for the scene {0}. If this is not what you " +
|
||||
"intended, click Export As New Asset below.", mSceneNameWhenExported.stringValue),
|
||||
MessageType.Warning);
|
||||
|
||||
if (GUILayout.Button("Export As New Asset"))
|
||||
{
|
||||
mAsset.objectReferenceValue = SerializedData.PromptForNewAsset(scene.name);
|
||||
mSceneNameWhenExported.stringValue = scene.name;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
SteamAudioManager.ExportScene(scene, false);
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
#else
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("Steam Audio is not supported for the target platform or STEAMAUDIO_ENABLED define symbol is missing.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Editor/SteamAudioStaticMeshInspector.cs.meta
Executable file
11
Scripts/Editor/SteamAudioStaticMeshInspector.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6929999ad3f3e54196cfa59c3181b95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Scripts/Editor/SteamAudioUnityEditor.asmdef
Executable file
17
Scripts/Editor/SteamAudioUnityEditor.asmdef
Executable file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "SteamAudioUnityEditor",
|
||||
"references": [
|
||||
"SteamAudioUnity"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Scripts/Editor/SteamAudioUnityEditor.asmdef.meta
Executable file
7
Scripts/Editor/SteamAudioUnityEditor.asmdef.meta
Executable file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32059f5c68d213f49892e59f10b1a065
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Scripts/Runtime.meta
Executable file
8
Scripts/Runtime.meta
Executable file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07db90b46cddd3245b0baf1c24d8548e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Scripts/Runtime/AudioEngineAmbisonicSource.cs
Executable file
46
Scripts/Runtime/AudioEngineAmbisonicSource.cs
Executable file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public abstract class AudioEngineAmbisonicSource
|
||||
{
|
||||
public virtual void Initialize(GameObject gameObject)
|
||||
{ }
|
||||
|
||||
public virtual void Destroy()
|
||||
{ }
|
||||
|
||||
public virtual void UpdateParameters(SteamAudioAmbisonicSource ambisonicSource)
|
||||
{ }
|
||||
|
||||
public virtual void GetParameters(SteamAudioAmbisonicSource ambisonicSource)
|
||||
{ }
|
||||
|
||||
public static AudioEngineAmbisonicSource Create(AudioEngineType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AudioEngineType.Unity:
|
||||
return new UnityAudioEngineAmbisonicSource();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/AudioEngineAmbisonicSource.cs.meta
Executable file
11
Scripts/Runtime/AudioEngineAmbisonicSource.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf3a8878920e660448a9f5dd6ff8589f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
59
Scripts/Runtime/AudioEngineSource.cs
Executable file
59
Scripts/Runtime/AudioEngineSource.cs
Executable file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public abstract class AudioEngineSource
|
||||
{
|
||||
public virtual void Initialize(GameObject gameObject)
|
||||
{ }
|
||||
|
||||
public virtual void Destroy()
|
||||
{ }
|
||||
|
||||
public virtual void UpdateParameters(SteamAudioSource source)
|
||||
{ }
|
||||
|
||||
public virtual void GetParameters(SteamAudioSource source)
|
||||
{ }
|
||||
|
||||
public static AudioEngineSource Create(AudioEngineType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AudioEngineType.Unity:
|
||||
return new UnityAudioEngineSource();
|
||||
case AudioEngineType.FMODStudio:
|
||||
return CreateFMODStudioAudioEngineSource();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static AudioEngineSource CreateFMODStudioAudioEngineSource()
|
||||
{
|
||||
var type = Type.GetType("SteamAudio.FMODStudioAudioEngineSource,SteamAudioUnity");
|
||||
return (type != null) ? (AudioEngineSource) Activator.CreateInstance(type) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/AudioEngineSource.cs.meta
Executable file
11
Scripts/Runtime/AudioEngineSource.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf1484b65484cc846b06a489d54195a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
89
Scripts/Runtime/AudioEngineState.cs
Executable file
89
Scripts/Runtime/AudioEngineState.cs
Executable file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using SteamAudio;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public abstract class AudioEngineState
|
||||
{
|
||||
public virtual void Initialize(IntPtr context, IntPtr defaultHRTF, SimulationSettings simulationSettings, PerspectiveCorrection correction)
|
||||
{ }
|
||||
|
||||
public virtual void Destroy()
|
||||
{ }
|
||||
|
||||
public virtual void SetHRTF(IntPtr hrtf)
|
||||
{ }
|
||||
|
||||
public virtual void SetPerspectiveCorrection(PerspectiveCorrection correction)
|
||||
{ }
|
||||
|
||||
public virtual void SetReverbSource(Source reverbSource)
|
||||
{ }
|
||||
|
||||
public static AudioEngineState Create(AudioEngineType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AudioEngineType.Unity:
|
||||
return new UnityAudioEngineState();
|
||||
case AudioEngineType.FMODStudio:
|
||||
return CreateFMODStudioAudioEngineState();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static AudioEngineState CreateFMODStudioAudioEngineState()
|
||||
{
|
||||
var type = Type.GetType("SteamAudio.FMODStudioAudioEngineState,SteamAudioUnity");
|
||||
return (type != null) ? (AudioEngineState) Activator.CreateInstance(type) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AudioEngineStateHelpers
|
||||
{
|
||||
public abstract Transform GetListenerTransform();
|
||||
|
||||
public abstract SteamAudio.AudioSettings GetAudioSettings();
|
||||
|
||||
public static AudioEngineStateHelpers Create(AudioEngineType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AudioEngineType.Unity:
|
||||
return new UnityAudioEngineStateHelpers();
|
||||
case AudioEngineType.FMODStudio:
|
||||
return CreateFMODStudioAudioEngineStateHelpers();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static AudioEngineStateHelpers CreateFMODStudioAudioEngineStateHelpers()
|
||||
{
|
||||
var type = Type.GetType("SteamAudio.FMODStudioAudioEngineStateHelpers,SteamAudioUnity");
|
||||
return (type != null) ? (AudioEngineStateHelpers) Activator.CreateInstance(type) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/AudioEngineState.cs.meta
Executable file
11
Scripts/Runtime/AudioEngineState.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82bc9a6ff2f97254787d9f40d71ae2e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
349
Scripts/Runtime/Baker.cs
Executable file
349
Scripts/Runtime/Baker.cs
Executable file
@ -0,0 +1,349 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using AOT;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public enum BakeStatus
|
||||
{
|
||||
Ready,
|
||||
InProgress,
|
||||
Complete
|
||||
}
|
||||
|
||||
public struct BakedDataTask
|
||||
{
|
||||
public GameObject gameObject;
|
||||
public MonoBehaviour component;
|
||||
public string name;
|
||||
public BakedDataIdentifier identifier;
|
||||
public SteamAudioProbeBatch[] probeBatches;
|
||||
public string[] probeBatchNames;
|
||||
public SerializedData[] probeBatchAssets;
|
||||
}
|
||||
|
||||
public static class Baker
|
||||
{
|
||||
static BakeStatus sStatus = BakeStatus.Ready;
|
||||
#if UNITY_EDITOR
|
||||
static float sProgress = 0.0f;
|
||||
#endif
|
||||
static ProgressCallback sProgressCallback = null;
|
||||
static IntPtr sProgressCallbackPointer = IntPtr.Zero;
|
||||
static GCHandle sProgressCallbackHandle;
|
||||
static Thread sThread;
|
||||
static int sCurrentObjectIndex = 0;
|
||||
static int sTotalObjects = 0;
|
||||
static string sCurrentObjectName = null;
|
||||
static int sCurrentProbeBatchIndex = 0;
|
||||
static int sTotalProbeBatches = 0;
|
||||
static bool sCancel = false;
|
||||
static BakedDataTask[] sTasks = null;
|
||||
|
||||
public static void BeginBake(BakedDataTask[] tasks)
|
||||
{
|
||||
SteamAudioManager.Initialize(ManagerInitReason.Baking);
|
||||
|
||||
if (SteamAudioManager.GetSceneType() == SceneType.Custom)
|
||||
{
|
||||
Debug.LogError("Baking is not supported when using Unity's built-in ray tracer. Click Steam Audio > Settings and switch to a different ray tracer.");
|
||||
return;
|
||||
}
|
||||
|
||||
SteamAudioManager.LoadScene(SceneManager.GetActiveScene(), SteamAudioManager.Context, false);
|
||||
|
||||
SteamAudioStaticMesh staticMeshComponent = null;
|
||||
var rootObjects = SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
foreach (var rootObject in rootObjects)
|
||||
{
|
||||
staticMeshComponent = rootObject.GetComponentInChildren<SteamAudioStaticMesh>();
|
||||
if (staticMeshComponent)
|
||||
break;
|
||||
}
|
||||
|
||||
if (staticMeshComponent == null || staticMeshComponent.asset == null)
|
||||
{
|
||||
Debug.LogError(string.Format("Scene {0} has not been exported. Click Steam Audio > Export Active Scene to do so.", SceneManager.GetActiveScene().name));
|
||||
return;
|
||||
}
|
||||
|
||||
var staticMesh = new StaticMesh(SteamAudioManager.Context, SteamAudioManager.CurrentScene, staticMeshComponent.asset);
|
||||
staticMesh.AddToScene(SteamAudioManager.CurrentScene);
|
||||
|
||||
SteamAudioManager.CurrentScene.Commit();
|
||||
|
||||
staticMesh.Release();
|
||||
|
||||
sTasks = tasks;
|
||||
sStatus = BakeStatus.InProgress;
|
||||
|
||||
sProgressCallback = new ProgressCallback(AdvanceProgress);
|
||||
|
||||
#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
|
||||
sProgressCallbackPointer = Marshal.GetFunctionPointerForDelegate(sProgressCallback);
|
||||
sProgressCallbackHandle = GCHandle.Alloc(sProgressCallbackPointer);
|
||||
GC.Collect();
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.update += InEditorUpdate;
|
||||
#endif
|
||||
|
||||
sThread = new Thread(BakeThread);
|
||||
sThread.Start();
|
||||
}
|
||||
|
||||
public static void EndBake()
|
||||
{
|
||||
if (sThread != null)
|
||||
{
|
||||
sThread.Join();
|
||||
}
|
||||
|
||||
SerializedObject.FlushAllWrites();
|
||||
|
||||
#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
|
||||
if (sProgressCallbackHandle.IsAllocated)
|
||||
{
|
||||
sProgressCallbackHandle.Free();
|
||||
}
|
||||
#endif
|
||||
|
||||
SteamAudioManager.ShutDown();
|
||||
UnityEngine.Object.DestroyImmediate(SteamAudioManager.Singleton.gameObject);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
sProgress = 0.0f;
|
||||
#endif
|
||||
sCurrentObjectIndex = 0;
|
||||
sTotalObjects = 0;
|
||||
sCurrentObjectName = null;
|
||||
sCurrentProbeBatchIndex = 0;
|
||||
sTotalProbeBatches = 0;
|
||||
|
||||
sStatus = BakeStatus.Ready;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.update -= InEditorUpdate;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsBakeActive()
|
||||
{
|
||||
return (sStatus != BakeStatus.Ready);
|
||||
}
|
||||
|
||||
public static bool DrawProgressBar()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (sStatus != BakeStatus.InProgress)
|
||||
return false;
|
||||
|
||||
var progress = sProgress + .01f; // Adding an offset because progress bar when it is exact 0 has some non-zero progress.
|
||||
var progressPercent = Mathf.FloorToInt(Mathf.Min(progress * 100.0f, 100.0f));
|
||||
var progressString = string.Format("Object {0} / {1} [{2}]: Baking {3} / {4} Probe Batch ({5}% complete)",
|
||||
sCurrentObjectIndex + 1, sTotalObjects, sCurrentObjectName, sCurrentProbeBatchIndex + 1, sTotalProbeBatches, progressPercent);
|
||||
|
||||
EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(), progress, progressString);
|
||||
|
||||
if (GUILayout.Button("Cancel"))
|
||||
{
|
||||
CancelBake();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void CancelBake()
|
||||
{
|
||||
// Ensures partial baked data is not serialized and that bake is properly canceled for multiple
|
||||
// probe boxes.
|
||||
sCancel = true;
|
||||
API.iplReflectionsBakerCancelBake(SteamAudioManager.Context.Get());
|
||||
EndBake();
|
||||
sCancel = false;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(ProgressCallback))]
|
||||
static void AdvanceProgress(float progress, IntPtr userData)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
sProgress = progress;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void InEditorUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (sStatus == BakeStatus.Complete)
|
||||
{
|
||||
EndBake();
|
||||
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void BakeThread()
|
||||
{
|
||||
sTotalObjects = sTasks.Length;
|
||||
|
||||
for (var i = 0; i < sTotalObjects; ++i)
|
||||
{
|
||||
sCurrentObjectIndex = i;
|
||||
|
||||
if (sTasks[i].identifier.type == BakedDataType.Pathing)
|
||||
{
|
||||
sCurrentObjectName = "pathing";
|
||||
}
|
||||
else if (sTasks[i].identifier.variation == BakedDataVariation.Reverb)
|
||||
{
|
||||
sCurrentObjectName = "reverb";
|
||||
}
|
||||
else
|
||||
{
|
||||
sCurrentObjectName = sTasks[i].name;
|
||||
}
|
||||
|
||||
Debug.Log(string.Format("START: Baking effect for {0}.", sCurrentObjectName));
|
||||
|
||||
var probeBatches = sTasks[i].probeBatches;
|
||||
sTotalProbeBatches = probeBatches.Length;
|
||||
|
||||
for (var j = 0; j < sTotalProbeBatches; ++j)
|
||||
{
|
||||
sCurrentProbeBatchIndex = j;
|
||||
|
||||
if (sCancel)
|
||||
return;
|
||||
|
||||
if (probeBatches[j] == null)
|
||||
{
|
||||
Debug.LogWarning(string.Format("{0}: Probe Batch at index {1} is null.", sCurrentObjectName, j));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (probeBatches[j].GetNumProbes() == 0)
|
||||
{
|
||||
Debug.LogWarning(string.Format("{0}: Probe Batch {1} has no probes, skipping.", sCurrentObjectName, sTasks[i].probeBatchNames[j]));
|
||||
continue;
|
||||
}
|
||||
|
||||
var probeBatch = new ProbeBatch(SteamAudioManager.Context, sTasks[i].probeBatchAssets[j]);
|
||||
|
||||
var simulationSettings = SteamAudioManager.GetSimulationSettings(true);
|
||||
|
||||
if (sTasks[i].identifier.type == BakedDataType.Reflections)
|
||||
{
|
||||
var bakeParams = new ReflectionsBakeParams { };
|
||||
bakeParams.scene = SteamAudioManager.CurrentScene.Get();
|
||||
bakeParams.probeBatch = probeBatch.Get();
|
||||
bakeParams.sceneType = simulationSettings.sceneType;
|
||||
bakeParams.identifier = sTasks[i].identifier;
|
||||
bakeParams.flags = 0;
|
||||
bakeParams.numRays = simulationSettings.maxNumRays;
|
||||
bakeParams.numDiffuseSamples = simulationSettings.numDiffuseSamples;
|
||||
bakeParams.numBounces = SteamAudioSettings.Singleton.bakingBounces;
|
||||
bakeParams.simulatedDuration = simulationSettings.maxDuration;
|
||||
bakeParams.savedDuration = simulationSettings.maxDuration;
|
||||
bakeParams.order = simulationSettings.maxOrder;
|
||||
bakeParams.numThreads = simulationSettings.numThreads;
|
||||
bakeParams.rayBatchSize = simulationSettings.rayBatchSize;
|
||||
bakeParams.irradianceMinDistance = SteamAudioSettings.Singleton.bakingIrradianceMinDistance;
|
||||
bakeParams.bakeBatchSize = 1;
|
||||
|
||||
if (SteamAudioSettings.Singleton.bakeConvolution)
|
||||
bakeParams.flags = bakeParams.flags | ReflectionsBakeFlags.BakeConvolution;
|
||||
|
||||
if (SteamAudioSettings.Singleton.bakeParametric)
|
||||
bakeParams.flags = bakeParams.flags | ReflectionsBakeFlags.BakeParametric;
|
||||
|
||||
if (simulationSettings.sceneType == SceneType.RadeonRays)
|
||||
{
|
||||
bakeParams.openCLDevice = SteamAudioManager.OpenCLDevice;
|
||||
bakeParams.radeonRaysDevice = SteamAudioManager.RadeonRaysDevice;
|
||||
bakeParams.bakeBatchSize = SteamAudioSettings.Singleton.bakingBatchSize;
|
||||
}
|
||||
|
||||
API.iplReflectionsBakerBake(SteamAudioManager.Context.Get(), ref bakeParams, sProgressCallback, IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
var bakeParams = new PathBakeParams { };
|
||||
bakeParams.scene = SteamAudioManager.CurrentScene.Get();
|
||||
bakeParams.probeBatch = probeBatch.Get();
|
||||
bakeParams.identifier = sTasks[i].identifier;
|
||||
bakeParams.numSamples = SteamAudioSettings.Singleton.bakingVisibilitySamples;
|
||||
bakeParams.radius = SteamAudioSettings.Singleton.bakingVisibilityRadius;
|
||||
bakeParams.threshold = SteamAudioSettings.Singleton.bakingVisibilityThreshold;
|
||||
bakeParams.visRange = SteamAudioSettings.Singleton.bakingVisibilityRange;
|
||||
bakeParams.pathRange = SteamAudioSettings.Singleton.bakingPathRange;
|
||||
bakeParams.numThreads = SteamAudioManager.Singleton.NumThreadsForCPUCorePercentage(SteamAudioSettings.Singleton.bakedPathingCPUCoresPercentage);
|
||||
|
||||
API.iplPathBakerBake(SteamAudioManager.Context.Get(), ref bakeParams, sProgressCallback, IntPtr.Zero);
|
||||
}
|
||||
|
||||
if (sCancel)
|
||||
{
|
||||
Debug.Log("CANCELLED: Baking.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't flush the writes to disk just yet, because we can only do it from the main thread.
|
||||
probeBatches[j].probeDataSize = probeBatch.Save(sTasks[i].probeBatchAssets[j], false);
|
||||
|
||||
var dataSize = (int) probeBatch.GetDataSize(sTasks[i].identifier);
|
||||
probeBatches[j].AddOrUpdateLayer(sTasks[i].gameObject, sTasks[i].identifier, dataSize);
|
||||
|
||||
if (sTasks[i].identifier.type == BakedDataType.Reflections)
|
||||
{
|
||||
switch (sTasks[i].identifier.variation)
|
||||
{
|
||||
case BakedDataVariation.Reverb:
|
||||
(sTasks[i].component as SteamAudioListener).UpdateBakedDataStatistics();
|
||||
break;
|
||||
|
||||
case BakedDataVariation.StaticSource:
|
||||
(sTasks[i].component as SteamAudioBakedSource).UpdateBakedDataStatistics();
|
||||
break;
|
||||
|
||||
case BakedDataVariation.StaticListener:
|
||||
(sTasks[i].component as SteamAudioBakedListener).UpdateBakedDataStatistics();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log(string.Format("COMPLETED: Baking effect for {0}.", sCurrentObjectName));
|
||||
}
|
||||
|
||||
sStatus = BakeStatus.Complete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/Baker.cs.meta
Executable file
11
Scripts/Runtime/Baker.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73a54b25ac58b5f499dae7062adb0e1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
188
Scripts/Runtime/Common.cs
Executable file
188
Scripts/Runtime/Common.cs
Executable file
@ -0,0 +1,188 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public static class Common
|
||||
{
|
||||
public static Vector3 ConvertVector(UnityEngine.Vector3 point)
|
||||
{
|
||||
Vector3 convertedPoint;
|
||||
convertedPoint.x = point.x;
|
||||
convertedPoint.y = point.y;
|
||||
convertedPoint.z = -point.z;
|
||||
|
||||
return convertedPoint;
|
||||
}
|
||||
|
||||
public static UnityEngine.Vector3 ConvertVector(Vector3 point)
|
||||
{
|
||||
UnityEngine.Vector3 convertedPoint;
|
||||
convertedPoint.x = point.x;
|
||||
convertedPoint.y = point.y;
|
||||
convertedPoint.z = -point.z;
|
||||
|
||||
return convertedPoint;
|
||||
}
|
||||
|
||||
public static Matrix4x4 ConvertTransform(Transform transform)
|
||||
{
|
||||
UnityEngine.Matrix4x4 flipZ = UnityEngine.Matrix4x4.Scale(new UnityEngine.Vector3(1, 1, -1));
|
||||
UnityEngine.Matrix4x4 flippedMatrix = flipZ * transform.localToWorldMatrix * flipZ;
|
||||
|
||||
var matrix = new Matrix4x4();
|
||||
matrix.m00 = flippedMatrix.m00;
|
||||
matrix.m01 = flippedMatrix.m01;
|
||||
matrix.m02 = flippedMatrix.m02;
|
||||
matrix.m03 = flippedMatrix.m03;
|
||||
matrix.m10 = flippedMatrix.m10;
|
||||
matrix.m11 = flippedMatrix.m11;
|
||||
matrix.m12 = flippedMatrix.m12;
|
||||
matrix.m13 = flippedMatrix.m13;
|
||||
matrix.m20 = flippedMatrix.m20;
|
||||
matrix.m21 = flippedMatrix.m21;
|
||||
matrix.m22 = flippedMatrix.m22;
|
||||
matrix.m23 = flippedMatrix.m23;
|
||||
matrix.m30 = flippedMatrix.m30;
|
||||
matrix.m31 = flippedMatrix.m31;
|
||||
matrix.m32 = flippedMatrix.m32;
|
||||
matrix.m33 = flippedMatrix.m33;
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public static Matrix4x4 TransposeMatrix(Matrix4x4 inMatrix)
|
||||
{
|
||||
var outMatrix = new Matrix4x4();
|
||||
|
||||
outMatrix.m00 = inMatrix.m00;
|
||||
outMatrix.m01 = inMatrix.m10;
|
||||
outMatrix.m02 = inMatrix.m20;
|
||||
outMatrix.m03 = inMatrix.m30;
|
||||
outMatrix.m10 = inMatrix.m01;
|
||||
outMatrix.m11 = inMatrix.m11;
|
||||
outMatrix.m12 = inMatrix.m21;
|
||||
outMatrix.m13 = inMatrix.m31;
|
||||
outMatrix.m20 = inMatrix.m02;
|
||||
outMatrix.m21 = inMatrix.m12;
|
||||
outMatrix.m22 = inMatrix.m22;
|
||||
outMatrix.m23 = inMatrix.m32;
|
||||
outMatrix.m30 = inMatrix.m03;
|
||||
outMatrix.m31 = inMatrix.m13;
|
||||
outMatrix.m32 = inMatrix.m23;
|
||||
outMatrix.m33 = inMatrix.m33;
|
||||
|
||||
return outMatrix;
|
||||
}
|
||||
|
||||
public static Matrix4x4 TransformMatrix(UnityEngine.Matrix4x4 inMatrix)
|
||||
{
|
||||
var outMatrix = new Matrix4x4();
|
||||
|
||||
outMatrix.m00 = inMatrix.m00;
|
||||
outMatrix.m01 = inMatrix.m01;
|
||||
outMatrix.m02 = inMatrix.m02;
|
||||
outMatrix.m03 = inMatrix.m03;
|
||||
outMatrix.m10 = inMatrix.m10;
|
||||
outMatrix.m11 = inMatrix.m11;
|
||||
outMatrix.m12 = inMatrix.m12;
|
||||
outMatrix.m13 = inMatrix.m13;
|
||||
outMatrix.m20 = inMatrix.m20;
|
||||
outMatrix.m21 = inMatrix.m21;
|
||||
outMatrix.m22 = inMatrix.m22;
|
||||
outMatrix.m23 = inMatrix.m23;
|
||||
outMatrix.m30 = inMatrix.m30;
|
||||
outMatrix.m31 = inMatrix.m31;
|
||||
outMatrix.m32 = inMatrix.m32;
|
||||
outMatrix.m33 = inMatrix.m33;
|
||||
|
||||
return outMatrix;
|
||||
}
|
||||
|
||||
public static byte[] ConvertString(string s)
|
||||
{
|
||||
return Encoding.UTF8.GetBytes(s + Char.MinValue);
|
||||
}
|
||||
|
||||
public static string GetStreamingAssetsFileName(string fileName)
|
||||
{
|
||||
var streamingAssetsFileName = Path.Combine(Application.streamingAssetsPath, fileName);
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
var tempFileName = Path.Combine(Application.temporaryCachePath, fileName);
|
||||
|
||||
if (File.Exists(tempFileName))
|
||||
{
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var streamingAssetLoader = new WWW(streamingAssetsFileName);
|
||||
while (!streamingAssetLoader.isDone)
|
||||
{
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(streamingAssetLoader.error))
|
||||
{
|
||||
using (var dataWriter = new BinaryWriter(new FileStream(tempFileName, FileMode.Create)))
|
||||
{
|
||||
dataWriter.Write(streamingAssetLoader.bytes);
|
||||
dataWriter.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(streamingAssetLoader.error);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogError(exception.ToString());
|
||||
}
|
||||
|
||||
return tempFileName;
|
||||
#else
|
||||
return streamingAssetsFileName;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string HumanReadableDataSize(int dataSize)
|
||||
{
|
||||
if (dataSize < 1e3)
|
||||
{
|
||||
return dataSize.ToString() + " bytes";
|
||||
}
|
||||
else if (dataSize < 1e6)
|
||||
{
|
||||
return (dataSize / 1e3f).ToString("0.0") + " kB";
|
||||
}
|
||||
else if (dataSize < 1e9)
|
||||
{
|
||||
return (dataSize / 1e6f).ToString("0.0") + " MB";
|
||||
}
|
||||
else
|
||||
{
|
||||
return (dataSize / 1e9f).ToString("0.0") + " GB";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/Common.cs.meta
Executable file
11
Scripts/Runtime/Common.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7797e245e8512a547ab441d68268cc01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Scripts/Runtime/Context.cs
Executable file
84
Scripts/Runtime/Context.cs
Executable file
@ -0,0 +1,84 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using AOT;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class Context
|
||||
{
|
||||
IntPtr mContext = IntPtr.Zero;
|
||||
|
||||
public Context()
|
||||
{
|
||||
var contextSettings = new ContextSettings { };
|
||||
contextSettings.version = Constants.kVersion;
|
||||
contextSettings.logCallback = LogMessage;
|
||||
contextSettings.simdLevel = SIMDLevel.AVX2;
|
||||
|
||||
if (SteamAudioSettings.Singleton.EnableValidation)
|
||||
{
|
||||
contextSettings.flags = contextSettings.flags | ContextFlags.Validation;
|
||||
}
|
||||
|
||||
var status = API.iplContextCreate(ref contextSettings, out mContext);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create context. [{0}]", status));
|
||||
}
|
||||
|
||||
public Context(Context context)
|
||||
{
|
||||
mContext = API.iplContextRetain(context.Get());
|
||||
}
|
||||
|
||||
~Context()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplContextRelease(ref mContext);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(LogCallback))]
|
||||
public static void LogMessage(LogLevel level, string message)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case LogLevel.Info:
|
||||
case LogLevel.Debug:
|
||||
Debug.Log(message);
|
||||
break;
|
||||
case LogLevel.Warning:
|
||||
Debug.LogWarning(message);
|
||||
break;
|
||||
case LogLevel.Error:
|
||||
Debug.LogError(message);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/Context.cs.meta
Executable file
11
Scripts/Runtime/Context.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19c99b97347775a4d901f873fee55e3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Scripts/Runtime/EmbreeDevice.cs
Executable file
54
Scripts/Runtime/EmbreeDevice.cs
Executable file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class EmbreeDevice
|
||||
{
|
||||
IntPtr mEmbreeDevice = IntPtr.Zero;
|
||||
|
||||
public EmbreeDevice(Context context)
|
||||
{
|
||||
var embreeDeviceSettings = new EmbreeDeviceSettings { };
|
||||
|
||||
var status = API.iplEmbreeDeviceCreate(context.Get(), ref embreeDeviceSettings, out mEmbreeDevice);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create Embree device. [{0}]", status));
|
||||
}
|
||||
|
||||
public EmbreeDevice(EmbreeDevice embreeDevice)
|
||||
{
|
||||
mEmbreeDevice = API.iplEmbreeDeviceRetain(embreeDevice.mEmbreeDevice);
|
||||
}
|
||||
|
||||
~EmbreeDevice()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplEmbreeDeviceRelease(ref mEmbreeDevice);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mEmbreeDevice;
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/EmbreeDevice.cs.meta
Executable file
11
Scripts/Runtime/EmbreeDevice.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b63c80d20765d8f49be4ad645532115f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
186
Scripts/Runtime/FMODStudioAudioEngineSource.cs
Executable file
186
Scripts/Runtime/FMODStudioAudioEngineSource.cs
Executable file
@ -0,0 +1,186 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public sealed class FMODStudioAudioEngineSource : AudioEngineSource
|
||||
{
|
||||
bool mFoundDSP = false;
|
||||
object mEventEmitter = null;
|
||||
object mEventInstance = null;
|
||||
object mDSP = null;
|
||||
SteamAudioSource mSteamAudioSource = null;
|
||||
int mHandle = -1;
|
||||
|
||||
static Type FMOD_DSP;
|
||||
static Type FMOD_ChannelGroup;
|
||||
static Type FMOD_Studio_EventInstance;
|
||||
static Type FMODUnity_StudioEventEmitter;
|
||||
static PropertyInfo FMODUnity_StudioEventEmitter_EventInstance;
|
||||
static MethodInfo FMOD_Studio_EventInstance_getChannelGroup;
|
||||
static MethodInfo FMOD_Studio_EventInstance_isValid;
|
||||
static MethodInfo FMOD_ChannelGroup_getNumDSPs;
|
||||
static MethodInfo FMOD_ChannelGroup_getDSP;
|
||||
static MethodInfo FMOD_DSP_getInfo;
|
||||
static MethodInfo FMOD_DSP_setParameterInt;
|
||||
static bool mBoundToPlugin = false;
|
||||
|
||||
const int kSimulationOutputsParamIndex = 33;
|
||||
|
||||
public override void Initialize(GameObject gameObject)
|
||||
{
|
||||
FindDSP(gameObject);
|
||||
|
||||
mSteamAudioSource = gameObject.GetComponent<SteamAudioSource>();
|
||||
if (mSteamAudioSource)
|
||||
{
|
||||
mHandle = FMODStudioAPI.iplFMODAddSource(mSteamAudioSource.GetSource().Get());
|
||||
}
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
mFoundDSP = false;
|
||||
|
||||
if (mSteamAudioSource)
|
||||
{
|
||||
FMODStudioAPI.iplFMODRemoveSource(mHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateParameters(SteamAudioSource source)
|
||||
{
|
||||
CheckForChangedEventInstance();
|
||||
|
||||
FindDSP(source.gameObject);
|
||||
if (!mFoundDSP)
|
||||
return;
|
||||
|
||||
var index = kSimulationOutputsParamIndex;
|
||||
FMOD_DSP_setParameterInt.Invoke(mDSP, new object[] { index++, mHandle });
|
||||
}
|
||||
|
||||
void CheckForChangedEventInstance()
|
||||
{
|
||||
if (mEventEmitter != null)
|
||||
{
|
||||
var eventInstance = FMODUnity_StudioEventEmitter_EventInstance.GetValue(mEventEmitter, null);
|
||||
if (eventInstance != mEventInstance)
|
||||
{
|
||||
// The event instance is different from the one we last used, which most likely means the
|
||||
// event-related objects were destroyed and re-created. Make sure we look for the DSP instance
|
||||
// when FindDSP is called next.
|
||||
mFoundDSP = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We haven't yet seen a valid event emitter component, so make sure we look for one when
|
||||
// FindDSP is called.
|
||||
mFoundDSP = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FindDSP(GameObject gameObject)
|
||||
{
|
||||
if (mFoundDSP)
|
||||
return;
|
||||
|
||||
BindToFMODStudioPlugin();
|
||||
|
||||
mEventEmitter = gameObject.GetComponent(FMODUnity_StudioEventEmitter) as object;
|
||||
if (mEventEmitter == null)
|
||||
return;
|
||||
|
||||
mEventInstance = FMODUnity_StudioEventEmitter_EventInstance.GetValue(mEventEmitter, null);
|
||||
if (!((bool)FMOD_Studio_EventInstance_isValid.Invoke(mEventInstance, null)))
|
||||
return;
|
||||
|
||||
var channelGroup = Activator.CreateInstance(FMOD_ChannelGroup);
|
||||
|
||||
var getChannelGroupArgs = new object[] { channelGroup };
|
||||
FMOD_Studio_EventInstance_getChannelGroup.Invoke(mEventInstance, getChannelGroupArgs);
|
||||
channelGroup = getChannelGroupArgs[0];
|
||||
|
||||
var getNumDSPsArgs = new object[] { 0 };
|
||||
FMOD_ChannelGroup_getNumDSPs.Invoke(channelGroup, getNumDSPsArgs);
|
||||
int numDSPs = (int)getNumDSPsArgs[0];
|
||||
|
||||
for (var i = 0; i < numDSPs; ++i)
|
||||
{
|
||||
var getDSPArgs = new object[] { i, mDSP };
|
||||
FMOD_ChannelGroup_getDSP.Invoke(channelGroup, getDSPArgs);
|
||||
mDSP = getDSPArgs[1];
|
||||
|
||||
var dspName = "";
|
||||
var dspVersion = 0u;
|
||||
var dspNumChannels = 0;
|
||||
var dspConfigWidth = 0;
|
||||
var dspConfigHeight = 0;
|
||||
|
||||
var getInfoArgs = new object[] { dspName, dspVersion, dspNumChannels, dspConfigWidth, dspConfigHeight };
|
||||
FMOD_DSP_getInfo.Invoke(mDSP, getInfoArgs);
|
||||
dspName = (string)getInfoArgs[0];
|
||||
|
||||
if (dspName == "Steam Audio Spatializer")
|
||||
{
|
||||
mFoundDSP = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BindToFMODStudioPlugin()
|
||||
{
|
||||
if (mBoundToPlugin)
|
||||
return;
|
||||
|
||||
var assemblySuffix = ",FMODUnity";
|
||||
|
||||
FMOD_DSP = Type.GetType("FMOD.DSP" + assemblySuffix);
|
||||
FMOD_ChannelGroup = Type.GetType("FMOD.ChannelGroup" + assemblySuffix);
|
||||
FMOD_Studio_EventInstance = Type.GetType("FMOD.Studio.EventInstance" + assemblySuffix);
|
||||
FMODUnity_StudioEventEmitter = Type.GetType("FMODUnity.StudioEventEmitter" + assemblySuffix);
|
||||
|
||||
FMODUnity_StudioEventEmitter_EventInstance = FMODUnity_StudioEventEmitter.GetProperty("EventInstance");
|
||||
|
||||
FMOD_Studio_EventInstance_getChannelGroup = FMOD_Studio_EventInstance.GetMethod("getChannelGroup");
|
||||
FMOD_Studio_EventInstance_isValid = FMOD_Studio_EventInstance.GetMethod("isValid");
|
||||
FMOD_ChannelGroup_getNumDSPs = FMOD_ChannelGroup.GetMethod("getNumDSPs");
|
||||
FMOD_ChannelGroup_getDSP = FMOD_ChannelGroup.GetMethod("getDSP");
|
||||
FMOD_DSP_setParameterInt = FMOD_DSP.GetMethod("setParameterInt");
|
||||
|
||||
var candidates = FMOD_DSP.GetMethods();
|
||||
foreach (var candidate in candidates)
|
||||
{
|
||||
if (candidate.Name == "getInfo" && candidate.GetParameters().Length == 5)
|
||||
{
|
||||
FMOD_DSP_getInfo = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mBoundToPlugin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/FMODStudioAudioEngineSource.cs.meta
Executable file
11
Scripts/Runtime/FMODStudioAudioEngineSource.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c36706fa5b924b94c8895e3051bdee14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
109
Scripts/Runtime/FMODStudioAudioEngineState.cs
Executable file
109
Scripts/Runtime/FMODStudioAudioEngineState.cs
Executable file
@ -0,0 +1,109 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public sealed class FMODStudioAudioEngineState : AudioEngineState
|
||||
{
|
||||
public override void Initialize(IntPtr context, IntPtr defaultHRTF, SimulationSettings simulationSettings, PerspectiveCorrection correction)
|
||||
{
|
||||
FMODStudioAPI.iplFMODInitialize(context);
|
||||
FMODStudioAPI.iplFMODSetHRTF(defaultHRTF);
|
||||
FMODStudioAPI.iplFMODSetSimulationSettings(simulationSettings);
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
FMODStudioAPI.iplFMODTerminate();
|
||||
}
|
||||
|
||||
public override void SetHRTF(IntPtr hrtf)
|
||||
{
|
||||
FMODStudioAPI.iplFMODSetHRTF(hrtf);
|
||||
}
|
||||
|
||||
public override void SetReverbSource(Source reverbSource)
|
||||
{
|
||||
FMODStudioAPI.iplFMODSetReverbSource(reverbSource.Get());
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class FMODStudioAudioEngineStateHelpers : AudioEngineStateHelpers
|
||||
{
|
||||
static bool mBoundToPlugin = false;
|
||||
|
||||
static Type FMOD_SPEAKERMODE;
|
||||
static Type FMOD_System;
|
||||
static Type FMODUnity_StudioListener;
|
||||
static Type FMODUnity_RuntimeManager;
|
||||
static PropertyInfo FMODUnity_RuntimeManager_CoreSystem;
|
||||
static MethodInfo FMOD_System_getSoftwareFormat;
|
||||
static MethodInfo FMOD_System_getDSPBufferSize;
|
||||
|
||||
public override Transform GetListenerTransform()
|
||||
{
|
||||
BindToFMODStudioPlugin();
|
||||
|
||||
var fmodStudioListener = (MonoBehaviour) GameObject.FindObjectOfType(FMODUnity_StudioListener);
|
||||
return (fmodStudioListener != null) ? fmodStudioListener.transform : null;
|
||||
}
|
||||
|
||||
public override AudioSettings GetAudioSettings()
|
||||
{
|
||||
BindToFMODStudioPlugin();
|
||||
|
||||
var audioSettings = new AudioSettings { };
|
||||
|
||||
var fmodSystem = FMODUnity_RuntimeManager_CoreSystem.GetValue(null, null);
|
||||
|
||||
var speakerMode = Activator.CreateInstance(FMOD_SPEAKERMODE);
|
||||
var getSoftwareFormatArgs = new object[] { 0, speakerMode, 0 };
|
||||
FMOD_System_getSoftwareFormat.Invoke(fmodSystem, getSoftwareFormatArgs);
|
||||
audioSettings.samplingRate = (int) getSoftwareFormatArgs[0];
|
||||
|
||||
var getDSPBufferSizeArgs = new object[] { 0u, 0 };
|
||||
FMOD_System_getDSPBufferSize.Invoke(fmodSystem, getDSPBufferSizeArgs);
|
||||
audioSettings.frameSize = (int) ((uint) getDSPBufferSizeArgs[0]);
|
||||
|
||||
return audioSettings;
|
||||
}
|
||||
|
||||
static void BindToFMODStudioPlugin()
|
||||
{
|
||||
if (mBoundToPlugin)
|
||||
return;
|
||||
|
||||
var assemblySuffix = ",FMODUnity";
|
||||
|
||||
FMOD_SPEAKERMODE = Type.GetType("FMOD.SPEAKERMODE" + assemblySuffix);
|
||||
FMOD_System = Type.GetType("FMOD.System" + assemblySuffix);
|
||||
FMODUnity_StudioListener = Type.GetType("FMODUnity.StudioListener" + assemblySuffix);
|
||||
FMODUnity_RuntimeManager = Type.GetType("FMODUnity.RuntimeManager" + assemblySuffix);
|
||||
|
||||
FMODUnity_RuntimeManager_CoreSystem = FMODUnity_RuntimeManager.GetProperty("CoreSystem");
|
||||
|
||||
FMOD_System_getSoftwareFormat = FMOD_System.GetMethod("getSoftwareFormat");
|
||||
FMOD_System_getDSPBufferSize = FMOD_System.GetMethod("getDSPBufferSize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/FMODStudioAudioEngineState.cs.meta
Executable file
11
Scripts/Runtime/FMODStudioAudioEngineState.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8e2075eab110ad4b88d26e434723035
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
102
Scripts/Runtime/HRTF.cs
Executable file
102
Scripts/Runtime/HRTF.cs
Executable file
@ -0,0 +1,102 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class HRTF
|
||||
{
|
||||
IntPtr mHRTF = IntPtr.Zero;
|
||||
|
||||
public HRTF(Context context, AudioSettings audioSettings, string sofaFileName, byte[] sofaFileData, float gaindB, HRTFNormType normType)
|
||||
{
|
||||
IntPtr sofaData = IntPtr.Zero;
|
||||
|
||||
var hrtfSettings = new HRTFSettings { };
|
||||
if (sofaFileData != null && sofaFileData.Length > 0)
|
||||
{
|
||||
hrtfSettings.type = HRTFType.SOFA;
|
||||
|
||||
sofaData = Marshal.AllocHGlobal(sofaFileData.Length);
|
||||
Marshal.Copy(sofaFileData, 0, sofaData, sofaFileData.Length);
|
||||
|
||||
hrtfSettings.sofaFileData = sofaData;
|
||||
hrtfSettings.sofaFileDataSize = sofaFileData.Length;
|
||||
}
|
||||
else if (sofaFileName != null)
|
||||
{
|
||||
hrtfSettings.type = HRTFType.SOFA;
|
||||
hrtfSettings.sofaFileName = sofaFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
hrtfSettings.type = HRTFType.Default;
|
||||
}
|
||||
|
||||
hrtfSettings.volume = dBToGain(gaindB);
|
||||
hrtfSettings.normType = normType;
|
||||
|
||||
var status = API.iplHRTFCreate(context.Get(), ref audioSettings, ref hrtfSettings, out mHRTF);
|
||||
if (status != Error.Success)
|
||||
{
|
||||
Debug.LogError(string.Format("Unable to load HRTF: {0}. [{1}]", (sofaFileName != null) ? sofaFileName : "default", status));
|
||||
mHRTF = IntPtr.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(string.Format("Loaded HRTF: {0}.", (sofaFileName != null) ? sofaFileName : "default"));
|
||||
}
|
||||
|
||||
if (sofaData != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(sofaData);
|
||||
}
|
||||
}
|
||||
|
||||
public HRTF(HRTF hrtf)
|
||||
{
|
||||
mHRTF = API.iplHRTFRetain(hrtf.Get());
|
||||
}
|
||||
|
||||
~HRTF()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplHRTFRelease(ref mHRTF);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mHRTF;
|
||||
}
|
||||
|
||||
private float dBToGain(float gaindB)
|
||||
{
|
||||
const float kMinDBLevel = -90.0f;
|
||||
|
||||
if (gaindB <= kMinDBLevel)
|
||||
return 0.0f;
|
||||
|
||||
return (float) Math.Pow(10.0, (double) gaindB * (1.0 / 20.0));
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/HRTF.cs.meta
Executable file
11
Scripts/Runtime/HRTF.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2676d545429ad5547a1ea3389903271e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
77
Scripts/Runtime/InstancedMesh.cs
Executable file
77
Scripts/Runtime/InstancedMesh.cs
Executable file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class InstancedMesh
|
||||
{
|
||||
IntPtr mInstancedMesh = IntPtr.Zero;
|
||||
|
||||
public InstancedMesh(Scene scene, Scene subScene, Transform transform)
|
||||
{
|
||||
var instancedMeshSettings = new InstancedMeshSettings { };
|
||||
instancedMeshSettings.subScene = subScene.Get();
|
||||
instancedMeshSettings.transform = Common.ConvertTransform(transform);
|
||||
|
||||
var status = API.iplInstancedMeshCreate(scene.Get(), ref instancedMeshSettings, out mInstancedMesh);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create instanced mesh ({0}). [{1}]", transform.gameObject.name, status));
|
||||
}
|
||||
|
||||
public InstancedMesh(InstancedMesh instancedMesh)
|
||||
{
|
||||
mInstancedMesh = API.iplInstancedMeshRetain(instancedMesh.mInstancedMesh);
|
||||
}
|
||||
|
||||
~InstancedMesh()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplInstancedMeshRelease(ref mInstancedMesh);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mInstancedMesh;
|
||||
}
|
||||
|
||||
public void AddToScene(Scene scene)
|
||||
{
|
||||
API.iplInstancedMeshAdd(mInstancedMesh, scene.Get());
|
||||
scene.NotifyAddObject();
|
||||
}
|
||||
|
||||
public void RemoveFromScene(Scene scene)
|
||||
{
|
||||
API.iplInstancedMeshRemove(mInstancedMesh, scene.Get());
|
||||
scene.NotifyRemoveObject();
|
||||
}
|
||||
|
||||
public void UpdateTransform(Scene scene, Transform transform)
|
||||
{
|
||||
API.iplInstancedMeshUpdateTransform(mInstancedMesh, scene.Get(), Common.ConvertTransform(transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/InstancedMesh.cs.meta
Executable file
11
Scripts/Runtime/InstancedMesh.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9b254356f848f34d976c386541ec68b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
94
Scripts/Runtime/OpenCLDevice.cs
Executable file
94
Scripts/Runtime/OpenCLDevice.cs
Executable file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class OpenCLDevice
|
||||
{
|
||||
IntPtr mOpenCLDevice = IntPtr.Zero;
|
||||
|
||||
public OpenCLDevice(Context context, OpenCLDeviceType deviceType, int numCUsToReserve, float fractionCUsForIRUpdate,
|
||||
bool requiresTAN)
|
||||
{
|
||||
var deviceSettings = new OpenCLDeviceSettings { };
|
||||
deviceSettings.type = deviceType;
|
||||
deviceSettings.numCUsToReserve = numCUsToReserve;
|
||||
deviceSettings.fractionCUsForIRUpdate = fractionCUsForIRUpdate;
|
||||
deviceSettings.requiresTAN = requiresTAN ? Bool.True : Bool.False;
|
||||
|
||||
var deviceList = IntPtr.Zero;
|
||||
var status = API.iplOpenCLDeviceListCreate(context.Get(), ref deviceSettings, out deviceList);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to enumerate OpenCL devices. [{0}]", status));
|
||||
|
||||
var numDevices = API.iplOpenCLDeviceListGetNumDevices(deviceList);
|
||||
if (numDevices <= 0)
|
||||
{
|
||||
API.iplOpenCLDeviceListRelease(ref deviceList);
|
||||
|
||||
// If we explicitly requested a device that supports TAN, or if we didn't ask for CU
|
||||
// reservation, but still didn't find any devices, stop.
|
||||
if (requiresTAN || numCUsToReserve == 0)
|
||||
throw new Exception(string.Format("No OpenCL devices found."));
|
||||
|
||||
Debug.LogWarning("No OpenCL devices found that match the provided parameters, attempting to " +
|
||||
"initialize without CU reservation.");
|
||||
|
||||
deviceSettings.numCUsToReserve = 0;
|
||||
deviceSettings.fractionCUsForIRUpdate = 0.0f;
|
||||
status = API.iplOpenCLDeviceListCreate(context.Get(), ref deviceSettings, out deviceList);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to enumerate OpenCL devices. [{0}]", status));
|
||||
|
||||
numDevices = API.iplOpenCLDeviceListGetNumDevices(deviceList);
|
||||
if (numDevices <= 0)
|
||||
throw new Exception(string.Format("No OpenCL devices found."));
|
||||
}
|
||||
|
||||
status = API.iplOpenCLDeviceCreate(context.Get(), deviceList, 0, out mOpenCLDevice);
|
||||
if (status != Error.Success)
|
||||
{
|
||||
API.iplOpenCLDeviceListRelease(ref deviceList);
|
||||
throw new Exception(string.Format("Unable to create OpenCL device. [{0}]", status));
|
||||
}
|
||||
|
||||
API.iplOpenCLDeviceListRelease(ref deviceList);
|
||||
}
|
||||
|
||||
public OpenCLDevice(OpenCLDevice device)
|
||||
{
|
||||
mOpenCLDevice = API.iplOpenCLDeviceRetain(device.mOpenCLDevice);
|
||||
}
|
||||
|
||||
~OpenCLDevice()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplOpenCLDeviceRelease(ref mOpenCLDevice);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mOpenCLDevice;
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/OpenCLDevice.cs.meta
Executable file
11
Scripts/Runtime/OpenCLDevice.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 980da0934e6939d439f50baac22a5286
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
151
Scripts/Runtime/ProbeBatch.cs
Executable file
151
Scripts/Runtime/ProbeBatch.cs
Executable file
@ -0,0 +1,151 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class ProbeArray
|
||||
{
|
||||
IntPtr mProbeArray = IntPtr.Zero;
|
||||
|
||||
public ProbeArray(Context context)
|
||||
{
|
||||
API.iplProbeArrayCreate(context.Get(), out mProbeArray);
|
||||
}
|
||||
|
||||
public ProbeArray(ProbeArray probeArray)
|
||||
{
|
||||
mProbeArray = API.iplProbeArrayRetain(probeArray.mProbeArray);
|
||||
}
|
||||
|
||||
~ProbeArray()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplProbeArrayRelease(ref mProbeArray);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mProbeArray;
|
||||
}
|
||||
|
||||
public void GenerateProbes(Scene scene, ProbeGenerationParams probeGenerationParams)
|
||||
{
|
||||
API.iplProbeArrayGenerateProbes(mProbeArray, scene.Get(), ref probeGenerationParams);
|
||||
}
|
||||
|
||||
public int GetNumProbes()
|
||||
{
|
||||
return API.iplProbeArrayGetNumProbes(mProbeArray);
|
||||
}
|
||||
|
||||
public Sphere GetProbe(int index)
|
||||
{
|
||||
return API.iplProbeArrayGetProbe(mProbeArray, index);
|
||||
}
|
||||
}
|
||||
|
||||
public class ProbeBatch
|
||||
{
|
||||
Context mContext = null;
|
||||
IntPtr mProbeBatch = IntPtr.Zero;
|
||||
|
||||
public ProbeBatch(Context context)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
API.iplProbeBatchCreate(context.Get(), out mProbeBatch);
|
||||
}
|
||||
|
||||
public ProbeBatch(Context context, SerializedData dataAsset)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
var serializedObject = new SerializedObject(context, dataAsset);
|
||||
|
||||
var status = API.iplProbeBatchLoad(context.Get(), serializedObject.Get(), out mProbeBatch);
|
||||
if (status != Error.Success)
|
||||
{
|
||||
Debug.LogError(string.Format("Unable to load Probe Batch from {0}.", dataAsset.name));
|
||||
mProbeBatch = IntPtr.Zero;
|
||||
}
|
||||
|
||||
serializedObject.Release();
|
||||
}
|
||||
|
||||
public ProbeBatch(ProbeBatch probeBatch)
|
||||
{
|
||||
mContext = probeBatch.mContext;
|
||||
|
||||
mProbeBatch = API.iplProbeBatchRetain(probeBatch.mProbeBatch);
|
||||
}
|
||||
|
||||
~ProbeBatch()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplProbeBatchRelease(ref mProbeBatch);
|
||||
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mProbeBatch;
|
||||
}
|
||||
|
||||
public int Save(SerializedData dataAsset, bool flush = true)
|
||||
{
|
||||
var serializedObject = new SerializedObject(mContext);
|
||||
API.iplProbeBatchSave(mProbeBatch, serializedObject.Get());
|
||||
var size = (int) serializedObject.GetSize();
|
||||
serializedObject.WriteToFile(dataAsset, flush);
|
||||
serializedObject.Release();
|
||||
return size;
|
||||
}
|
||||
|
||||
public void AddProbeArray(ProbeArray probeArray)
|
||||
{
|
||||
API.iplProbeBatchAddProbeArray(mProbeBatch, probeArray.Get());
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
API.iplProbeBatchCommit(mProbeBatch);
|
||||
}
|
||||
|
||||
public void RemoveData(BakedDataIdentifier identifier)
|
||||
{
|
||||
API.iplProbeBatchRemoveData(mProbeBatch, ref identifier);
|
||||
}
|
||||
|
||||
public UIntPtr GetDataSize(BakedDataIdentifier identifier)
|
||||
{
|
||||
return API.iplProbeBatchGetDataSize(mProbeBatch, ref identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Scripts/Runtime/ProbeBatch.cs.meta
Executable file
11
Scripts/Runtime/ProbeBatch.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63ee2a9f8d2a86043bb79036d010ee2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Scripts/Runtime/RadeonRaysDevice.cs
Executable file
54
Scripts/Runtime/RadeonRaysDevice.cs
Executable file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class RadeonRaysDevice
|
||||
{
|
||||
IntPtr mRadeonRaysDevice = IntPtr.Zero;
|
||||
|
||||
public RadeonRaysDevice(OpenCLDevice openCLDevice)
|
||||
{
|
||||
var deviceSettings = new RadeonRaysDeviceSettings { };
|
||||
|
||||
var status = API.iplRadeonRaysDeviceCreate(openCLDevice.Get(), ref deviceSettings, out mRadeonRaysDevice);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create Radeon Rays device. [{0}]", status));
|
||||
}
|
||||
|
||||
public RadeonRaysDevice(RadeonRaysDevice device)
|
||||
{
|
||||
mRadeonRaysDevice = API.iplRadeonRaysDeviceRetain(device.mRadeonRaysDevice);
|
||||
}
|
||||
|
||||
~RadeonRaysDevice()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplRadeonRaysDeviceRelease(ref mRadeonRaysDevice);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mRadeonRaysDevice;
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/RadeonRaysDevice.cs.meta
Executable file
11
Scripts/Runtime/RadeonRaysDevice.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab45c0e4ff6a2c445843d2133d90ce2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Scripts/Runtime/SOFAFile.cs
Executable file
38
Scripts/Runtime/SOFAFile.cs
Executable file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
/*
|
||||
* Represents a serializable object that is created when importing a .sofa file as an asset.
|
||||
*/
|
||||
public class SOFAFile : ScriptableObject
|
||||
{
|
||||
// The name of the sofa file that was imported.
|
||||
public string sofaName = "";
|
||||
|
||||
// The imported data.
|
||||
public byte[] data = null;
|
||||
|
||||
// The volume correction factor in dB.
|
||||
public float volume = 0.0f;
|
||||
|
||||
// Volume normalization type.
|
||||
public HRTFNormType normType = HRTFNormType.None;
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SOFAFile.cs.meta
Executable file
11
Scripts/Runtime/SOFAFile.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c07f8c30ab6b2bb4380f1a4429dd557a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
114
Scripts/Runtime/Scene.cs
Executable file
114
Scripts/Runtime/Scene.cs
Executable file
@ -0,0 +1,114 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class Scene
|
||||
{
|
||||
Context mContext = null;
|
||||
IntPtr mScene = IntPtr.Zero;
|
||||
int mNumObjects = 0;
|
||||
|
||||
public Scene(Context context, SceneType type, EmbreeDevice embreeDevice, RadeonRaysDevice radeonRaysDevice, ClosestHitCallback closestHitCallback, AnyHitCallback anyHitCallback)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
var sceneSettings = new SceneSettings { };
|
||||
sceneSettings.type = type;
|
||||
sceneSettings.embreeDevice = (embreeDevice != null) ? embreeDevice.Get() : IntPtr.Zero;
|
||||
sceneSettings.radeonRaysDevice = (radeonRaysDevice != null) ? radeonRaysDevice.Get() : IntPtr.Zero;
|
||||
sceneSettings.closestHitCallback = closestHitCallback;
|
||||
sceneSettings.anyHitCallback = anyHitCallback;
|
||||
|
||||
var status = API.iplSceneCreate(context.Get(), ref sceneSettings, out mScene);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create scene [{0}]", status.ToString()));
|
||||
}
|
||||
|
||||
public Scene(Context context, SceneSettings sceneSettings, SerializedData dataAsset)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
var serializedObject = new SerializedObject(context, dataAsset);
|
||||
var status = API.iplSceneLoad(context.Get(), ref sceneSettings, serializedObject.Get(), null, IntPtr.Zero, out mScene);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to load scene [{0}]", status.ToString()));
|
||||
|
||||
serializedObject.Release();
|
||||
}
|
||||
|
||||
public Scene(Scene scene)
|
||||
{
|
||||
mContext = scene.mContext;
|
||||
|
||||
mScene = API.iplSceneRetain(scene.mScene);
|
||||
}
|
||||
|
||||
~Scene()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplSceneRelease(ref mScene);
|
||||
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mScene;
|
||||
}
|
||||
|
||||
public void Save(SerializedData dataAsset)
|
||||
{
|
||||
var serializedObject = new SerializedObject(mContext);
|
||||
API.iplSceneSave(mScene, serializedObject.Get());
|
||||
serializedObject.WriteToFile(dataAsset);
|
||||
serializedObject.Release();
|
||||
}
|
||||
|
||||
public void SaveOBJ(string fileBaseName)
|
||||
{
|
||||
API.iplSceneSaveOBJ(mScene, fileBaseName);
|
||||
}
|
||||
|
||||
public void NotifyAddObject()
|
||||
{
|
||||
++mNumObjects;
|
||||
}
|
||||
|
||||
public void NotifyRemoveObject()
|
||||
{
|
||||
--mNumObjects;
|
||||
}
|
||||
|
||||
public int GetNumObjects()
|
||||
{
|
||||
return mNumObjects;
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
API.iplSceneCommit(mScene);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Scripts/Runtime/Scene.cs.meta
Executable file
11
Scripts/Runtime/Scene.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f36118f1552c924438a563f1eba9832d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Scripts/Runtime/SerializedData.cs
Executable file
45
Scripts/Runtime/SerializedData.cs
Executable file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class SerializedData : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
public byte[] data;
|
||||
|
||||
public static SerializedData PromptForNewAsset(string defaultFileName)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var fileName = EditorUtility.SaveFilePanelInProject("Export", defaultFileName, "asset",
|
||||
"Select a file to export data to.");
|
||||
|
||||
if (fileName != null && fileName.Length > 0)
|
||||
{
|
||||
var dataAsset = ScriptableObject.CreateInstance<SerializedData>();
|
||||
AssetDatabase.CreateAsset(dataAsset, fileName);
|
||||
return dataAsset;
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SerializedData.cs.meta
Executable file
11
Scripts/Runtime/SerializedData.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a82078fb50fbcb46a7e4402721b1a31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
141
Scripts/Runtime/SerializedObject.cs
Executable file
141
Scripts/Runtime/SerializedObject.cs
Executable file
@ -0,0 +1,141 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class SerializedObject
|
||||
{
|
||||
IntPtr mSerializedObject = IntPtr.Zero;
|
||||
IntPtr mDataBuffer = IntPtr.Zero;
|
||||
|
||||
static List<SerializedData> sAssetsToFlush = null;
|
||||
|
||||
public SerializedObject(Context context)
|
||||
{
|
||||
var serializedObjectSettings = new SerializedObjectSettings { };
|
||||
|
||||
API.iplSerializedObjectCreate(context.Get(), ref serializedObjectSettings, out mSerializedObject);
|
||||
}
|
||||
|
||||
public SerializedObject(Context context, SerializedData dataAsset)
|
||||
{
|
||||
var data = dataAsset.data;
|
||||
mDataBuffer = Marshal.AllocHGlobal(data.Length);
|
||||
|
||||
Marshal.Copy(data, 0, mDataBuffer, data.Length);
|
||||
|
||||
var serializedObjectSettings = new SerializedObjectSettings { };
|
||||
serializedObjectSettings.data = mDataBuffer;
|
||||
serializedObjectSettings.size = (UIntPtr) data.Length;
|
||||
|
||||
API.iplSerializedObjectCreate(context.Get(), ref serializedObjectSettings, out mSerializedObject);
|
||||
}
|
||||
|
||||
public SerializedObject(SerializedObject serializedObject)
|
||||
{
|
||||
mSerializedObject = API.iplSerializedObjectRetain(serializedObject.Get());
|
||||
}
|
||||
|
||||
~SerializedObject()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
if (mDataBuffer != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(mDataBuffer);
|
||||
mDataBuffer = IntPtr.Zero;
|
||||
}
|
||||
|
||||
API.iplSerializedObjectRelease(ref mSerializedObject);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mSerializedObject;
|
||||
}
|
||||
|
||||
public UIntPtr GetSize()
|
||||
{
|
||||
return API.iplSerializedObjectGetSize(mSerializedObject);
|
||||
}
|
||||
|
||||
public IntPtr GetData()
|
||||
{
|
||||
return API.iplSerializedObjectGetData(mSerializedObject);
|
||||
}
|
||||
|
||||
public void WriteToFile(SerializedData dataAsset, bool flush = true)
|
||||
{
|
||||
var dataSize = GetSize();
|
||||
var dataBuffer = GetData();
|
||||
|
||||
dataAsset.data = new byte[(int) dataSize];
|
||||
Marshal.Copy(dataBuffer, dataAsset.data, 0, (int) dataSize);
|
||||
|
||||
if (flush)
|
||||
{
|
||||
FlushWrite(dataAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sAssetsToFlush == null)
|
||||
{
|
||||
sAssetsToFlush = new List<SerializedData>();
|
||||
}
|
||||
|
||||
sAssetsToFlush.Add(dataAsset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FlushWrite(SerializedData dataAsset)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var assetPaths = new string[1];
|
||||
assetPaths[0] = AssetDatabase.GetAssetPath(dataAsset);
|
||||
|
||||
// TODO: Deprecate older versions of Unity.
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
AssetDatabase.ForceReserializeAssets(assetPaths);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void FlushAllWrites()
|
||||
{
|
||||
if (sAssetsToFlush == null)
|
||||
return;
|
||||
|
||||
foreach (var dataAsset in sAssetsToFlush)
|
||||
{
|
||||
FlushWrite(dataAsset);
|
||||
}
|
||||
|
||||
sAssetsToFlush.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Scripts/Runtime/SerializedObject.cs.meta
Executable file
11
Scripts/Runtime/SerializedObject.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e71666981c49a64e98ee2cbd2726952
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
152
Scripts/Runtime/Simulator.cs
Executable file
152
Scripts/Runtime/Simulator.cs
Executable file
@ -0,0 +1,152 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class Simulator
|
||||
{
|
||||
IntPtr mSimulator = IntPtr.Zero;
|
||||
|
||||
public Simulator(Context context, SimulationSettings simulationSettings)
|
||||
{
|
||||
var status = API.iplSimulatorCreate(context.Get(), ref simulationSettings, out mSimulator);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create simulator. [{0}]", status));
|
||||
}
|
||||
|
||||
public Simulator(Simulator simulator)
|
||||
{
|
||||
mSimulator = API.iplSimulatorRetain(simulator.mSimulator);
|
||||
}
|
||||
|
||||
~Simulator()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplSimulatorRelease(ref mSimulator);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mSimulator;
|
||||
}
|
||||
|
||||
public void SetScene(Scene scene)
|
||||
{
|
||||
API.iplSimulatorSetScene(mSimulator, scene.Get());
|
||||
}
|
||||
|
||||
public void AddProbeBatch(ProbeBatch probeBatch)
|
||||
{
|
||||
API.iplSimulatorAddProbeBatch(mSimulator, probeBatch.Get());
|
||||
}
|
||||
|
||||
public void RemoveProbeBatch(ProbeBatch probeBatch)
|
||||
{
|
||||
API.iplSimulatorRemoveProbeBatch(mSimulator, probeBatch.Get());
|
||||
}
|
||||
|
||||
public void SetSharedInputs(SimulationFlags flags, SimulationSharedInputs sharedInputs)
|
||||
{
|
||||
API.iplSimulatorSetSharedInputs(mSimulator, flags, ref sharedInputs);
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
API.iplSimulatorCommit(mSimulator);
|
||||
}
|
||||
|
||||
public void RunDirect()
|
||||
{
|
||||
API.iplSimulatorRunDirect(mSimulator);
|
||||
}
|
||||
|
||||
public void RunReflections()
|
||||
{
|
||||
API.iplSimulatorRunReflections(mSimulator);
|
||||
}
|
||||
|
||||
public void RunPathing()
|
||||
{
|
||||
API.iplSimulatorRunPathing(mSimulator);
|
||||
}
|
||||
}
|
||||
|
||||
public class Source
|
||||
{
|
||||
IntPtr mSource = IntPtr.Zero;
|
||||
|
||||
public Source(Simulator simulator, SimulationSettings simulationSettings)
|
||||
{
|
||||
var sourceSettings = new SourceSettings { };
|
||||
sourceSettings.flags = simulationSettings.flags;
|
||||
|
||||
var status = API.iplSourceCreate(simulator.Get(), ref sourceSettings, out mSource);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to create source for simulation. [{0}]", status));
|
||||
}
|
||||
|
||||
public Source(Source source)
|
||||
{
|
||||
mSource = API.iplSourceRetain(source.mSource);
|
||||
}
|
||||
|
||||
~Source()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplSourceRelease(ref mSource);
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mSource;
|
||||
}
|
||||
|
||||
public void AddToSimulator(Simulator simulator)
|
||||
{
|
||||
API.iplSourceAdd(mSource, simulator.Get());
|
||||
}
|
||||
|
||||
public void RemoveFromSimulator(Simulator simulator)
|
||||
{
|
||||
API.iplSourceRemove(mSource, simulator.Get());
|
||||
}
|
||||
|
||||
public void SetInputs(SimulationFlags flags, SimulationInputs inputs)
|
||||
{
|
||||
API.iplSourceSetInputs(mSource, flags, ref inputs);
|
||||
}
|
||||
|
||||
public SimulationOutputs GetOutputs(SimulationFlags flags)
|
||||
{
|
||||
var outputs = new SimulationOutputs { };
|
||||
API.iplSourceGetOutputs(mSource, flags, ref outputs);
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Scripts/Runtime/Simulator.cs.meta
Executable file
11
Scripts/Runtime/Simulator.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59c8ab9b6583fd541bae96e7d56ad808
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
136
Scripts/Runtime/StaticMesh.cs
Executable file
136
Scripts/Runtime/StaticMesh.cs
Executable file
@ -0,0 +1,136 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#if STEAMAUDIO_ENABLED
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public class StaticMesh
|
||||
{
|
||||
Context mContext = null;
|
||||
IntPtr mStaticMesh = IntPtr.Zero;
|
||||
|
||||
public StaticMesh(Context context, Scene scene, Vector3[] vertices, Triangle[] triangles, int[] materialIndices, Material[] materials)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
var verticesBuffer = Marshal.AllocHGlobal(vertices.Length * Marshal.SizeOf(typeof(Vector3)));
|
||||
var trianglesBuffer = Marshal.AllocHGlobal(triangles.Length * Marshal.SizeOf(typeof(Triangle)));
|
||||
var materialIndicesBuffer = Marshal.AllocHGlobal(materialIndices.Length * Marshal.SizeOf(typeof(int)));
|
||||
var materialsBuffer = Marshal.AllocHGlobal(materials.Length * Marshal.SizeOf(typeof(Material)));
|
||||
|
||||
for (var i = 0; i < vertices.Length; ++i)
|
||||
{
|
||||
Marshal.StructureToPtr(vertices[i], new IntPtr(verticesBuffer.ToInt64() + i * Marshal.SizeOf(typeof(Vector3))), false);
|
||||
}
|
||||
|
||||
for (var i = 0; i < triangles.Length; ++i)
|
||||
{
|
||||
Marshal.StructureToPtr(triangles[i], new IntPtr(trianglesBuffer.ToInt64() + i * Marshal.SizeOf(typeof(Triangle))), false);
|
||||
}
|
||||
|
||||
Marshal.Copy(materialIndices, 0, materialIndicesBuffer, triangles.Length);
|
||||
|
||||
for (var i = 0; i < materials.Length; ++i)
|
||||
{
|
||||
Marshal.StructureToPtr(materials[i], new IntPtr(materialsBuffer.ToInt64() + i * Marshal.SizeOf(typeof(Material))), false);
|
||||
}
|
||||
|
||||
var staticMeshSettings = new StaticMeshSettings { };
|
||||
staticMeshSettings.numVertices = vertices.Length;
|
||||
staticMeshSettings.numTriangles = triangles.Length;
|
||||
staticMeshSettings.numMaterials = materials.Length;
|
||||
staticMeshSettings.vertices = verticesBuffer;
|
||||
staticMeshSettings.triangles = trianglesBuffer;
|
||||
staticMeshSettings.materialIndices = materialIndicesBuffer;
|
||||
staticMeshSettings.materials = materialsBuffer;
|
||||
|
||||
var status = API.iplStaticMeshCreate(scene.Get(), ref staticMeshSettings, out mStaticMesh);
|
||||
if (status != Error.Success)
|
||||
{
|
||||
throw new Exception(string.Format("Unable to create static mesh for export ({0} vertices, {1} triangles, {2} materials): [{3}]",
|
||||
staticMeshSettings.numVertices.ToString(), staticMeshSettings.numTriangles.ToString(), staticMeshSettings.numMaterials.ToString(),
|
||||
status.ToString()));
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(verticesBuffer);
|
||||
Marshal.FreeHGlobal(trianglesBuffer);
|
||||
Marshal.FreeHGlobal(materialIndicesBuffer);
|
||||
Marshal.FreeHGlobal(materialsBuffer);
|
||||
}
|
||||
|
||||
public StaticMesh(Context context, Scene scene, SerializedData dataAsset)
|
||||
{
|
||||
mContext = context;
|
||||
|
||||
var serializedObject = new SerializedObject(context, dataAsset);
|
||||
|
||||
var status = API.iplStaticMeshLoad(scene.Get(), serializedObject.Get(), null, IntPtr.Zero, out mStaticMesh);
|
||||
if (status != Error.Success)
|
||||
throw new Exception(string.Format("Unable to load static mesh ({0}). [{1}]", dataAsset.name, status));
|
||||
|
||||
serializedObject.Release();
|
||||
}
|
||||
|
||||
public StaticMesh(StaticMesh staticMesh)
|
||||
{
|
||||
mContext = staticMesh.mContext;
|
||||
|
||||
mStaticMesh = API.iplStaticMeshRetain(staticMesh.mStaticMesh);
|
||||
}
|
||||
|
||||
~StaticMesh()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
API.iplStaticMeshRelease(ref mStaticMesh);
|
||||
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
public IntPtr Get()
|
||||
{
|
||||
return mStaticMesh;
|
||||
}
|
||||
|
||||
public void Save(SerializedData dataAsset)
|
||||
{
|
||||
var serializedObject = new SerializedObject(mContext);
|
||||
API.iplStaticMeshSave(mStaticMesh, serializedObject.Get());
|
||||
serializedObject.WriteToFile(dataAsset);
|
||||
serializedObject.Release();
|
||||
}
|
||||
|
||||
public void AddToScene(Scene scene)
|
||||
{
|
||||
API.iplStaticMeshAdd(mStaticMesh, scene.Get());
|
||||
scene.NotifyAddObject();
|
||||
}
|
||||
|
||||
public void RemoveFromScene(Scene scene)
|
||||
{
|
||||
API.iplStaticMeshRemove(mStaticMesh, scene.Get());
|
||||
scene.NotifyRemoveObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Scripts/Runtime/StaticMesh.cs.meta
Executable file
11
Scripts/Runtime/StaticMesh.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 426a41fdb5d8b904fb4b688ed1b1db02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1372
Scripts/Runtime/SteamAudio.cs
Executable file
1372
Scripts/Runtime/SteamAudio.cs
Executable file
File diff suppressed because it is too large
Load Diff
11
Scripts/Runtime/SteamAudio.cs.meta
Executable file
11
Scripts/Runtime/SteamAudio.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faab0996f33b3304faccb7f9f8c48dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Scripts/Runtime/SteamAudioAmbisonicSource.cs
Executable file
74
Scripts/Runtime/SteamAudioAmbisonicSource.cs
Executable file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Ambisonic Source")]
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class SteamAudioAmbisonicSource : MonoBehaviour
|
||||
{
|
||||
[Header("HRTF Settings")]
|
||||
public bool applyHRTF = true;
|
||||
|
||||
AudioEngineAmbisonicSource mAudioEngineAmbisonicSource = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mAudioEngineAmbisonicSource = AudioEngineAmbisonicSource.Create(SteamAudioSettings.Singleton.audioEngine);
|
||||
if (mAudioEngineAmbisonicSource != null)
|
||||
{
|
||||
mAudioEngineAmbisonicSource.Initialize(gameObject);
|
||||
mAudioEngineAmbisonicSource.UpdateParameters(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (mAudioEngineAmbisonicSource != null)
|
||||
{
|
||||
mAudioEngineAmbisonicSource.UpdateParameters(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (mAudioEngineAmbisonicSource != null)
|
||||
{
|
||||
mAudioEngineAmbisonicSource.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (mAudioEngineAmbisonicSource != null)
|
||||
{
|
||||
mAudioEngineAmbisonicSource.UpdateParameters(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (mAudioEngineAmbisonicSource != null)
|
||||
{
|
||||
mAudioEngineAmbisonicSource.UpdateParameters(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioAmbisonicSource.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioAmbisonicSource.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe05866fd4e732246be6461a576ebcb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
150
Scripts/Runtime/SteamAudioBakedListener.cs
Executable file
150
Scripts/Runtime/SteamAudioBakedListener.cs
Executable file
@ -0,0 +1,150 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Baked Listener")]
|
||||
public class SteamAudioBakedListener : MonoBehaviour
|
||||
{
|
||||
[Header("Baked Static Listener Settings")]
|
||||
[Range(0.0f, 1000.0f)]
|
||||
public float influenceRadius = 1000.0f;
|
||||
public bool useAllProbeBatches = false;
|
||||
public SteamAudioProbeBatch[] probeBatches = null;
|
||||
|
||||
[SerializeField]
|
||||
int mTotalDataSize = 0;
|
||||
[SerializeField]
|
||||
int[] mProbeDataSizes = null;
|
||||
[SerializeField]
|
||||
BakedDataIdentifier mIdentifier = new BakedDataIdentifier { };
|
||||
[SerializeField]
|
||||
SteamAudioProbeBatch[] mProbeBatchesUsed = null;
|
||||
|
||||
#if STEAMAUDIO_ENABLED
|
||||
public int GetTotalDataSize()
|
||||
{
|
||||
return mTotalDataSize;
|
||||
}
|
||||
|
||||
public int[] GetProbeDataSizes()
|
||||
{
|
||||
return mProbeDataSizes;
|
||||
}
|
||||
|
||||
public int GetSizeForProbeBatch(int index)
|
||||
{
|
||||
return mProbeDataSizes[index];
|
||||
}
|
||||
|
||||
public SteamAudioProbeBatch[] GetProbeBatchesUsed()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
{
|
||||
CacheProbeBatchesUsed();
|
||||
}
|
||||
|
||||
return mProbeBatchesUsed;
|
||||
}
|
||||
|
||||
public BakedDataIdentifier GetBakedDataIdentifier()
|
||||
{
|
||||
var identifier = new BakedDataIdentifier { };
|
||||
identifier.type = BakedDataType.Reflections;
|
||||
identifier.variation = BakedDataVariation.StaticListener;
|
||||
identifier.endpointInfluence.center = Common.ConvertVector(transform.position);
|
||||
identifier.endpointInfluence.radius = influenceRadius;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
var oldColor = Gizmos.color;
|
||||
var oldMatrix = Gizmos.matrix;
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, influenceRadius);
|
||||
|
||||
Gizmos.color = Color.magenta;
|
||||
|
||||
if (mProbeBatchesUsed != null)
|
||||
{
|
||||
foreach (var probeBatch in mProbeBatchesUsed)
|
||||
{
|
||||
if (probeBatch == null)
|
||||
continue;
|
||||
|
||||
Gizmos.matrix = probeBatch.transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(new UnityEngine.Vector3(0, 0, 0), new UnityEngine.Vector3(1, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
Gizmos.matrix = oldMatrix;
|
||||
Gizmos.color = oldColor;
|
||||
}
|
||||
|
||||
public void UpdateBakedDataStatistics()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
return;
|
||||
|
||||
mProbeDataSizes = new int[mProbeBatchesUsed.Length];
|
||||
mTotalDataSize = 0;
|
||||
|
||||
for (var i = 0; i < mProbeBatchesUsed.Length; ++i)
|
||||
{
|
||||
mProbeDataSizes[i] = mProbeBatchesUsed[i].GetSizeForLayer(mIdentifier);
|
||||
mTotalDataSize += mProbeDataSizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginBake()
|
||||
{
|
||||
CacheIdentifier();
|
||||
CacheProbeBatchesUsed();
|
||||
|
||||
var tasks = new BakedDataTask[1];
|
||||
tasks[0].gameObject = gameObject;
|
||||
tasks[0].component = this;
|
||||
tasks[0].name = gameObject.name;
|
||||
tasks[0].identifier = mIdentifier;
|
||||
tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
tasks[0].probeBatchNames = new string[tasks[0].probeBatches.Length];
|
||||
tasks[0].probeBatchAssets = new SerializedData[tasks[0].probeBatches.Length];
|
||||
for (var i = 0; i < tasks[0].probeBatchNames.Length; ++i)
|
||||
{
|
||||
tasks[0].probeBatchNames[i] = tasks[0].probeBatches[i].gameObject.name;
|
||||
tasks[0].probeBatchAssets[i] = tasks[0].probeBatches[i].GetAsset();
|
||||
}
|
||||
|
||||
Baker.BeginBake(tasks);
|
||||
}
|
||||
|
||||
void CacheIdentifier()
|
||||
{
|
||||
mIdentifier = GetBakedDataIdentifier();
|
||||
}
|
||||
|
||||
void CacheProbeBatchesUsed()
|
||||
{
|
||||
mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioBakedListener.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioBakedListener.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d1a2bdfdee8e5b48a9949c674b73640
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
150
Scripts/Runtime/SteamAudioBakedSource.cs
Executable file
150
Scripts/Runtime/SteamAudioBakedSource.cs
Executable file
@ -0,0 +1,150 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Baked Source")]
|
||||
public class SteamAudioBakedSource : MonoBehaviour
|
||||
{
|
||||
[Header("Baked Static Source Settings")]
|
||||
[Range(0.0f, 1000.0f)]
|
||||
public float influenceRadius = 1000.0f;
|
||||
public bool useAllProbeBatches = false;
|
||||
public SteamAudioProbeBatch[] probeBatches = null;
|
||||
|
||||
[SerializeField]
|
||||
int mTotalDataSize = 0;
|
||||
[SerializeField]
|
||||
int[] mProbeDataSizes = null;
|
||||
[SerializeField]
|
||||
BakedDataIdentifier mIdentifier = new BakedDataIdentifier { };
|
||||
[SerializeField]
|
||||
SteamAudioProbeBatch[] mProbeBatchesUsed = null;
|
||||
|
||||
#if STEAMAUDIO_ENABLED
|
||||
public int GetTotalDataSize()
|
||||
{
|
||||
return mTotalDataSize;
|
||||
}
|
||||
|
||||
public int[] GetProbeDataSizes()
|
||||
{
|
||||
return mProbeDataSizes;
|
||||
}
|
||||
|
||||
public int GetSizeForProbeBatch(int index)
|
||||
{
|
||||
return mProbeDataSizes[index];
|
||||
}
|
||||
|
||||
public SteamAudioProbeBatch[] GetProbeBatchesUsed()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
{
|
||||
CacheProbeBatchesUsed();
|
||||
}
|
||||
|
||||
return mProbeBatchesUsed;
|
||||
}
|
||||
|
||||
public BakedDataIdentifier GetBakedDataIdentifier()
|
||||
{
|
||||
var identifier = new BakedDataIdentifier { };
|
||||
identifier.type = BakedDataType.Reflections;
|
||||
identifier.variation = BakedDataVariation.StaticSource;
|
||||
identifier.endpointInfluence.center = Common.ConvertVector(transform.position);
|
||||
identifier.endpointInfluence.radius = influenceRadius;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
var oldColor = Gizmos.color;
|
||||
var oldMatrix = Gizmos.matrix;
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, influenceRadius);
|
||||
|
||||
Gizmos.color = Color.magenta;
|
||||
|
||||
if (mProbeBatchesUsed != null)
|
||||
{
|
||||
foreach (var probeBatch in mProbeBatchesUsed)
|
||||
{
|
||||
if (probeBatch == null)
|
||||
continue;
|
||||
|
||||
Gizmos.matrix = probeBatch.transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(new UnityEngine.Vector3(0, 0, 0), new UnityEngine.Vector3(1, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
Gizmos.matrix = oldMatrix;
|
||||
Gizmos.color = oldColor;
|
||||
}
|
||||
|
||||
public void UpdateBakedDataStatistics()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
return;
|
||||
|
||||
mProbeDataSizes = new int[mProbeBatchesUsed.Length];
|
||||
mTotalDataSize = 0;
|
||||
|
||||
for (var i = 0; i < mProbeBatchesUsed.Length; ++i)
|
||||
{
|
||||
mProbeDataSizes[i] = mProbeBatchesUsed[i].GetSizeForLayer(mIdentifier);
|
||||
mTotalDataSize += mProbeDataSizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginBake()
|
||||
{
|
||||
CacheIdentifier();
|
||||
CacheProbeBatchesUsed();
|
||||
|
||||
var tasks = new BakedDataTask[1];
|
||||
tasks[0].gameObject = gameObject;
|
||||
tasks[0].component = this;
|
||||
tasks[0].name = gameObject.name;
|
||||
tasks[0].identifier = mIdentifier;
|
||||
tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
tasks[0].probeBatchNames = new string[tasks[0].probeBatches.Length];
|
||||
tasks[0].probeBatchAssets = new SerializedData[tasks[0].probeBatches.Length];
|
||||
for (var i = 0; i < tasks[0].probeBatchNames.Length; ++i)
|
||||
{
|
||||
tasks[0].probeBatchNames[i] = tasks[0].probeBatches[i].gameObject.name;
|
||||
tasks[0].probeBatchAssets[i] = tasks[0].probeBatches[i].GetAsset();
|
||||
}
|
||||
|
||||
Baker.BeginBake(tasks);
|
||||
}
|
||||
|
||||
void CacheIdentifier()
|
||||
{
|
||||
mIdentifier = GetBakedDataIdentifier();
|
||||
}
|
||||
|
||||
void CacheProbeBatchesUsed()
|
||||
{
|
||||
mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioBakedSource.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioBakedSource.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ea378497d2d9e847898c57b9eb3fb94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
82
Scripts/Runtime/SteamAudioDynamicObject.cs
Executable file
82
Scripts/Runtime/SteamAudioDynamicObject.cs
Executable file
@ -0,0 +1,82 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Dynamic Object")]
|
||||
public class SteamAudioDynamicObject : MonoBehaviour
|
||||
{
|
||||
[Header("Export Settings")]
|
||||
public SerializedData asset = null;
|
||||
|
||||
#if STEAMAUDIO_ENABLED
|
||||
InstancedMesh mInstancedMesh = null;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
SteamAudioManager.UnloadDynamicObject(this);
|
||||
|
||||
if (mInstancedMesh != null)
|
||||
{
|
||||
mInstancedMesh.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (mInstancedMesh != null)
|
||||
{
|
||||
mInstancedMesh.AddToScene(SteamAudioManager.CurrentScene);
|
||||
SteamAudioManager.ScheduleCommitScene();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (mInstancedMesh != null && SteamAudioManager.CurrentScene != null)
|
||||
{
|
||||
mInstancedMesh.RemoveFromScene(SteamAudioManager.CurrentScene);
|
||||
SteamAudioManager.ScheduleCommitScene();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (mInstancedMesh == null && asset != null)
|
||||
{
|
||||
mInstancedMesh = SteamAudioManager.LoadDynamicObject(this, SteamAudioManager.CurrentScene, SteamAudioManager.Context);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
mInstancedMesh.AddToScene(SteamAudioManager.CurrentScene);
|
||||
SteamAudioManager.ScheduleCommitScene();
|
||||
}
|
||||
}
|
||||
|
||||
// Only update the dynamic object if it has actually move this frame
|
||||
if (transform.hasChanged)
|
||||
{
|
||||
mInstancedMesh.UpdateTransform(SteamAudioManager.CurrentScene, transform);
|
||||
SteamAudioManager.ScheduleCommitScene();
|
||||
transform.hasChanged = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioDynamicObject.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioDynamicObject.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fb43d10a308b2f46ad4561774f97e52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
76
Scripts/Runtime/SteamAudioFMODStudio.cs
Executable file
76
Scripts/Runtime/SteamAudioFMODStudio.cs
Executable file
@ -0,0 +1,76 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public static class FMODStudioAPI
|
||||
{
|
||||
// FMOD STUDIO PLUGIN
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODInitialize(IntPtr context);
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODSetHRTF(IntPtr hrtf);
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODSetSimulationSettings(SimulationSettings simulationSettings);
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODSetReverbSource(IntPtr reverbSource);
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODTerminate();
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern int iplFMODAddSource(IntPtr source);
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
#else
|
||||
[DllImport("phonon_fmod")]
|
||||
#endif
|
||||
public static extern void iplFMODRemoveSource(int handle);
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioFMODStudio.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioFMODStudio.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 910b4010d4f5f4c388938e56f9715f37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Scripts/Runtime/SteamAudioGeometry.cs
Executable file
74
Scripts/Runtime/SteamAudioGeometry.cs
Executable file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Geometry")]
|
||||
public class SteamAudioGeometry : MonoBehaviour
|
||||
{
|
||||
[Header("Material Settings")]
|
||||
public SteamAudioMaterial material = null;
|
||||
[Header("Export Settings")]
|
||||
public bool exportAllChildren = false;
|
||||
[Header("Terrain Settings")]
|
||||
[Range(0, 10)]
|
||||
public int terrainSimplificationLevel = 0;
|
||||
|
||||
#if STEAMAUDIO_ENABLED
|
||||
public int GetNumVertices()
|
||||
{
|
||||
if (exportAllChildren)
|
||||
{
|
||||
var objects = SteamAudioManager.GetGameObjectsForExport(gameObject);
|
||||
|
||||
var numVertices = 0;
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
numVertices += SteamAudioManager.GetNumVertices(obj);
|
||||
}
|
||||
|
||||
return numVertices;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SteamAudioManager.GetNumVertices(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNumTriangles()
|
||||
{
|
||||
if (exportAllChildren)
|
||||
{
|
||||
var objects = SteamAudioManager.GetGameObjectsForExport(gameObject);
|
||||
|
||||
var numTriangles = 0;
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
numTriangles += SteamAudioManager.GetNumTriangles(obj);
|
||||
}
|
||||
|
||||
return numTriangles;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SteamAudioManager.GetNumTriangles(gameObject);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
12
Scripts/Runtime/SteamAudioGeometry.cs.meta
Executable file
12
Scripts/Runtime/SteamAudioGeometry.cs.meta
Executable file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e829c87dc2a2ed2419c5f67848317fe4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- material: {fileID: 11400000, guid: a086f686223eed942816c70be67841b0, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
247
Scripts/Runtime/SteamAudioListener.cs
Executable file
247
Scripts/Runtime/SteamAudioListener.cs
Executable file
@ -0,0 +1,247 @@
|
||||
//
|
||||
// Copyright 2017-2023 Valve Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SteamAudio
|
||||
{
|
||||
public enum ReverbType
|
||||
{
|
||||
Realtime,
|
||||
Baked
|
||||
}
|
||||
|
||||
[AddComponentMenu("Steam Audio/Steam Audio Listener")]
|
||||
public class SteamAudioListener : MonoBehaviour
|
||||
{
|
||||
[Header("Baked Static Listener Settings")]
|
||||
public SteamAudioBakedListener currentBakedListener = null;
|
||||
|
||||
[Header("Reverb Settings")]
|
||||
public bool applyReverb = false;
|
||||
public ReverbType reverbType = ReverbType.Realtime;
|
||||
|
||||
[Header("Baked Reverb Settings")]
|
||||
public bool useAllProbeBatches = false;
|
||||
public SteamAudioProbeBatch[] probeBatches = null;
|
||||
|
||||
[SerializeField]
|
||||
int mTotalDataSize = 0;
|
||||
[SerializeField]
|
||||
int[] mProbeDataSizes = null;
|
||||
[SerializeField]
|
||||
BakedDataIdentifier mIdentifier = new BakedDataIdentifier { };
|
||||
[SerializeField]
|
||||
SteamAudioProbeBatch[] mProbeBatchesUsed = null;
|
||||
|
||||
#if STEAMAUDIO_ENABLED
|
||||
Simulator mSimulator = null;
|
||||
Source mSource = null;
|
||||
|
||||
public int GetTotalDataSize()
|
||||
{
|
||||
return mTotalDataSize;
|
||||
}
|
||||
|
||||
public int[] GetProbeDataSizes()
|
||||
{
|
||||
return mProbeDataSizes;
|
||||
}
|
||||
|
||||
public int GetSizeForProbeBatch(int index)
|
||||
{
|
||||
return mProbeDataSizes[index];
|
||||
}
|
||||
|
||||
public SteamAudioProbeBatch[] GetProbeBatchesUsed()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
{
|
||||
CacheProbeBatchesUsed();
|
||||
}
|
||||
|
||||
return mProbeBatchesUsed;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Reinitialize();
|
||||
}
|
||||
|
||||
public void Reinitialize()
|
||||
{
|
||||
mSimulator = SteamAudioManager.Simulator;
|
||||
|
||||
var settings = SteamAudioManager.GetSimulationSettings(false);
|
||||
mSource = new Source(SteamAudioManager.Simulator, settings);
|
||||
|
||||
SteamAudioManager.GetAudioEngineState().SetReverbSource(mSource);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (mSource != null)
|
||||
{
|
||||
mSource.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SteamAudioManager.GetAudioEngineState().SetReverbSource(mSource);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (applyReverb)
|
||||
{
|
||||
mSource.AddToSimulator(mSimulator);
|
||||
SteamAudioManager.AddListener(this);
|
||||
SteamAudioManager.GetAudioEngineState().SetReverbSource(mSource);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (applyReverb)
|
||||
{
|
||||
SteamAudioManager.RemoveListener(this);
|
||||
mSource.RemoveFromSimulator(mSimulator);
|
||||
SteamAudioManager.GetAudioEngineState().SetReverbSource(mSource);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SteamAudioManager.GetAudioEngineState().SetReverbSource(mSource);
|
||||
}
|
||||
|
||||
public BakedDataIdentifier GetBakedDataIdentifier()
|
||||
{
|
||||
var identifier = new BakedDataIdentifier { };
|
||||
identifier.type = BakedDataType.Reflections;
|
||||
identifier.variation = BakedDataVariation.Reverb;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void SetInputs(SimulationFlags flags)
|
||||
{
|
||||
var inputs = new SimulationInputs { };
|
||||
inputs.source.origin = Common.ConvertVector(transform.position);
|
||||
inputs.source.ahead = Common.ConvertVector(transform.forward);
|
||||
inputs.source.up = Common.ConvertVector(transform.up);
|
||||
inputs.source.right = Common.ConvertVector(transform.right);
|
||||
inputs.distanceAttenuationModel.type = DistanceAttenuationModelType.Default;
|
||||
inputs.airAbsorptionModel.type = AirAbsorptionModelType.Default;
|
||||
inputs.reverbScaleLow = 1.0f;
|
||||
inputs.reverbScaleMid = 1.0f;
|
||||
inputs.reverbScaleHigh = 1.0f;
|
||||
inputs.hybridReverbTransitionTime = SteamAudioSettings.Singleton.hybridReverbTransitionTime;
|
||||
inputs.hybridReverbOverlapPercent = SteamAudioSettings.Singleton.hybridReverbOverlapPercent / 100.0f;
|
||||
inputs.baked = (reverbType != ReverbType.Realtime) ? Bool.True : Bool.False;
|
||||
if (reverbType == ReverbType.Baked)
|
||||
{
|
||||
inputs.bakedDataIdentifier = GetBakedDataIdentifier();
|
||||
}
|
||||
|
||||
inputs.flags = 0;
|
||||
if (applyReverb)
|
||||
{
|
||||
inputs.flags = inputs.flags | SimulationFlags.Reflections;
|
||||
}
|
||||
|
||||
inputs.directFlags = 0;
|
||||
|
||||
mSource.SetInputs(flags, inputs);
|
||||
}
|
||||
|
||||
public void UpdateOutputs(SimulationFlags flags)
|
||||
{}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
var oldColor = Gizmos.color;
|
||||
var oldMatrix = Gizmos.matrix;
|
||||
|
||||
Gizmos.color = Color.magenta;
|
||||
|
||||
if (mProbeBatchesUsed != null)
|
||||
{
|
||||
foreach (var probeBatch in mProbeBatchesUsed)
|
||||
{
|
||||
if (probeBatch == null)
|
||||
continue;
|
||||
|
||||
Gizmos.matrix = probeBatch.transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(new UnityEngine.Vector3(0, 0, 0), new UnityEngine.Vector3(1, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
Gizmos.matrix = oldMatrix;
|
||||
Gizmos.color = oldColor;
|
||||
}
|
||||
|
||||
public void UpdateBakedDataStatistics()
|
||||
{
|
||||
if (mProbeBatchesUsed == null)
|
||||
return;
|
||||
|
||||
mProbeDataSizes = new int[mProbeBatchesUsed.Length];
|
||||
mTotalDataSize = 0;
|
||||
|
||||
for (var i = 0; i < mProbeBatchesUsed.Length; ++i)
|
||||
{
|
||||
mProbeDataSizes[i] = mProbeBatchesUsed[i].GetSizeForLayer(mIdentifier);
|
||||
mTotalDataSize += mProbeDataSizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginBake()
|
||||
{
|
||||
CacheIdentifier();
|
||||
CacheProbeBatchesUsed();
|
||||
|
||||
var tasks = new BakedDataTask[1];
|
||||
tasks[0].gameObject = gameObject;
|
||||
tasks[0].component = this;
|
||||
tasks[0].name = "Reverb";
|
||||
tasks[0].identifier = mIdentifier;
|
||||
tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
tasks[0].probeBatchNames = new string[tasks[0].probeBatches.Length];
|
||||
tasks[0].probeBatchAssets = new SerializedData[tasks[0].probeBatches.Length];
|
||||
for (var i = 0; i < tasks[0].probeBatchNames.Length; ++i)
|
||||
{
|
||||
tasks[0].probeBatchNames[i] = tasks[0].probeBatches[i].gameObject.name;
|
||||
tasks[0].probeBatchAssets[i] = tasks[0].probeBatches[i].GetAsset();
|
||||
}
|
||||
|
||||
Baker.BeginBake(tasks);
|
||||
}
|
||||
|
||||
void CacheIdentifier()
|
||||
{
|
||||
mIdentifier.type = BakedDataType.Reflections;
|
||||
mIdentifier.variation = BakedDataVariation.Reverb;
|
||||
}
|
||||
|
||||
void CacheProbeBatchesUsed()
|
||||
{
|
||||
mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsOfType<SteamAudioProbeBatch>() : probeBatches;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Scripts/Runtime/SteamAudioListener.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioListener.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fd9ebf1401392e4bbd47fea32f47642
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2059
Scripts/Runtime/SteamAudioManager.cs
Executable file
2059
Scripts/Runtime/SteamAudioManager.cs
Executable file
File diff suppressed because it is too large
Load Diff
11
Scripts/Runtime/SteamAudioManager.cs.meta
Executable file
11
Scripts/Runtime/SteamAudioManager.cs.meta
Executable file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b11066ff95bbf3344b868394742f7002
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user