Init
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using PXR_Audio.Spatializer;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PXR_Audio_Spatializer_AudioSource))]
|
||||
[CanEditMultipleObjects]
|
||||
public class PXR_Audio_Spatializer_AudioSourceEditor : Editor
|
||||
{
|
||||
private SerializedProperty sourceGainDBProperty;
|
||||
private SerializedProperty reflectionGainDBProperty;
|
||||
private SerializedProperty sourceSizeProperty;
|
||||
private SerializedProperty enableDopplerProperty;
|
||||
private SerializedProperty sourceAttenuationModeProperty;
|
||||
private SerializedProperty minAttenuationDistanceProperty;
|
||||
private SerializedProperty maxAttenuationDistanceProperty;
|
||||
private SerializedProperty directivityAlphaProperty;
|
||||
private SerializedProperty directivityOrderProperty;
|
||||
|
||||
private bool showAdvancedOptions = false;
|
||||
private bool showDirectivityOptions = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
sourceGainDBProperty = serializedObject.FindProperty("sourceGainDB");
|
||||
reflectionGainDBProperty = serializedObject.FindProperty("reflectionGainDB");
|
||||
sourceSizeProperty = serializedObject.FindProperty("sourceSize");
|
||||
enableDopplerProperty = serializedObject.FindProperty("enableDoppler");
|
||||
sourceAttenuationModeProperty = serializedObject.FindProperty("sourceAttenuationMode");
|
||||
minAttenuationDistanceProperty = serializedObject.FindProperty("minAttenuationDistance");
|
||||
maxAttenuationDistanceProperty = serializedObject.FindProperty("maxAttenuationDistance");
|
||||
directivityAlphaProperty = serializedObject.FindProperty("directivityAlpha");
|
||||
directivityOrderProperty = serializedObject.FindProperty("directivityOrder");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(sourceGainDBProperty,
|
||||
new GUIContent("Source Gain (dB)", "Master gain of this sound source in dBFS"));
|
||||
EditorGUILayout.PropertyField(reflectionGainDBProperty,
|
||||
new GUIContent("Reflection Gain (dB)", "Gain of the reflection sound of this sound source in dBFS"));
|
||||
EditorGUILayout.PropertyField(sourceSizeProperty,
|
||||
new GUIContent("Source Size (meters)", "Volumetric radius of this sound source in meters"));
|
||||
|
||||
showAdvancedOptions = EditorGUILayout.Foldout(showAdvancedOptions, "Advanced Options");
|
||||
if (showAdvancedOptions)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(enableDopplerProperty);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(Application.isPlaying);
|
||||
EditorGUILayout.PropertyField(sourceAttenuationModeProperty);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
var attenuationMode = (SourceAttenuationMode)sourceAttenuationModeProperty.enumValueIndex;
|
||||
if (attenuationMode == SourceAttenuationMode.InverseSquare ||
|
||||
attenuationMode == SourceAttenuationMode.Customized)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(minAttenuationDistanceProperty);
|
||||
EditorGUILayout.PropertyField(maxAttenuationDistanceProperty);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
showDirectivityOptions = EditorGUILayout.Foldout(showDirectivityOptions,
|
||||
new GUIContent("Directivity", "Setup radiation polar pattern of sound energy of this source."));
|
||||
if (showDirectivityOptions)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(directivityAlphaProperty, new GUIContent("Alpha"));
|
||||
EditorGUILayout.PropertyField(directivityOrderProperty, new GUIContent("Order"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b905f32fd564591a492987708e5d090
|
||||
timeCreated: 1710728832
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PXR_Audio_Spatializer_Context))]
|
||||
[CanEditMultipleObjects]
|
||||
public class PXR_Audio_Spatializer_ContextEditor : Editor
|
||||
{
|
||||
private SerializedProperty meshBakingLayerMask;
|
||||
private bool showMeshBakingUtilsFlag = true;
|
||||
private string meshBakingUtilitiesTitle = "Static mesh baking utilities";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
meshBakingLayerMask = serializedObject.FindProperty("meshBakingLayerMask");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
// Static mesh baking utilities
|
||||
serializedObject.Update();
|
||||
showMeshBakingUtilsFlag = EditorGUILayout.Foldout(showMeshBakingUtilsFlag, meshBakingUtilitiesTitle);
|
||||
if (showMeshBakingUtilsFlag)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(meshBakingLayerMask, new GUIContent("Layer", "Layers of game objects that will trigger mesh baking."));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.indentLevel * 15);
|
||||
if (GUILayout.Button(new GUIContent("Bake all", "Bake all acoustic geometries in this scene. Affected by 'Layer'")))
|
||||
{
|
||||
var start = Time.realtimeSinceStartup;
|
||||
|
||||
Undo.IncrementCurrentGroup();
|
||||
var undoGroupIndex = Undo.GetCurrentGroup();
|
||||
|
||||
string bakedObjectNames = "";
|
||||
int meshCount = 0;
|
||||
var sceneGeometries = FindObjectsOfType<PXR_Audio_Spatializer_SceneGeometry>();
|
||||
foreach (PXR_Audio_Spatializer_SceneGeometry geometry in sceneGeometries)
|
||||
{
|
||||
bakedObjectNames += geometry.name + ", ";
|
||||
|
||||
Undo.RecordObject(geometry, "");
|
||||
meshCount += geometry.BakeStaticMesh(meshBakingLayerMask.intValue);
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(geometry);
|
||||
}
|
||||
|
||||
Undo.SetCurrentGroupName("Bake static meshes for gameObject: " + bakedObjectNames);
|
||||
Undo.CollapseUndoOperations(undoGroupIndex);
|
||||
|
||||
var durationMs = (Time.realtimeSinceStartup - start) * 1000;
|
||||
Debug.LogFormat("Baked static {0} meshes for gameObject: {1}in {2:f4} ms", meshCount, bakedObjectNames,
|
||||
durationMs);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Clear all", "Clear all baked acoustic geometries in this scene.")))
|
||||
{
|
||||
Undo.IncrementCurrentGroup();
|
||||
var undoGroupIndex = Undo.GetCurrentGroup();
|
||||
string bakedObjectNames = "";
|
||||
|
||||
var sceneGeometries = FindObjectsOfType<PXR_Audio_Spatializer_SceneGeometry>();
|
||||
foreach (PXR_Audio_Spatializer_SceneGeometry geometry in sceneGeometries)
|
||||
{
|
||||
bakedObjectNames += geometry.name + ", ";
|
||||
|
||||
Undo.RecordObject(geometry, "");
|
||||
geometry.ClearBakeStaticMesh();
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(geometry);
|
||||
}
|
||||
|
||||
Undo.SetCurrentGroupName("Clear baked static meshes for gameObject: " + bakedObjectNames);
|
||||
Undo.CollapseUndoOperations(undoGroupIndex);
|
||||
|
||||
Debug.LogFormat("Cleared baked static meshes for gameObject: {0}", bakedObjectNames);
|
||||
}
|
||||
|
||||
GUILayout.Space(EditorGUI.indentLevel * 15 - 15);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f86288d700dd5404ab527def8df8c36c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PXR_Audio_Spatializer_SceneGeometry))]
|
||||
[CanEditMultipleObjects]
|
||||
public class PXR_Audio_Spatializer_SceneGeometryEditor : Editor
|
||||
{
|
||||
private SerializedProperty includeChildren;
|
||||
private SerializedProperty visualizeMeshInEditor;
|
||||
private SerializedProperty bakedStaticMesh;
|
||||
private SerializedProperty meshBakingLayerMask;
|
||||
private bool showMeshBakingUtilsFlag = true;
|
||||
private string meshBakingUtilitiesTitle = "Static mesh baking utilities";
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
includeChildren = serializedObject.FindProperty("includeChildren");
|
||||
visualizeMeshInEditor = serializedObject.FindProperty("visualizeMeshInEditor");
|
||||
bakedStaticMesh = serializedObject.FindProperty("bakedStaticMesh");
|
||||
meshBakingLayerMask = serializedObject.FindProperty("meshBakingLayerMask");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Boolean flags
|
||||
EditorGUILayout.PropertyField(includeChildren);
|
||||
EditorGUILayout.PropertyField(visualizeMeshInEditor);
|
||||
|
||||
// Static mesh baking utilities
|
||||
showMeshBakingUtilsFlag = EditorGUILayout.Foldout(showMeshBakingUtilsFlag, meshBakingUtilitiesTitle);
|
||||
if (showMeshBakingUtilsFlag)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(meshBakingLayerMask,
|
||||
new GUIContent("Layer", "Layers of game objects that will trigger mesh baking."));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(EditorGUI.indentLevel * 15);
|
||||
if (GUILayout.Button(new GUIContent("Bake", "Bake acoustic meshes for this acoustic geometry\n" +
|
||||
" - affected by your 'Layer' setting.")))
|
||||
{
|
||||
var start = Time.realtimeSinceStartup;
|
||||
|
||||
Undo.IncrementCurrentGroup();
|
||||
var undoGroupIndex = Undo.GetCurrentGroup();
|
||||
|
||||
string bakedObjectNames = "";
|
||||
int meshCount = 0;
|
||||
foreach (var t in targets)
|
||||
{
|
||||
PXR_Audio_Spatializer_SceneGeometry geometry = (PXR_Audio_Spatializer_SceneGeometry)t;
|
||||
bakedObjectNames += geometry.name + ", ";
|
||||
|
||||
Undo.RecordObject(geometry, "");
|
||||
meshCount += geometry.BakeStaticMesh(meshBakingLayerMask.intValue);
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(geometry);
|
||||
}
|
||||
|
||||
Undo.SetCurrentGroupName("Bake static meshes for gameObject: " + bakedObjectNames);
|
||||
Undo.CollapseUndoOperations(undoGroupIndex);
|
||||
|
||||
var durationMs = (Time.realtimeSinceStartup - start) * 1000;
|
||||
Debug.LogFormat("Baked static {0} meshes for gameObject: {1}in {2:f4} ms", meshCount, bakedObjectNames,
|
||||
durationMs);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Clear", "Clear the baked mesh")))
|
||||
{
|
||||
Undo.IncrementCurrentGroup();
|
||||
var undoGroupIndex = Undo.GetCurrentGroup();
|
||||
string bakedObjectNames = "";
|
||||
foreach (var t in targets)
|
||||
{
|
||||
PXR_Audio_Spatializer_SceneGeometry geometry = (PXR_Audio_Spatializer_SceneGeometry)t;
|
||||
bakedObjectNames += geometry.name + ", ";
|
||||
|
||||
Undo.RecordObject(geometry, "");
|
||||
geometry.ClearBakeStaticMesh();
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(geometry);
|
||||
}
|
||||
|
||||
Undo.SetCurrentGroupName("Clear baked static meshes for gameObject: " + bakedObjectNames);
|
||||
Undo.CollapseUndoOperations(undoGroupIndex);
|
||||
|
||||
Debug.LogFormat("Cleared baked static meshes for gameObject: {0}", bakedObjectNames);
|
||||
}
|
||||
|
||||
GUILayout.Space(EditorGUI.indentLevel * 15 - 15);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(bakedStaticMesh);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09493c449b7ba41da8978c862fb59643
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(PXR_Audio_Spatializer_SceneMaterial))]
|
||||
[CanEditMultipleObjects]
|
||||
public class PXR_Audio_Spatializer_SceneMaterialEditor : Editor
|
||||
{
|
||||
private SerializedProperty materialPresetProperty;
|
||||
private SerializedProperty absorptionProperty;
|
||||
private SerializedProperty scatteringProperty;
|
||||
private SerializedProperty transmissionProperty;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
materialPresetProperty = serializedObject.FindProperty("materialPreset");
|
||||
absorptionProperty = serializedObject.FindProperty("absorption");
|
||||
scatteringProperty = serializedObject.FindProperty("scattering");
|
||||
transmissionProperty = serializedObject.FindProperty("transmission");
|
||||
}
|
||||
|
||||
private static int[] bandCenters = { 1000, 2000, 4000, 8000 };
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(materialPresetProperty);
|
||||
|
||||
for (int i = 0; i < absorptionProperty.arraySize; i++)
|
||||
{
|
||||
SerializedProperty elementProperty = absorptionProperty.GetArrayElementAtIndex(i);
|
||||
string elementName = $"Absorption band {bandCenters[i]} Hz";
|
||||
string tooltips = $"Ratio of sound energy absorbed by each reflection for band {bandCenters[i]} Hz";
|
||||
EditorGUILayout.PropertyField(elementProperty, new GUIContent(elementName, tooltips));
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(scatteringProperty);
|
||||
EditorGUILayout.PropertyField(transmissionProperty);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 738f0726e7684c8192c01c6a022b96c4
|
||||
timeCreated: 1710310935
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Pico.Spatializer.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": ["GUID:b3d620f74d91148829d3deb288af824d"],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c64abb93d730f406cbeaa719424a4ae9
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user