Initial Wwise Integration
Created wwise project Integrated inventory UI sounds Improved projectile weapon behavior (randomized start position, stopped them from self-destructing at target range when airburst is disabled)
This commit is contained in:
parent
b53e4aec8c
commit
db8c3c7779
1019 changed files with 76372 additions and 110 deletions
306
Assets/Wwise/Editor/WwiseComponents/AkAmbientInspector.cs
Normal file
306
Assets/Wwise/Editor/WwiseComponents/AkAmbientInspector.cs
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkAmbient))]
|
||||
public class AkAmbientInspector : AkEventInspector
|
||||
{
|
||||
public enum AttenuationSphereOptions
|
||||
{
|
||||
Dont_Show,
|
||||
Current_Event_Only,
|
||||
All_Events
|
||||
}
|
||||
|
||||
public static System.Collections.Generic.Dictionary<UnityEngine.Object, AttenuationSphereOptions> attSphereProperties =
|
||||
new System.Collections.Generic.Dictionary<UnityEngine.Object, AttenuationSphereOptions>();
|
||||
|
||||
public AttenuationSphereOptions currentAttSphereOp;
|
||||
|
||||
private AkAmbient m_AkAmbient;
|
||||
private UnityEditor.SerializedProperty multiPositionTypeProperty;
|
||||
private UnityEditor.SerializedProperty largeModePositionArrayProperty;
|
||||
|
||||
private System.Collections.Generic.List<int> triggerList;
|
||||
|
||||
public new void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
m_AkAmbient = target as AkAmbient;
|
||||
|
||||
multiPositionTypeProperty = serializedObject.FindProperty("multiPositionTypeLabel");
|
||||
largeModePositionArrayProperty = serializedObject.FindProperty("LargeModePositions");
|
||||
|
||||
if (!attSphereProperties.ContainsKey(target))
|
||||
attSphereProperties.Add(target, AttenuationSphereOptions.Dont_Show);
|
||||
|
||||
currentAttSphereOp = attSphereProperties[target];
|
||||
|
||||
AkWwiseXMLWatcher.Instance.XMLUpdated += PopulateMaxAttenuation;
|
||||
}
|
||||
|
||||
public new void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
|
||||
DefaultHandles.Hidden = false;
|
||||
|
||||
AkWwiseXMLWatcher.Instance.XMLUpdated -= PopulateMaxAttenuation;
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
//Save trigger mask to know when it changes
|
||||
triggerList = m_AkAmbient.triggerList;
|
||||
|
||||
base.OnChildInspectorGUI();
|
||||
|
||||
if (UnityEngine.Event.current.type == UnityEngine.EventType.ExecuteCommand
|
||||
&& UnityEngine.Event.current.commandName == "ObjectSelectorClosed")
|
||||
{
|
||||
var pickedObject = UnityEditor.EditorGUIUtility.GetObjectPickerObject();
|
||||
if (pickedObject != null)
|
||||
{
|
||||
int insertIndex = largeModePositionArrayProperty.arraySize;
|
||||
largeModePositionArrayProperty.InsertArrayElementAtIndex(insertIndex);
|
||||
|
||||
var newElement = largeModePositionArrayProperty.GetArrayElementAtIndex(insertIndex);
|
||||
newElement.objectReferenceValue = pickedObject;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(multiPositionTypeProperty, new UnityEngine.GUIContent("Position Type: ", "Simple Mode: Only one position is used.\nLarge Mode: Children of AkAmbient with AkAmbientLargeModePositioner component will be used as position source for multi-positioning.\nMultiple Position Mode: Every AkAmbient using the same event will be used as position source for multi-positioning."));
|
||||
|
||||
var multiPositionType = (MultiPositionTypeLabel)multiPositionTypeProperty.intValue;
|
||||
if (multiPositionType == MultiPositionTypeLabel.Large_Mode || multiPositionType == MultiPositionTypeLabel.MultiPosition_Mode)
|
||||
{
|
||||
foreach (AkAmbient ambient in targets)
|
||||
{
|
||||
if (!ambient.gameObject.isStatic)
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
UnityEditor.EditorGUILayout.HelpBox(string.Format("Position Type <{0}> requires an AkGameObj that does not move. Consider setting the associated GameObject to static.", multiPositionType), UnityEditor.MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
currentAttSphereOp = (AttenuationSphereOptions) UnityEditor.EditorGUILayout.EnumPopup("Show Attenuation Sphere: ", currentAttSphereOp);
|
||||
attSphereProperties[target] = currentAttSphereOp;
|
||||
|
||||
if (multiPositionType == MultiPositionTypeLabel.Large_Mode)
|
||||
{
|
||||
UnityEngine.GUILayout.BeginHorizontal();
|
||||
if (UnityEngine.GUILayout.Button("Add Large Mode position object"))
|
||||
{
|
||||
int insertIndex = largeModePositionArrayProperty.arraySize;
|
||||
largeModePositionArrayProperty.InsertArrayElementAtIndex(insertIndex);
|
||||
|
||||
var newPoint = new UnityEngine.GameObject(string.Format("AkAmbientPoint{0}", insertIndex));
|
||||
UnityEditor.Undo.RegisterCreatedObjectUndo(newPoint, "CreateNewLargeModePositionObject");
|
||||
UnityEditor.Undo.AddComponent<AkAmbientLargeModePositioner>(newPoint);
|
||||
UnityEditor.Undo.SetTransformParent(newPoint.transform, m_AkAmbient.transform, "CreateNewLargeModePositionObjectSetParent");
|
||||
newPoint.transform.position = m_AkAmbient.transform.TransformPoint(UnityEngine.Vector3.zero);
|
||||
newPoint.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
|
||||
|
||||
var newElement = largeModePositionArrayProperty.GetArrayElementAtIndex(insertIndex);
|
||||
newElement.objectReferenceValue = newPoint.GetComponent<AkAmbientLargeModePositioner>();
|
||||
}
|
||||
|
||||
if (UnityEngine.GUILayout.Button("Pick existing position object"))
|
||||
{
|
||||
int controlID = UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive);
|
||||
UnityEditor.EditorGUIUtility.ShowObjectPicker<AkAmbientLargeModePositioner>(null, true, string.Empty, controlID);
|
||||
}
|
||||
UnityEngine.GUILayout.EndHorizontal();
|
||||
|
||||
++UnityEditor.EditorGUI.indentLevel;
|
||||
UnityEditor.EditorGUI.BeginChangeCheck();
|
||||
for (int i = 0; i < largeModePositionArrayProperty.arraySize; ++i)
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(largeModePositionArrayProperty.GetArrayElementAtIndex(i), true);
|
||||
}
|
||||
if (UnityEditor.EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
--UnityEditor.EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
//Save multi-position type to know if it has changed
|
||||
var multiPosType = m_AkAmbient.multiPositionTypeLabel;
|
||||
|
||||
if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode)
|
||||
{
|
||||
UpdateTriggers(multiPosType);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTriggers(MultiPositionTypeLabel in_multiPosType)
|
||||
{
|
||||
//if we just switched to MultiPosition_Mode
|
||||
if (in_multiPosType != m_AkAmbient.multiPositionTypeLabel)
|
||||
{
|
||||
//Get all AkAmbients in the scene
|
||||
var akAmbients = FindObjectsOfType<AkAmbient>();
|
||||
|
||||
//Find the first AkAmbient that is in multiPosition_Mode and that has the same event as the current AkAmbient
|
||||
for (var i = 0; i < akAmbients.Length; i++)
|
||||
{
|
||||
if (akAmbients[i] != m_AkAmbient &&
|
||||
akAmbients[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode &&
|
||||
akAmbients[i].data.Id == m_AkAmbient.data.Id)
|
||||
{
|
||||
//if the current AkAmbient doesn't have the same trigger as the others, we ask the user which one he wants to keep
|
||||
if (!HasSameTriggers(akAmbients[i].triggerList))
|
||||
{
|
||||
if (UnityEditor.EditorUtility.DisplayDialog("AkAmbient Trigger Mismatch",
|
||||
"All ambients in multi-position mode with the same event must have the same triggers.\n" +
|
||||
"Which triggers would you like to keep?", "Current AkAmbient Triggers", "Other AkAmbients Triggers"))
|
||||
SetMultiPosTrigger(akAmbients);
|
||||
else
|
||||
m_AkAmbient.triggerList = akAmbients[i].triggerList;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if the trigger changed or there was an undo/redo operation, we update the triggers of all the AkAmbients in the same group as the current one
|
||||
else if (!HasSameTriggers(triggerList) || UnityEngine.Event.current.type == UnityEngine.EventType.ValidateCommand &&
|
||||
UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
||||
{
|
||||
var akAmbients = FindObjectsOfType<AkAmbient>();
|
||||
SetMultiPosTrigger(akAmbients);
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasSameTriggers(System.Collections.Generic.List<int> other)
|
||||
{
|
||||
return other.Count == m_AkAmbient.triggerList.Count &&
|
||||
System.Linq.Enumerable.Count(System.Linq.Enumerable.Except(m_AkAmbient.triggerList, other)) == 0;
|
||||
}
|
||||
|
||||
private void SetMultiPosTrigger(AkAmbient[] akAmbients)
|
||||
{
|
||||
for (var i = 0; i < akAmbients.Length; i++)
|
||||
{
|
||||
if (akAmbients[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode &&
|
||||
akAmbients[i].data.Id == m_AkAmbient.data.Id)
|
||||
akAmbients[i].triggerList = m_AkAmbient.triggerList;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
RenderAttenuationSpheres();
|
||||
}
|
||||
|
||||
public void RenderAttenuationSpheres()
|
||||
{
|
||||
if (currentAttSphereOp == AttenuationSphereOptions.Dont_Show)
|
||||
return;
|
||||
|
||||
if (currentAttSphereOp == AttenuationSphereOptions.Current_Event_Only)
|
||||
{
|
||||
// Get the max attenuation for the event (if available)
|
||||
var radius = AkWwiseProjectInfo.GetData().GetEventMaxAttenuation(m_AkAmbient.data.Id);
|
||||
|
||||
if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.Simple_Mode)
|
||||
{
|
||||
DrawSphere(m_AkAmbient.gameObject.transform.position, radius);
|
||||
}
|
||||
else if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.Large_Mode)
|
||||
{
|
||||
var positionComponents = m_AkAmbient.GetComponentsInChildren<AkAmbientLargeModePositioner>();
|
||||
|
||||
for (int i = 0; i < positionComponents.Length; i++)
|
||||
{
|
||||
DrawSphere(positionComponents[i].transform.position, radius);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var akAmbiants = FindObjectsOfType<AkAmbient>();
|
||||
|
||||
for (var i = 0; i < akAmbiants.Length; i++)
|
||||
{
|
||||
if (akAmbiants[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode &&
|
||||
akAmbiants[i].data.Id == m_AkAmbient.data.Id)
|
||||
{
|
||||
DrawSphere(akAmbiants[i].gameObject.transform.position, radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var akAmbiants = FindObjectsOfType<AkAmbient>();
|
||||
|
||||
for (var i = 0; i < akAmbiants.Length; i++)
|
||||
{
|
||||
// Get the max attenuation for the event (if available)
|
||||
var radius = AkWwiseProjectInfo.GetData().GetEventMaxAttenuation(akAmbiants[i].data.Id);
|
||||
|
||||
if (akAmbiants[i].multiPositionTypeLabel == MultiPositionTypeLabel.Large_Mode)
|
||||
{
|
||||
var positionComponents = m_AkAmbient.GetComponentsInChildren<AkAmbientLargeModePositioner>();
|
||||
|
||||
for (int j = 0; j < positionComponents.Length; j++)
|
||||
{
|
||||
DrawSphere(positionComponents[j].transform.position, radius);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSphere(akAmbiants[i].gameObject.transform.position, radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static UnityEngine.Color SPHERE_COLOR = new UnityEngine.Color(1.0f, 0.0f, 0.0f, 0.1f);
|
||||
|
||||
private void DrawSphere(UnityEngine.Vector3 in_position, float in_radius)
|
||||
{
|
||||
UnityEditor.Handles.color = SPHERE_COLOR;
|
||||
|
||||
if ((UnityEditor.SceneView.lastActiveSceneView.camera.transform.position - in_position).sqrMagnitude > in_radius * in_radius)
|
||||
{
|
||||
UnityEditor.Handles.SphereHandleCap(0, in_position, UnityEngine.Quaternion.identity, in_radius * 2.0f, UnityEngine.EventType.Repaint);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawDiscs(UnityEngine.Vector3.up, UnityEngine.Vector3.down, 6, in_position, in_radius);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDiscs(UnityEngine.Vector3 in_startNormal, UnityEngine.Vector3 in_endNormal, uint in_nbDiscs,
|
||||
UnityEngine.Vector3 in_position, float in_radius)
|
||||
{
|
||||
var f = 1.0f / in_nbDiscs;
|
||||
for (var i = 0; i < in_nbDiscs; i++)
|
||||
{
|
||||
UnityEditor.Handles.DrawWireDisc(in_position, UnityEngine.Vector3.Slerp(in_startNormal, in_endNormal, f * i), in_radius);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PopulateMaxAttenuation()
|
||||
{
|
||||
UnityEditor.SceneView.RepaintAll();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d53dfd686eb93394ebe7a6985833206e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkAudioListener))]
|
||||
public class AkAudioListenerInspector : UnityEditor.Editor
|
||||
{
|
||||
private UnityEditor.SerializedProperty m_isDefaultListener;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_isDefaultListener = serializedObject.FindProperty("isDefaultListener");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUI.BeginChangeCheck();
|
||||
UnityEditor.EditorGUILayout.PropertyField(m_isDefaultListener);
|
||||
if (UnityEditor.EditorGUI.EndChangeCheck())
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e56f84fb6319a8e46bf3eb819380bb31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Wwise/Editor/WwiseComponents/AkBankInspector.cs
Normal file
61
Assets/Wwise/Editor/WwiseComponents/AkBankInspector.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkBank))]
|
||||
public class AkBankInspector : AkBaseInspector
|
||||
{
|
||||
private readonly AkUnityEventHandlerInspector m_LoadBankEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
private readonly AkUnityEventHandlerInspector m_UnloadBankEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
private UnityEditor.SerializedProperty decode;
|
||||
private UnityEditor.SerializedProperty loadAsync;
|
||||
private UnityEditor.SerializedProperty saveDecoded;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_LoadBankEventHandlerInspector.Init(serializedObject, "triggerList", "Load On: ", false);
|
||||
m_UnloadBankEventHandlerInspector.Init(serializedObject, "unloadTriggerList", "Unload On: ", false);
|
||||
|
||||
loadAsync = serializedObject.FindProperty("loadAsynchronous");
|
||||
decode = serializedObject.FindProperty("decodeBank");
|
||||
saveDecoded = serializedObject.FindProperty("saveDecodedBank");
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
m_LoadBankEventHandlerInspector.OnGUI();
|
||||
m_UnloadBankEventHandlerInspector.OnGUI();
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(loadAsync, new UnityEngine.GUIContent("Asynchronous:"));
|
||||
UnityEditor.EditorGUILayout.PropertyField(decode, new UnityEngine.GUIContent("Decode compressed data:"));
|
||||
|
||||
if (!decode.boolValue)
|
||||
return;
|
||||
|
||||
var oldSaveDecodedValue = saveDecoded.boolValue;
|
||||
UnityEditor.EditorGUILayout.PropertyField(saveDecoded, new UnityEngine.GUIContent("Save decoded bank:"));
|
||||
if (!oldSaveDecodedValue || saveDecoded.boolValue)
|
||||
return;
|
||||
|
||||
var bank = target as AkBank;
|
||||
AkBasePathGetter.EvaluateGamePaths();
|
||||
var decodedBankPath = System.IO.Path.Combine(AkBasePathGetter.DecodedBankFullPath, bank.data.Name + ".bnk");
|
||||
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(decodedBankPath);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
UnityEngine.Debug.Log("WwiseUnity: Could not delete existing decoded SoundBank. Please delete it manually. " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkBankInspector.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkBankInspector.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 039e592a4cbac3c4e9f4bd8eb34e9b1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Wwise/Editor/WwiseComponents/AkBaseInspector.cs
Normal file
31
Assets/Wwise/Editor/WwiseComponents/AkBaseInspector.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
public abstract class AkBaseInspector : UnityEditor.Editor
|
||||
{
|
||||
public abstract void OnChildInspectorGUI();
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
OnChildInspectorGUI();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEngine.GUILayout.HorizontalScope("box"))
|
||||
UnityEditor.EditorGUILayout.PropertyField(serializedObject.FindProperty("data"), new UnityEngine.GUIContent("Name: "));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (UnityEngine.GUI.changed)
|
||||
UnityEditor.EditorUtility.SetDirty(serializedObject.targetObject);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkBaseInspector.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkBaseInspector.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1533a3a8145a4541ac64d58133b886f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkEnvironment))]
|
||||
public class AkEnvironmentInspector : AkBaseInspector
|
||||
{
|
||||
private AkEnvironment m_AkEnvironment;
|
||||
|
||||
private UnityEditor.SerializedProperty m_excludeOthers;
|
||||
private UnityEditor.SerializedProperty m_isDefault;
|
||||
private UnityEditor.SerializedProperty m_priority;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_AkEnvironment = target as AkEnvironment;
|
||||
|
||||
m_priority = serializedObject.FindProperty("priority");
|
||||
m_isDefault = serializedObject.FindProperty("isDefault");
|
||||
m_excludeOthers = serializedObject.FindProperty("excludeOthers");
|
||||
|
||||
//We move and replace the game object to trigger the OnTriggerStay function
|
||||
ShakeEnvironment();
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
m_priority.intValue = UnityEditor.EditorGUILayout.IntField("Priority: ", m_priority.intValue);
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
m_isDefault.boolValue = UnityEditor.EditorGUILayout.Toggle("Default: ", m_isDefault.boolValue);
|
||||
if (m_isDefault.boolValue)
|
||||
m_excludeOthers.boolValue = false;
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
m_excludeOthers.boolValue = UnityEditor.EditorGUILayout.Toggle("Exclude Others: ", m_excludeOthers.boolValue);
|
||||
if (m_excludeOthers.boolValue)
|
||||
m_isDefault.boolValue = false;
|
||||
}
|
||||
|
||||
AkGameObjectInspector.RigidbodyCheck(m_AkEnvironment.gameObject);
|
||||
}
|
||||
|
||||
public void ShakeEnvironment()
|
||||
{
|
||||
var temp = m_AkEnvironment.transform.position;
|
||||
temp.x *= 1.0000001f;
|
||||
m_AkEnvironment.transform.position = temp;
|
||||
|
||||
UnityEditor.EditorApplication.update += ReplaceEnvironment;
|
||||
}
|
||||
|
||||
private void ReplaceEnvironment()
|
||||
{
|
||||
UnityEditor.EditorApplication.update -= ReplaceEnvironment;
|
||||
if (m_AkEnvironment && m_AkEnvironment.transform)
|
||||
{
|
||||
var temp = m_AkEnvironment.transform.position;
|
||||
temp.x /= 1.0000001f;
|
||||
m_AkEnvironment.transform.position = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ecd8234067f60b419187d914b714193
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CustomEditor(typeof(AkEnvironmentPortal))]
|
||||
public class AkEnvironmentPortalInspector : UnityEditor.Editor
|
||||
{
|
||||
private readonly int[] m_selectedIndex = new int[AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL];
|
||||
private AkEnvironmentPortal m_envPortal;
|
||||
private UnityEditor.SerializedProperty m_environments;
|
||||
private UnityEditor.SerializedProperty m_axis;
|
||||
private UnityEditor.SerializedProperty m_envList;
|
||||
|
||||
[UnityEditor.MenuItem("GameObject/Wwise/Environment Portal", false, 1)]
|
||||
public static void CreatePortal()
|
||||
{
|
||||
var portal = new UnityEngine.GameObject("EnvironmentPortal");
|
||||
|
||||
UnityEditor.Undo.AddComponent<AkEnvironmentPortal>(portal);
|
||||
portal.GetComponent<UnityEngine.Collider>().isTrigger = true;
|
||||
|
||||
UnityEditor.Selection.objects = new UnityEngine.Object[] { portal };
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_envPortal = target as AkEnvironmentPortal;
|
||||
m_environments = serializedObject.FindProperty("environments");
|
||||
m_axis = serializedObject.FindProperty("axis");
|
||||
m_envList = serializedObject.FindProperty("envList");
|
||||
|
||||
FindOverlappingEnvironments();
|
||||
for (var i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++)
|
||||
{
|
||||
m_selectedIndex[i] = 0;
|
||||
|
||||
var list = m_envList.GetArrayElementAtIndex(i).FindPropertyRelative("list");
|
||||
for (var j = 0; j < list.arraySize; ++j)
|
||||
{
|
||||
if (list.GetArrayElementAtIndex(j).objectReferenceValue == m_environments.GetArrayElementAtIndex(i).objectReferenceValue)
|
||||
{
|
||||
m_selectedIndex[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
using (new UnityEngine.GUILayout.VerticalScope("box"))
|
||||
{
|
||||
for (var i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++)
|
||||
{
|
||||
var list = m_envList.GetArrayElementAtIndex(i).FindPropertyRelative("list");
|
||||
var labels = new string[list.arraySize];
|
||||
|
||||
for (var j = 0; j < list.arraySize; j++)
|
||||
{
|
||||
var environment = list.GetArrayElementAtIndex(j).objectReferenceValue as AkEnvironment;
|
||||
if (environment != null)
|
||||
{
|
||||
labels[j] = j + 1 + ". " + GetEnvironmentName(environment) + " (" + environment.name + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
list.DeleteArrayElementAtIndex(j);
|
||||
}
|
||||
}
|
||||
|
||||
var index = UnityEditor.EditorGUILayout.Popup("Environment #" + (i + 1), m_selectedIndex[i], labels);
|
||||
m_environments.GetArrayElementAtIndex(i).objectReferenceValue = index < 0 || index >= list.arraySize ? null : list.GetArrayElementAtIndex(index).objectReferenceValue;
|
||||
m_selectedIndex[i] = index;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
var axisLabels = new[]{ "X", "Y", "Z" };
|
||||
var axes = new[] { UnityEngine.Vector3.right, UnityEngine.Vector3.up, UnityEngine.Vector3.forward };
|
||||
|
||||
var index = 0;
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
if (m_axis.vector3Value == axes[i])
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var newIndex = UnityEditor.EditorGUILayout.Popup("Axis", index, axisLabels);
|
||||
m_axis.vector3Value = axes[newIndex];
|
||||
|
||||
if (index != newIndex)
|
||||
{
|
||||
for (var i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++)
|
||||
m_envList.GetArrayElementAtIndex(i).FindPropertyRelative("list").ClearArray();
|
||||
|
||||
FindOverlappingEnvironments();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
AkGameObjectInspector.RigidbodyCheck(m_envPortal.gameObject);
|
||||
}
|
||||
|
||||
private string GetEnvironmentName(AkEnvironment in_env)
|
||||
{
|
||||
foreach (var wwu in AkWwiseProjectInfo.GetData().AuxBusWwu)
|
||||
foreach (var env in wwu.List)
|
||||
if (in_env.data.Id == env.Id)
|
||||
return env.Name;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void FindOverlappingEnvironments()
|
||||
{
|
||||
var myCollider = m_envPortal.gameObject.GetComponent<UnityEngine.Collider>();
|
||||
if (myCollider == null)
|
||||
return;
|
||||
|
||||
var environments = FindObjectsOfType<AkEnvironment>();
|
||||
foreach (var environment in environments)
|
||||
{
|
||||
var otherCollider = environment.gameObject.GetComponent<UnityEngine.Collider>();
|
||||
if (otherCollider == null)
|
||||
continue;
|
||||
|
||||
if (myCollider.bounds.Intersects(otherCollider.bounds))
|
||||
{
|
||||
//if index == 0 => the environment is on the negative side of the portal(opposite to the direction of the chosen axis)
|
||||
//if index == 1 => the environment is on the positive side of the portal(same direction as the chosen axis)
|
||||
var index = UnityEngine.Vector3.Dot(m_envPortal.transform.rotation * m_axis.vector3Value,
|
||||
environment.transform.position - m_envPortal.transform.position) >= 0 ? 1 : 0;
|
||||
|
||||
var list = m_envList.GetArrayElementAtIndex(index).FindPropertyRelative("list");
|
||||
|
||||
var isFound = false;
|
||||
var count = list.arraySize;
|
||||
|
||||
for (var j = 0; j < count; j++)
|
||||
{
|
||||
if (list.GetArrayElementAtIndex(j).objectReferenceValue == environment)
|
||||
{
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFound)
|
||||
{
|
||||
list.InsertArrayElementAtIndex(count);
|
||||
list.GetArrayElementAtIndex(count).objectReferenceValue = environment;
|
||||
|
||||
var otherList = m_envList.GetArrayElementAtIndex(++index % AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL).FindPropertyRelative("list");
|
||||
|
||||
for (var j = 0; j < otherList.arraySize; j++)
|
||||
{
|
||||
if (otherList.GetArrayElementAtIndex(j).objectReferenceValue == environment)
|
||||
{
|
||||
otherList.DeleteArrayElementAtIndex(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++)
|
||||
{
|
||||
var list = m_envList.GetArrayElementAtIndex(i).FindPropertyRelative("list");
|
||||
for (var j = 0; j < list.arraySize; j++)
|
||||
{
|
||||
if (list.GetArrayElementAtIndex(j).objectReferenceValue == environment)
|
||||
{
|
||||
list.DeleteArrayElementAtIndex(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bf953ad6f9c2f2479344c21950554fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
276
Assets/Wwise/Editor/WwiseComponents/AkEventInspector.cs
Normal file
276
Assets/Wwise/Editor/WwiseComponents/AkEventInspector.cs
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkEvent))]
|
||||
public class AkEventInspector : AkBaseInspector
|
||||
{
|
||||
private readonly AkUnityEventHandlerInspector m_UnityEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
private UnityEditor.SerializedProperty actionOnEventType;
|
||||
private UnityEditor.SerializedProperty callbackData;
|
||||
private UnityEditor.SerializedProperty curveInterpolation;
|
||||
private UnityEditor.SerializedProperty enableActionOnEvent;
|
||||
private UnityEditor.SerializedProperty transitionDuration;
|
||||
private UnityEditor.SerializedProperty useCallbacks;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
m_UnityEventHandlerInspector.Init(serializedObject);
|
||||
|
||||
enableActionOnEvent = serializedObject.FindProperty("enableActionOnEvent");
|
||||
actionOnEventType = serializedObject.FindProperty("actionOnEventType");
|
||||
curveInterpolation = serializedObject.FindProperty("curveInterpolation");
|
||||
transitionDuration = serializedObject.FindProperty("transitionDuration");
|
||||
useCallbacks = serializedObject.FindProperty("useCallbacks");
|
||||
callbackData = serializedObject.FindProperty("Callbacks");
|
||||
|
||||
AkEditorEventPlayer.RefreshGUI += Repaint;
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
AkEditorEventPlayer.RefreshGUI -= Repaint;
|
||||
}
|
||||
|
||||
private void DisplayActionOnEvent()
|
||||
{
|
||||
if (useCallbacks.boolValue)
|
||||
return;
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(enableActionOnEvent, new UnityEngine.GUIContent("Action On Event: "));
|
||||
if (!enableActionOnEvent.boolValue)
|
||||
return;
|
||||
|
||||
UnityEditor.EditorGUILayout.PropertyField(actionOnEventType, new UnityEngine.GUIContent("Action On EventType: "));
|
||||
UnityEditor.EditorGUILayout.PropertyField(curveInterpolation, new UnityEngine.GUIContent("Curve Interpolation: "));
|
||||
UnityEditor.EditorGUILayout.Slider(transitionDuration, 0.0f, 60.0f, new UnityEngine.GUIContent("Fade Time (secs): "));
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayCallbackInformation()
|
||||
{
|
||||
if (enableActionOnEvent.boolValue)
|
||||
return;
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(useCallbacks, new UnityEngine.GUIContent("Use Callback: "));
|
||||
|
||||
if (useCallbacks.boolValue)
|
||||
{
|
||||
var emptyContent = new UnityEngine.GUIContent("");
|
||||
|
||||
// ensure that there is always at least one entry since we are "using" callbacks
|
||||
if (callbackData.arraySize == 0)
|
||||
callbackData.arraySize = 1;
|
||||
|
||||
const float callbackSpacerWidth = 4;
|
||||
const float removeButtonWidth = 20;
|
||||
var rect = UnityEditor.EditorGUILayout.GetControlRect();
|
||||
var callbackFieldWidth = (rect.width - removeButtonWidth) / 3;
|
||||
rect.width = callbackFieldWidth - callbackSpacerWidth;
|
||||
|
||||
UnityEngine.GUI.Label(rect, "Game Object");
|
||||
|
||||
rect.x += callbackFieldWidth;
|
||||
UnityEngine.GUI.Label(rect, "Callback Function");
|
||||
|
||||
rect.x += callbackFieldWidth;
|
||||
UnityEngine.GUI.Label(rect, "Callback Flags");
|
||||
|
||||
for (var i = 0; i < callbackData.arraySize; ++i)
|
||||
{
|
||||
var data = callbackData.GetArrayElementAtIndex(i);
|
||||
rect = UnityEditor.EditorGUILayout.GetControlRect();
|
||||
rect.width = callbackFieldWidth - callbackSpacerWidth;
|
||||
UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("GameObject"), emptyContent);
|
||||
|
||||
rect.x += callbackFieldWidth;
|
||||
UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("FunctionName"), emptyContent);
|
||||
|
||||
rect.x += callbackFieldWidth;
|
||||
UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("Flags"), emptyContent);
|
||||
|
||||
rect.x += callbackFieldWidth;
|
||||
rect.width = removeButtonWidth;
|
||||
if (UnityEngine.GUI.Button(rect, "X"))
|
||||
callbackData.DeleteArrayElementAtIndex(i);
|
||||
}
|
||||
|
||||
if (UnityEngine.GUI.Button(UnityEditor.EditorGUILayout.GetControlRect(), "Add"))
|
||||
{
|
||||
var i = callbackData.arraySize++;
|
||||
var data = callbackData.GetArrayElementAtIndex(i);
|
||||
data.FindPropertyRelative("GameObject").objectReferenceValue = null;
|
||||
data.FindPropertyRelative("FunctionName").stringValue = string.Empty;
|
||||
data.FindPropertyRelative("Flags.value").intValue = 0;
|
||||
}
|
||||
}
|
||||
else if (callbackData.arraySize == 1)
|
||||
{
|
||||
var data = callbackData.GetArrayElementAtIndex(0);
|
||||
if (data.FindPropertyRelative("GameObject").objectReferenceValue == null)
|
||||
if (string.IsNullOrEmpty(data.FindPropertyRelative("FunctionName").stringValue))
|
||||
if (data.FindPropertyRelative("Flags.value").intValue == 0)
|
||||
callbackData.arraySize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
m_UnityEventHandlerInspector.OnGUI();
|
||||
|
||||
DisplayActionOnEvent();
|
||||
DisplayCallbackInformation();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
if (targets.Length == 1)
|
||||
{
|
||||
var akEvent = (AkEvent) target;
|
||||
var eventPlaying = AkEditorEventPlayer.IsEventPlaying(akEvent);
|
||||
if (eventPlaying)
|
||||
{
|
||||
if (UnityEngine.GUILayout.Button("Stop"))
|
||||
{
|
||||
UnityEngine.GUIUtility.hotControl = 0;
|
||||
AkEditorEventPlayer.StopEvent(akEvent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityEngine.GUILayout.Button("Play"))
|
||||
{
|
||||
UnityEngine.GUIUtility.hotControl = 0;
|
||||
AkEditorEventPlayer.PlayEvent(akEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var playingEventsSelected = false;
|
||||
var stoppedEventsSelected = false;
|
||||
for (var i = 0; i < targets.Length; ++i)
|
||||
{
|
||||
var akEventTarget = targets[i] as AkEvent;
|
||||
if (akEventTarget != null)
|
||||
{
|
||||
if (AkEditorEventPlayer.IsEventPlaying(akEventTarget))
|
||||
{
|
||||
playingEventsSelected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
stoppedEventsSelected = true;
|
||||
}
|
||||
|
||||
if (playingEventsSelected && stoppedEventsSelected)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stoppedEventsSelected &&
|
||||
UnityEngine.GUILayout.Button("Play Multiple"))
|
||||
{
|
||||
for (var i = 0; i < targets.Length; ++i)
|
||||
{
|
||||
var akEventTarget = targets[i] as AkEvent;
|
||||
if (akEventTarget != null)
|
||||
{
|
||||
AkEditorEventPlayer.PlayEvent(akEventTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (playingEventsSelected &&
|
||||
UnityEngine.GUILayout.Button("Stop Multiple"))
|
||||
{
|
||||
for (var i = 0; i < targets.Length; ++i)
|
||||
{
|
||||
var akEventTarget = targets[i] as AkEvent;
|
||||
if (akEventTarget != null)
|
||||
{
|
||||
AkEditorEventPlayer.StopEvent(akEventTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UnityEngine.GUILayout.Button("Stop All"))
|
||||
{
|
||||
UnityEngine.GUIUtility.hotControl = 0;
|
||||
AkEditorEventPlayer.StopAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AkEditorEventPlayer
|
||||
{
|
||||
private static readonly System.Collections.Generic.List<AkEvent> akEvents = new System.Collections.Generic.List<AkEvent>();
|
||||
|
||||
public static event System.Action RefreshGUI;
|
||||
|
||||
private static void CallbackHandler(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info)
|
||||
{
|
||||
if (in_type == AkCallbackType.AK_EndOfEvent)
|
||||
{
|
||||
akEvents.Remove(in_cookie as AkEvent);
|
||||
|
||||
var refreshGUI = RefreshGUI;
|
||||
if (refreshGUI != null)
|
||||
{
|
||||
refreshGUI.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayEvent(AkEvent akEvent)
|
||||
{
|
||||
if (akEvents.Contains(akEvent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var playingID = akEvent.data.Post(akEvent.gameObject, (uint)AkCallbackType.AK_EndOfEvent, CallbackHandler, akEvent);
|
||||
if (playingID != AkSoundEngine.AK_INVALID_PLAYING_ID)
|
||||
{
|
||||
akEvents.Add(akEvent);
|
||||
|
||||
// In the case where objects are being placed in edit mode and then previewed, their positions won't yet be updated so we ensure they're updated here.
|
||||
AkSoundEngine.SetObjectPosition(akEvent.gameObject, akEvent.transform);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopEvent(AkEvent akEvent)
|
||||
{
|
||||
if (akEvents.Remove(akEvent))
|
||||
{
|
||||
akEvent.data.Stop(akEvent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsEventPlaying(AkEvent akEvent)
|
||||
{
|
||||
return akEvents.Contains(akEvent);
|
||||
}
|
||||
|
||||
public static void StopAll()
|
||||
{
|
||||
akEvents.Clear();
|
||||
AkSoundEngine.StopAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkEventInspector.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkEventInspector.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abd0974a5a8122641aae02ce00ad542f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
198
Assets/Wwise/Editor/WwiseComponents/AkEventPlayableInspector.cs
Normal file
198
Assets/Wwise/Editor/WwiseComponents/AkEventPlayableInspector.cs
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
#if UNITY_EDITOR
|
||||
#if !AK_DISABLE_TIMELINE
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
|
||||
[UnityEditor.CustomEditor(typeof(AkEventPlayable))]
|
||||
public class AkEventPlayableInspector : UnityEditor.Editor
|
||||
{
|
||||
private AkEventPlayable m_AkEventPlayable;
|
||||
private UnityEditor.SerializedProperty akEvent;
|
||||
private UnityEditor.SerializedProperty emitterObjectRef;
|
||||
private UnityEditor.SerializedProperty retriggerEvent;
|
||||
private UnityEditor.SerializedProperty UseWwiseEventDuration;
|
||||
private UnityEditor.SerializedProperty StopEventAtClipEnd;
|
||||
private UnityEditor.SerializedProperty blendInCurve;
|
||||
private UnityEditor.SerializedProperty blendOutCurve;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
m_AkEventPlayable = target as AkEventPlayable;
|
||||
if (m_AkEventPlayable == null)
|
||||
return;
|
||||
|
||||
akEvent = serializedObject.FindProperty("akEvent");
|
||||
emitterObjectRef = serializedObject.FindProperty("emitterObjectRef");
|
||||
retriggerEvent = serializedObject.FindProperty("retriggerEvent");
|
||||
UseWwiseEventDuration = serializedObject.FindProperty("UseWwiseEventDuration");
|
||||
StopEventAtClipEnd = serializedObject.FindProperty("StopEventAtClipEnd");
|
||||
blendInCurve = serializedObject.FindProperty("blendInCurve");
|
||||
blendOutCurve = serializedObject.FindProperty("blendOutCurve");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(AkSoundEngine.Deprecation_2019_2_0, UnityEditor.MessageType.Warning);
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(akEvent, new UnityEngine.GUIContent("Event: "));
|
||||
UnityEditor.EditorGUILayout.PropertyField(emitterObjectRef, new UnityEngine.GUIContent("Override Track Object: "));
|
||||
UnityEditor.EditorGUILayout.PropertyField(blendInCurve);
|
||||
UnityEditor.EditorGUILayout.PropertyField(blendOutCurve);
|
||||
}
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(UseWwiseEventDuration, new UnityEngine.GUIContent("Use Wwise Event Duration: ", "The clip duration is set to the duration of the Wwise Event"));
|
||||
|
||||
if (!UpdateClipInformation(m_AkEventPlayable.owningClip, m_AkEventPlayable.akEvent, serializedObject, UseWwiseEventDuration.boolValue))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(string.Format("The duration of the Wwise event \"{0}\" has not been determined. Playback for this event may be inconsistent. " +
|
||||
"Ensure that the event is associated with a generated SoundBank!", m_AkEventPlayable.akEvent.Name), UnityEditor.MessageType.Warning);
|
||||
}
|
||||
|
||||
if (!UseWwiseEventDuration.boolValue)
|
||||
{
|
||||
var StopEventAtClipEndValue = StopEventAtClipEnd.boolValue;
|
||||
var retriggerEventValue = retriggerEvent.boolValue;
|
||||
|
||||
UnityEditor.EditorGUILayout.PropertyField(StopEventAtClipEnd, new UnityEngine.GUIContent("Stop Event At End of clip: "));
|
||||
UnityEditor.EditorGUILayout.PropertyField(retriggerEvent, new UnityEngine.GUIContent("Loop: ", "When checked, an event will loop until the end of the clip."));
|
||||
|
||||
if (retriggerEvent.boolValue && !StopEventAtClipEnd.boolValue)
|
||||
{
|
||||
if (!retriggerEventValue)
|
||||
StopEventAtClipEnd.boolValue = true;
|
||||
else if (StopEventAtClipEndValue)
|
||||
retriggerEvent.boolValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static void UpdateProgressBar(int index, int count)
|
||||
{
|
||||
float progress = (float)index / count;
|
||||
UnityEditor.EditorUtility.DisplayProgressBar("Wwise Integration", "Fixing clip durations of AkEventPlayables...", progress);
|
||||
}
|
||||
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
public static void SetupSoundbankSetting()
|
||||
{
|
||||
AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", AkWwiseEditorSettings.WwiseProjectAbsolutePath);
|
||||
|
||||
UnityEditor.EditorApplication.update += RunOnce;
|
||||
AkWwiseXMLWatcher.Instance.XMLUpdated += UpdateAllClips;
|
||||
}
|
||||
|
||||
private static void RunOnce()
|
||||
{
|
||||
UpdateAllClips();
|
||||
UnityEditor.EditorApplication.update -= RunOnce;
|
||||
}
|
||||
|
||||
private static void UpdateAllClips()
|
||||
{
|
||||
var guids = UnityEditor.AssetDatabase.FindAssets("t:AkEventPlayable", new[] { "Assets" });
|
||||
if (guids.Length < 1)
|
||||
return;
|
||||
|
||||
var processedGuids = new System.Collections.Generic.HashSet<string>();
|
||||
|
||||
for (var i = 0; i < guids.Length; i++)
|
||||
{
|
||||
UpdateProgressBar(i, guids.Length);
|
||||
|
||||
var guid = guids[i];
|
||||
if (processedGuids.Contains(guid))
|
||||
continue;
|
||||
|
||||
processedGuids.Add(guid);
|
||||
|
||||
var path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
var objects = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
|
||||
var instanceIds = new System.Collections.Generic.List<int>();
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
if (obj == null)
|
||||
continue;
|
||||
|
||||
var id = obj.GetInstanceID();
|
||||
if (!instanceIds.Contains(id))
|
||||
instanceIds.Add(id);
|
||||
}
|
||||
|
||||
for (; instanceIds.Count > 0; instanceIds.RemoveAt(0))
|
||||
{
|
||||
var id = instanceIds[0];
|
||||
objects = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
if (obj && obj.GetInstanceID() == id)
|
||||
{
|
||||
var playable = obj as AkEventPlayable;
|
||||
if (playable)
|
||||
{
|
||||
var serializedObject = new UnityEditor.SerializedObject(playable);
|
||||
var setClipDuration = serializedObject.FindProperty("UseWwiseEventDuration").boolValue;
|
||||
UpdateClipInformation(playable.owningClip, playable.akEvent, serializedObject, setClipDuration);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum clip duration. This value is set to 1/60 of a second which generally represents the time of 1 frame.
|
||||
/// </summary>
|
||||
private const double MinimumDurationInSeconds = 1.0 / 60;
|
||||
|
||||
/// <summary>
|
||||
/// Updates the associated clip information and the event durations.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the Wwise event is found in the project data.</returns>
|
||||
private static bool UpdateClipInformation(UnityEngine.Timeline.TimelineClip clip, AK.Wwise.Event akEvent,
|
||||
UnityEditor.SerializedObject serializedObject, bool setClipDuration)
|
||||
{
|
||||
var clipDuration = MinimumDurationInSeconds;
|
||||
var eventInfo = AkWwiseProjectInfo.GetData().GetEventInfo(akEvent.Id);
|
||||
if (eventInfo != null)
|
||||
{
|
||||
serializedObject.FindProperty("eventDurationMin").floatValue = eventInfo.minDuration;
|
||||
serializedObject.FindProperty("eventDurationMax").floatValue = eventInfo.maxDuration;
|
||||
|
||||
if (eventInfo.maxDuration > clipDuration)
|
||||
clipDuration = eventInfo.maxDuration;
|
||||
}
|
||||
|
||||
if (clip != null)
|
||||
{
|
||||
clip.displayName = akEvent.Name;
|
||||
if (setClipDuration)
|
||||
clip.duration = clipDuration;
|
||||
}
|
||||
|
||||
return eventInfo != null && eventInfo.maxDuration > 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !AK_DISABLE_TIMELINE
|
||||
#endif //#if UNITY_EDITOR
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e0dcf9375fafaf43be30b114efb3934
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CustomPropertyDrawer(typeof(AkGameObjListenerList))]
|
||||
internal class AkGameObjListenerListDrawer : UnityEditor.PropertyDrawer
|
||||
{
|
||||
private const int listenerSpacerWidth = 4;
|
||||
private const int removeButtonWidth = 20;
|
||||
|
||||
public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
|
||||
{
|
||||
var height = (UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing) *
|
||||
2;
|
||||
var listenerListProperty = property.FindPropertyRelative("initialListenerList");
|
||||
if (listenerListProperty != null && listenerListProperty.isArray)
|
||||
{
|
||||
height += (UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing) *
|
||||
listenerListProperty.arraySize + UnityEditor.EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
|
||||
UnityEngine.GUIContent label)
|
||||
{
|
||||
// Using BeginProperty / EndProperty on the parent property means that
|
||||
// prefab override logic works on the entire property.
|
||||
UnityEditor.EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
var initialRect = position;
|
||||
|
||||
position = UnityEditor.EditorGUI.PrefixLabel(position,
|
||||
UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive),
|
||||
new UnityEngine.GUIContent("Use Default Listeners:"));
|
||||
position.height = UnityEditor.EditorGUIUtility.singleLineHeight +
|
||||
UnityEditor.EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
var useDefaultListenersProperty = property.FindPropertyRelative("useDefaultListeners");
|
||||
useDefaultListenersProperty.boolValue = UnityEngine.GUI.Toggle(position, useDefaultListenersProperty.boolValue, "");
|
||||
|
||||
var listenerListProperty = property.FindPropertyRelative("initialListenerList");
|
||||
if (listenerListProperty.isArray)
|
||||
{
|
||||
position.height = UnityEditor.EditorGUIUtility.singleLineHeight +
|
||||
UnityEditor.EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
for (var ii = 0; ii < listenerListProperty.arraySize; ++ii)
|
||||
{
|
||||
var listenerFieldWidth = initialRect.width - removeButtonWidth;
|
||||
position.y += UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing;
|
||||
position.x = initialRect.x;
|
||||
position.width = listenerFieldWidth - listenerSpacerWidth;
|
||||
|
||||
var listenerProperty = listenerListProperty.GetArrayElementAtIndex(ii);
|
||||
UnityEditor.EditorGUI.PropertyField(position, listenerProperty, new UnityEngine.GUIContent("Listener " + ii));
|
||||
|
||||
position.x = initialRect.x + listenerFieldWidth;
|
||||
position.width = removeButtonWidth;
|
||||
|
||||
if (UnityEngine.GUI.Button(position, "X"))
|
||||
{
|
||||
UnityEngine.GUIUtility.keyboardControl = 0;
|
||||
UnityEngine.GUIUtility.hotControl = 0;
|
||||
|
||||
listenerProperty.objectReferenceValue = null;
|
||||
listenerListProperty.DeleteArrayElementAtIndex(ii);
|
||||
--ii;
|
||||
}
|
||||
}
|
||||
|
||||
position.x = initialRect.x;
|
||||
position.width = initialRect.width;
|
||||
position.y += UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing +
|
||||
UnityEditor.EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (UnityEngine.GUI.Button(position, "Add Listener"))
|
||||
{
|
||||
UnityEngine.GUIUtility.keyboardControl = 0;
|
||||
UnityEngine.GUIUtility.hotControl = 0;
|
||||
|
||||
var lastPosition = listenerListProperty.arraySize;
|
||||
listenerListProperty.arraySize = lastPosition + 1;
|
||||
|
||||
// Avoid copying the previous last array element into the newly added last position
|
||||
var listenerProperty = listenerListProperty.GetArrayElementAtIndex(lastPosition);
|
||||
listenerProperty.objectReferenceValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEditor.EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a8ee090f839bf50408c83560cdb2f6fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
178
Assets/Wwise/Editor/WwiseComponents/AkGameObjectInspector.cs
Normal file
178
Assets/Wwise/Editor/WwiseComponents/AkGameObjectInspector.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class DefaultHandles
|
||||
{
|
||||
public static bool Hidden
|
||||
{
|
||||
get
|
||||
{
|
||||
var type = typeof(UnityEditor.Tools);
|
||||
var field = type.GetField("s_Hidden",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
|
||||
return (bool) field.GetValue(null);
|
||||
}
|
||||
set
|
||||
{
|
||||
var type = typeof(UnityEditor.Tools);
|
||||
var field = type.GetField("s_Hidden",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
|
||||
field.SetValue(null, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkGameObj))]
|
||||
public class AkGameObjectInspector : UnityEditor.Editor
|
||||
{
|
||||
private bool hideDefaultHandle;
|
||||
private UnityEditor.SerializedProperty listeners;
|
||||
private AkGameObj m_AkGameObject;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_AkGameObject = target as AkGameObj;
|
||||
listeners = serializedObject.FindProperty("m_listeners");
|
||||
|
||||
DefaultHandles.Hidden = hideDefaultHandle;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
DefaultHandles.Hidden = false;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// Unity tries to construct a AkGameObjPositionOffsetData all the time. Need this ugly workaround
|
||||
// to prevent it from doing this.
|
||||
if (m_AkGameObject.m_positionOffsetData != null)
|
||||
{
|
||||
if (!m_AkGameObject.m_positionOffsetData.KeepMe)
|
||||
m_AkGameObject.m_positionOffsetData = null;
|
||||
}
|
||||
|
||||
var positionOffsetData = m_AkGameObject.m_positionOffsetData;
|
||||
var positionOffset = UnityEngine.Vector3.zero;
|
||||
|
||||
UnityEditor.EditorGUI.BeginChangeCheck();
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
var applyPosOffset = UnityEditor.EditorGUILayout.Toggle("Apply Position Offset:", positionOffsetData != null);
|
||||
|
||||
if (applyPosOffset != (positionOffsetData != null))
|
||||
positionOffsetData = applyPosOffset ? new AkGameObjPositionOffsetData(true) : null;
|
||||
|
||||
if (positionOffsetData != null)
|
||||
{
|
||||
positionOffset = UnityEditor.EditorGUILayout.Vector3Field("Position Offset", positionOffsetData.positionOffset);
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
if (hideDefaultHandle)
|
||||
{
|
||||
if (UnityEngine.GUILayout.Button("Show Main Transform"))
|
||||
{
|
||||
hideDefaultHandle = false;
|
||||
DefaultHandles.Hidden = hideDefaultHandle;
|
||||
}
|
||||
}
|
||||
else if (UnityEngine.GUILayout.Button("Hide Main Transform"))
|
||||
{
|
||||
hideDefaultHandle = true;
|
||||
DefaultHandles.Hidden = hideDefaultHandle;
|
||||
}
|
||||
}
|
||||
else if (hideDefaultHandle)
|
||||
{
|
||||
hideDefaultHandle = false;
|
||||
DefaultHandles.Hidden = hideDefaultHandle;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
var isEnvironmentAware = m_AkGameObject.isEnvironmentAware;
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
isEnvironmentAware = UnityEditor.EditorGUILayout.Toggle("Environment Aware:", isEnvironmentAware);
|
||||
}
|
||||
|
||||
if (UnityEditor.EditorGUI.EndChangeCheck())
|
||||
{
|
||||
UnityEditor.Undo.RecordObject(target, "AkGameObj Parameter Change");
|
||||
|
||||
m_AkGameObject.m_positionOffsetData = positionOffsetData;
|
||||
|
||||
if (positionOffsetData != null)
|
||||
m_AkGameObject.m_positionOffsetData.positionOffset = positionOffset;
|
||||
|
||||
m_AkGameObject.isEnvironmentAware = isEnvironmentAware;
|
||||
}
|
||||
|
||||
if (isEnvironmentAware)
|
||||
RigidbodyCheck(m_AkGameObject.gameObject);
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUI.BeginChangeCheck();
|
||||
UnityEditor.EditorGUILayout.PropertyField(listeners);
|
||||
if (UnityEditor.EditorGUI.EndChangeCheck())
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public static void RigidbodyCheck(UnityEngine.GameObject gameObject)
|
||||
{
|
||||
if (AkWwiseEditorSettings.Instance.ShowMissingRigidBodyWarning && gameObject.GetComponent<UnityEngine.Rigidbody>() == null)
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(
|
||||
"Interactions between AkGameObj and AkEnvironment require a Rigidbody component on the object or the environment.",
|
||||
UnityEditor.MessageType.Warning);
|
||||
|
||||
if (UnityEngine.GUILayout.Button("Add Rigidbody"))
|
||||
{
|
||||
var rb = UnityEditor.Undo.AddComponent<UnityEngine.Rigidbody>(gameObject);
|
||||
rb.useGravity = false;
|
||||
rb.isKinematic = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
if (m_AkGameObject.m_positionOffsetData == null)
|
||||
return;
|
||||
|
||||
UnityEditor.EditorGUI.BeginChangeCheck();
|
||||
|
||||
// Transform local offset to world coordinate
|
||||
var pos = m_AkGameObject.transform.TransformPoint(m_AkGameObject.m_positionOffsetData.positionOffset);
|
||||
|
||||
// Get new handle position
|
||||
pos = UnityEditor.Handles.PositionHandle(pos, UnityEngine.Quaternion.identity);
|
||||
|
||||
if (UnityEditor.EditorGUI.EndChangeCheck())
|
||||
{
|
||||
UnityEditor.Undo.RecordObject(target, "Position Offset Change");
|
||||
|
||||
// Transform world offset to local coordinate
|
||||
m_AkGameObject.m_positionOffsetData.positionOffset = m_AkGameObject.transform.InverseTransformPoint(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad844eba12e53c64eb2d08ff39a42bf2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
191
Assets/Wwise/Editor/WwiseComponents/AkPortalManager.cs
Normal file
191
Assets/Wwise/Editor/WwiseComponents/AkPortalManager.cs
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
public class AkPortalManager
|
||||
{
|
||||
private static AkPortalManager s_portalManager;
|
||||
|
||||
public System.Collections.Generic.List<AkEnvironment> EnvironmentList =
|
||||
new System.Collections.Generic.List<AkEnvironment>();
|
||||
|
||||
public System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<AkEnvironment>>[]
|
||||
IntersectingEnvironments =
|
||||
{
|
||||
//All environments on the negative side of each portal(opposite to the direction of the chosen axis)
|
||||
new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<AkEnvironment>>(),
|
||||
//All environments on the positive side of each portal(same direction as the chosen axis)
|
||||
new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<AkEnvironment>>()
|
||||
};
|
||||
|
||||
private float m_timeStamp = UnityEngine.Time.realtimeSinceStartup;
|
||||
|
||||
public System.Collections.Generic.List<AkEnvironmentPortal> PortalList =
|
||||
new System.Collections.Generic.List<AkEnvironmentPortal>();
|
||||
|
||||
static AkPortalManager()
|
||||
{
|
||||
//This constructor is called before any game object is created when there is a compilation which makes the 'FindObjectsOfType' function return null.
|
||||
//So we register the init function to be called at hte first update.
|
||||
UnityEditor.EditorApplication.update += Init;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
//Do nothing if Manager exists
|
||||
if (s_portalManager == null)
|
||||
{
|
||||
s_portalManager = new AkPortalManager();
|
||||
s_portalManager.Populate();
|
||||
|
||||
//Register the update function to be called at each frame
|
||||
UnityEditor.EditorApplication.update += s_portalManager.UpdateEnvironments;
|
||||
}
|
||||
|
||||
//Unregister in case we were registered
|
||||
UnityEditor.EditorApplication.update -= Init;
|
||||
}
|
||||
|
||||
public static AkPortalManager GetManager()
|
||||
{
|
||||
return s_portalManager;
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
//Add all environments in the scene to the environment list
|
||||
var akEnv = UnityEngine.Object.FindObjectsOfType<AkEnvironment>();
|
||||
s_portalManager.EnvironmentList.Clear();
|
||||
s_portalManager.EnvironmentList.AddRange(akEnv);
|
||||
|
||||
//Add all portals in the scene to the portal list
|
||||
var akPortals = UnityEngine.Object.FindObjectsOfType<AkEnvironmentPortal>();
|
||||
s_portalManager.PortalList.Clear();
|
||||
s_portalManager.PortalList.AddRange(akPortals);
|
||||
|
||||
//check for portal-environment intersections and populate the IntersectingEnvironments dictionary
|
||||
for (var i = 0; i < s_portalManager.PortalList.Count; i++)
|
||||
s_portalManager.UpdatePortal(s_portalManager.PortalList[i]);
|
||||
}
|
||||
|
||||
public void UpdatePortal(AkEnvironmentPortal in_portal)
|
||||
{
|
||||
var envList = new System.Collections.Generic.List<AkEnvironment>[2];
|
||||
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (!IntersectingEnvironments[i].TryGetValue(in_portal.GetInstanceID(), out envList[i]))
|
||||
{
|
||||
envList[i] = new System.Collections.Generic.List<AkEnvironment>();
|
||||
IntersectingEnvironments[i][in_portal.GetInstanceID()] = envList[i];
|
||||
}
|
||||
else
|
||||
envList[i].Clear();
|
||||
}
|
||||
|
||||
//We check if a portal intersects any environment
|
||||
//Iterate in reverse order for safe removal form list while iterating
|
||||
for (var i = EnvironmentList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (EnvironmentList[i] != null)
|
||||
{
|
||||
//if there is an intersection
|
||||
if (in_portal.GetComponent<UnityEngine.Collider>().bounds
|
||||
.Intersects(EnvironmentList[i].GetComponent<UnityEngine.Collider>().bounds))
|
||||
{
|
||||
if (UnityEngine.Vector3.Dot(in_portal.transform.rotation * in_portal.axis,
|
||||
EnvironmentList[i].transform.position - in_portal.transform.position) >= 0)
|
||||
envList[1].Add(EnvironmentList[i]);
|
||||
else
|
||||
envList[0].Add(EnvironmentList[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
EnvironmentList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnvironment(AkEnvironment in_env)
|
||||
{
|
||||
for (var i = PortalList.Count - 1; i >= 0; i--) //Iterate in reverse order for safe removal form list while iterating
|
||||
{
|
||||
if (PortalList[i] != null)
|
||||
{
|
||||
if (in_env.GetComponent<UnityEngine.Collider>().bounds
|
||||
.Intersects(PortalList[i].GetComponent<UnityEngine.Collider>().bounds))
|
||||
{
|
||||
System.Collections.Generic.List<AkEnvironment> envList = null;
|
||||
|
||||
//Get index of the list that should contain this environment
|
||||
//Index = 0 means that the enviroment is on the negative side of the portal (opposite to the direction of the chosen axis)
|
||||
//Index = 1 means that the enviroment is on the positive side of the portal (same direction as the chosen axis)
|
||||
var index = UnityEngine.Vector3.Dot(PortalList[i].transform.rotation * PortalList[i].axis,
|
||||
in_env.transform.position - PortalList[i].transform.position) >= 0
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
if (!IntersectingEnvironments[index].TryGetValue(PortalList[i].GetInstanceID(), out envList))
|
||||
{
|
||||
envList = new System.Collections.Generic.List<AkEnvironment>();
|
||||
envList.Add(in_env);
|
||||
IntersectingEnvironments[index][PortalList[i].GetInstanceID()] = envList;
|
||||
}
|
||||
else if (!envList.Contains(in_env))
|
||||
envList.Add(in_env);
|
||||
}
|
||||
}
|
||||
else
|
||||
PortalList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEnvironments()
|
||||
{
|
||||
//Timer is reset when starting play mode and when coming back to editor mode
|
||||
if (UnityEngine.Time.realtimeSinceStartup < m_timeStamp)
|
||||
{
|
||||
m_timeStamp = UnityEngine.Time.realtimeSinceStartup;
|
||||
|
||||
//The PortalManager object doesn't get destroyed but all game objects in our lists become null
|
||||
//So we populate
|
||||
Populate();
|
||||
return;
|
||||
}
|
||||
|
||||
//The update is done once every second
|
||||
if (UnityEngine.Time.realtimeSinceStartup - m_timeStamp < 1.0f)
|
||||
return;
|
||||
|
||||
m_timeStamp = UnityEngine.Time.realtimeSinceStartup;
|
||||
|
||||
var portals = UnityEditor.Selection.GetFiltered(typeof(AkEnvironmentPortal), UnityEditor.SelectionMode.Unfiltered);
|
||||
if (portals != null)
|
||||
{
|
||||
for (var i = 0; i < portals.Length; i++)
|
||||
{
|
||||
if (!PortalList.Contains((AkEnvironmentPortal) portals[i]))
|
||||
PortalList.Add((AkEnvironmentPortal) portals[i]);
|
||||
|
||||
UpdatePortal((AkEnvironmentPortal) portals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var envs = UnityEditor.Selection.GetFiltered(typeof(AkEnvironment), UnityEditor.SelectionMode.Unfiltered);
|
||||
if (envs != null)
|
||||
{
|
||||
for (var i = 0; i < envs.Length; i++)
|
||||
{
|
||||
if (!EnvironmentList.Contains((AkEnvironment) envs[i]))
|
||||
EnvironmentList.Add((AkEnvironment) envs[i]);
|
||||
|
||||
UpdateEnvironment((AkEnvironment) envs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkPortalManager.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkPortalManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 06aa992560e26564abf806d1ee35151d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#if UNITY_EDITOR
|
||||
#if !AK_DISABLE_TIMELINE
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
|
||||
[UnityEditor.CustomEditor(typeof(AkRTPCPlayable))]
|
||||
public class AkRTPCPlayableInspector : UnityEditor.Editor
|
||||
{
|
||||
private UnityEditor.SerializedProperty Behaviour;
|
||||
private UnityEditor.SerializedProperty overrideTrackObject;
|
||||
private AkRTPCPlayable playable;
|
||||
private UnityEditor.SerializedProperty RTPCObject;
|
||||
private UnityEditor.SerializedProperty setRTPCGlobally;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
playable = target as AkRTPCPlayable;
|
||||
|
||||
setRTPCGlobally = serializedObject.FindProperty("setRTPCGlobally");
|
||||
overrideTrackObject = serializedObject.FindProperty("overrideTrackObject");
|
||||
RTPCObject = serializedObject.FindProperty("RTPCObject");
|
||||
Behaviour = serializedObject.FindProperty("template");
|
||||
|
||||
if (playable != null && playable.OwningClip != null)
|
||||
playable.OwningClip.displayName = playable.Parameter.Name;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(AkSoundEngine.Deprecation_2019_2_0, UnityEditor.MessageType.Warning);
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
if (setRTPCGlobally != null)
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(setRTPCGlobally, new UnityEngine.GUIContent("Set RTPC Globally: "));
|
||||
if (!setRTPCGlobally.boolValue)
|
||||
{
|
||||
if (overrideTrackObject != null)
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(overrideTrackObject,
|
||||
new UnityEngine.GUIContent("Override Track Object: "));
|
||||
if (overrideTrackObject.boolValue)
|
||||
{
|
||||
if (RTPCObject != null)
|
||||
UnityEditor.EditorGUILayout.PropertyField(RTPCObject, new UnityEngine.GUIContent("RTPC Object: "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Behaviour != null)
|
||||
UnityEditor.EditorGUILayout.PropertyField(Behaviour, new UnityEngine.GUIContent("Animated Value: "), true);
|
||||
|
||||
if (playable != null && playable.OwningClip != null)
|
||||
playable.OwningClip.displayName = playable.Parameter.Name;
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !AK_DISABLE_TIMELINE
|
||||
#endif //#if UNITY_EDITOR
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 809f76667a58d2243bd7eccda41aedb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Wwise/Editor/WwiseComponents/AkRTPCTrackInspector.cs
Normal file
27
Assets/Wwise/Editor/WwiseComponents/AkRTPCTrackInspector.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#if !AK_DISABLE_TIMELINE
|
||||
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
|
||||
[UnityEditor.CustomEditor(typeof(AkRTPCTrack))]
|
||||
public class AkRTPCTrackInspector : UnityEditor.Editor
|
||||
{
|
||||
private UnityEditor.SerializedProperty Parameter;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
Parameter = serializedObject.FindProperty("Parameter");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(Parameter, new UnityEngine.GUIContent("Parameter: "));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
#endif //!AK_DISABLE_TIMELINE
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d6029c4e10283f049b6bc6b59dccd15b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CustomEditor(typeof(AkRoomAwareObject))]
|
||||
public class AkRoomAwareObjectInspector : UnityEditor.Editor
|
||||
{
|
||||
private bool hideDefaultHandle;
|
||||
private UnityEditor.SerializedProperty listeners;
|
||||
private AkRoomAwareObject m_AkRoomAwareObject;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_AkRoomAwareObject = target as AkRoomAwareObject;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
RigidbodyCheck(m_AkRoomAwareObject.gameObject);
|
||||
ColliderCheck(m_AkRoomAwareObject.gameObject);
|
||||
}
|
||||
|
||||
public static void ColliderCheck(UnityEngine.GameObject gameObject)
|
||||
{
|
||||
if (AkWwiseEditorSettings.Instance.ShowSpatialAudioWarningMsg)
|
||||
{
|
||||
var collider = gameObject.GetComponent<UnityEngine.Collider>();
|
||||
if (collider == null || !collider.enabled)
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(
|
||||
"Interactions between AkRoomAwareObject and AkRoom require a Collider component on the object.",
|
||||
UnityEditor.MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RigidbodyCheck(UnityEngine.GameObject gameObject)
|
||||
{
|
||||
if (AkWwiseEditorSettings.Instance.ShowMissingRigidBodyWarning && gameObject.GetComponent<UnityEngine.Rigidbody>() == null)
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(
|
||||
"Interactions between AkRoomAwareObject and AkRoom require a Rigidbody component on the object or the room.",
|
||||
UnityEditor.MessageType.Warning);
|
||||
|
||||
if (UnityEngine.GUILayout.Button("Add Rigidbody"))
|
||||
{
|
||||
var rb = UnityEditor.Undo.AddComponent<UnityEngine.Rigidbody>(gameObject);
|
||||
rb.useGravity = false;
|
||||
rb.isKinematic = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 76e9edecbeb8fff478836541f084586e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Wwise/Editor/WwiseComponents/AkRoomInspector.cs
Normal file
61
Assets/Wwise/Editor/WwiseComponents/AkRoomInspector.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CustomEditor(typeof(AkRoom))]
|
||||
public class AkRoomInspector : UnityEditor.Editor
|
||||
{
|
||||
private readonly AkUnityEventHandlerInspector m_PostEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
|
||||
private AkRoom m_AkRoom;
|
||||
private UnityEditor.SerializedProperty priority;
|
||||
|
||||
private UnityEditor.SerializedProperty reverbAuxBus;
|
||||
private UnityEditor.SerializedProperty reverbLevel;
|
||||
private UnityEditor.SerializedProperty wallOcclusion;
|
||||
private UnityEditor.SerializedProperty roomToneEvent;
|
||||
private UnityEditor.SerializedProperty roomToneAuxSend;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_PostEventHandlerInspector.Init(serializedObject, "triggerList", "Trigger On: ", false);
|
||||
|
||||
m_AkRoom = target as AkRoom;
|
||||
|
||||
reverbAuxBus = serializedObject.FindProperty("reverbAuxBus");
|
||||
reverbLevel = serializedObject.FindProperty("reverbLevel");
|
||||
wallOcclusion = serializedObject.FindProperty("wallOcclusion");
|
||||
priority = serializedObject.FindProperty("priority");
|
||||
roomToneEvent = serializedObject.FindProperty("roomToneEvent");
|
||||
roomToneAuxSend = serializedObject.FindProperty("roomToneAuxSend");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(reverbAuxBus);
|
||||
UnityEditor.EditorGUILayout.PropertyField(reverbLevel);
|
||||
UnityEditor.EditorGUILayout.PropertyField(wallOcclusion);
|
||||
UnityEditor.EditorGUILayout.PropertyField(priority);
|
||||
}
|
||||
|
||||
UnityEditor.EditorGUILayout.LabelField("Room Tone", UnityEditor.EditorStyles.boldLabel);
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
m_PostEventHandlerInspector.OnGUI();
|
||||
UnityEditor.EditorGUILayout.PropertyField(roomToneEvent);
|
||||
UnityEditor.EditorGUILayout.PropertyField(roomToneAuxSend);
|
||||
}
|
||||
|
||||
AkRoomAwareObjectInspector.RigidbodyCheck(m_AkRoom.gameObject);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkRoomInspector.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkRoomInspector.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e40ecdd247d6c54e87e10fd7699af5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Wwise/Editor/WwiseComponents/AkRoomPortalInspector.cs
Normal file
87
Assets/Wwise/Editor/WwiseComponents/AkRoomPortalInspector.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkRoomPortal))]
|
||||
public class AkRoomPortalInspector : UnityEditor.Editor
|
||||
{
|
||||
private UnityEditor.SerializedProperty initialState;
|
||||
private UnityEditor.SerializedProperty rooms;
|
||||
|
||||
private readonly AkUnityEventHandlerInspector m_ClosePortalEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
private readonly AkUnityEventHandlerInspector m_OpenPortalEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
|
||||
private AkRoomPortal m_roomPortal;
|
||||
|
||||
[UnityEditor.MenuItem("GameObject/Wwise/Room Portal", false, 1)]
|
||||
public static void CreatePortal()
|
||||
{
|
||||
var portal = new UnityEngine.GameObject("RoomPortal");
|
||||
|
||||
UnityEditor.Undo.AddComponent<AkRoomPortal>(portal);
|
||||
portal.GetComponent<UnityEngine.Collider>().isTrigger = true;
|
||||
|
||||
UnityEditor.Selection.objects = new UnityEngine.Object[] { portal };
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
initialState = serializedObject.FindProperty("initialState");
|
||||
rooms = serializedObject.FindProperty("rooms");
|
||||
|
||||
m_OpenPortalEventHandlerInspector.Init(serializedObject, "triggerList", "Open On: ", false);
|
||||
m_ClosePortalEventHandlerInspector.Init(serializedObject, "closePortalTriggerList", "Close On: ", false);
|
||||
|
||||
m_roomPortal = target as AkRoomPortal;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(initialState);
|
||||
m_OpenPortalEventHandlerInspector.OnGUI();
|
||||
m_ClosePortalEventHandlerInspector.OnGUI();
|
||||
}
|
||||
|
||||
m_roomPortal.UpdateRooms();
|
||||
|
||||
var labels = new[] { "Back Room", "Front Room" };
|
||||
var tooltips = new[] { "The highest priority, active and enabled AkRoom component overlapping the back surface of this AkRoomPortal.",
|
||||
"The highest priority, active and enabled AkRoom component overlapping the front surface of this AkRoomPortal." };
|
||||
|
||||
var wasEnabled = UnityEngine.GUI.enabled;
|
||||
UnityEngine.GUI.enabled = false;
|
||||
|
||||
for (var i = 0; i < AkRoomPortal.MAX_ROOMS_PER_PORTAL; i++)
|
||||
UnityEditor.EditorGUILayout.PropertyField(rooms.GetArrayElementAtIndex(i), new UnityEngine.GUIContent(labels[i], tooltips[i]), true);
|
||||
|
||||
UnityEngine.GUI.enabled = wasEnabled;
|
||||
|
||||
RoomCheck(m_roomPortal);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public static void RoomCheck(AkRoomPortal portal)
|
||||
{
|
||||
if (AkWwiseEditorSettings.Instance.ShowSpatialAudioWarningMsg)
|
||||
{
|
||||
if (!portal.IsValid)
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
UnityEditor.EditorGUILayout.HelpBox(
|
||||
"Front and back rooms are identical. The AkRoomPortal will not be sent to Spatial Audio.",
|
||||
UnityEditor.MessageType.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4e5bc05f7b6298b46b06f5063baf3847
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CustomEditor(typeof(AkSpatialAudioListener))]
|
||||
public class AkSpatialAudioListenerInspector : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UnityEditor.EditorGUILayout.HelpBox(
|
||||
"The current version of Spatial Audio only supports one listener. Make sure to only have one AkSpatialAudioListener active at a time.",
|
||||
UnityEditor.MessageType.Info);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b943c187a96bfac4d86758da2faa4edf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Wwise/Editor/WwiseComponents/AkStateInspector.cs
Normal file
24
Assets/Wwise/Editor/WwiseComponents/AkStateInspector.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkState))]
|
||||
public class AkStateInspector : AkBaseInspector
|
||||
{
|
||||
private readonly AkUnityEventHandlerInspector m_UnityEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_UnityEventHandlerInspector.Init(serializedObject);
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
m_UnityEventHandlerInspector.OnGUI();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Wwise/Editor/WwiseComponents/AkStateInspector.cs.meta
Normal file
11
Assets/Wwise/Editor/WwiseComponents/AkStateInspector.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d03d5ad92777aa048a1bcd6e4193595b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Wwise/Editor/WwiseComponents/AkSwitchInspector.cs
Normal file
24
Assets/Wwise/Editor/WwiseComponents/AkSwitchInspector.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
[UnityEditor.CanEditMultipleObjects]
|
||||
[UnityEditor.CustomEditor(typeof(AkSwitch))]
|
||||
public class AkSwitchInspector : AkBaseInspector
|
||||
{
|
||||
private readonly AkUnityEventHandlerInspector m_UnityEventHandlerInspector = new AkUnityEventHandlerInspector();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_UnityEventHandlerInspector.Init(serializedObject);
|
||||
}
|
||||
|
||||
public override void OnChildInspectorGUI()
|
||||
{
|
||||
m_UnityEventHandlerInspector.OnGUI();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ee58e63ff30727448f72aa77eead843
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
#if UNITY_EDITOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class AkUnityEventHandlerInspector
|
||||
{
|
||||
private static string[] m_triggerTypeNames;
|
||||
private static uint[] m_triggerTypeIDs;
|
||||
private static System.Collections.Generic.Dictionary<uint, string> m_triggerTypes;
|
||||
|
||||
///Defines the triggers that make use of useOtherObjectMask
|
||||
private static readonly string[] useOtherObjectTriggers =
|
||||
{ "AkTriggerEnter", "AkTriggerExit", "AkTriggerCollisionEnter", "AkTriggerCollisionExit" };
|
||||
|
||||
private string m_label = "Trigger On: ";
|
||||
|
||||
private bool m_showUseOtherToggle = true;
|
||||
private UnityEditor.SerializedProperty m_triggerList;
|
||||
private UnityEditor.SerializedProperty m_useOtherObject;
|
||||
|
||||
public void Init(UnityEditor.SerializedObject in_serializedObject, string in_listName = "triggerList",
|
||||
string in_label = "Trigger On: ", bool in_showUseOtherToggle = true)
|
||||
{
|
||||
m_label = in_label;
|
||||
m_showUseOtherToggle = in_showUseOtherToggle;
|
||||
|
||||
m_triggerList = in_serializedObject.FindProperty(in_listName);
|
||||
m_useOtherObject = in_serializedObject.FindProperty("useOtherObject");
|
||||
|
||||
//Get the updated list of all triggers
|
||||
if (m_triggerTypes == null)
|
||||
{
|
||||
m_triggerTypes = AkTriggerBase.GetAllDerivedTypes();
|
||||
m_triggerTypeNames = new string[m_triggerTypes.Count];
|
||||
m_triggerTypes.Values.CopyTo(m_triggerTypeNames, 0);
|
||||
m_triggerTypeIDs = new uint[m_triggerTypes.Count];
|
||||
m_triggerTypes.Keys.CopyTo(m_triggerTypeIDs, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
|
||||
{
|
||||
var currentTriggers = GetCurrentTriggers();
|
||||
var oldMask = BuildCurrentMaskValue(currentTriggers);
|
||||
var newMask = UnityEditor.EditorGUILayout.MaskField(m_label, oldMask, m_triggerTypeNames);
|
||||
|
||||
if (oldMask != newMask)
|
||||
{
|
||||
currentTriggers.Clear();
|
||||
for (var i = 0; i < m_triggerTypeNames.Length; i++)
|
||||
{
|
||||
var curTriggerID = AkUtilities.ShortIDGenerator.Compute(m_triggerTypeNames[i]);
|
||||
if ((newMask & (1 << i)) != 0 && !currentTriggers.Contains(curTriggerID))
|
||||
currentTriggers.Add(curTriggerID);
|
||||
}
|
||||
|
||||
SaveNewTriggers(currentTriggers);
|
||||
}
|
||||
|
||||
if (m_showUseOtherToggle)
|
||||
{
|
||||
var toggleWasDisplayed = false;
|
||||
|
||||
for (var i = 0; i < m_triggerTypeNames.Length; i++)
|
||||
{
|
||||
if ((newMask & (1 << i)) != 0 && Contain(useOtherObjectTriggers, m_triggerTypeNames[i]))
|
||||
{
|
||||
UnityEditor.EditorGUILayout.PropertyField(m_useOtherObject, new UnityEngine.GUIContent("Use Other Object: "));
|
||||
toggleWasDisplayed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!toggleWasDisplayed)
|
||||
m_useOtherObject.boolValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
|
||||
}
|
||||
|
||||
private System.Collections.Generic.List<uint> GetCurrentTriggers()
|
||||
{
|
||||
var newList = new System.Collections.Generic.List<uint>();
|
||||
for (var i = 0; i < m_triggerList.arraySize; i++)
|
||||
newList.Add((uint)m_triggerList.GetArrayElementAtIndex(i).intValue);
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
private int GetIdIndex(uint in_ID)
|
||||
{
|
||||
var index = -1;
|
||||
for (var i = 0; i < m_triggerTypeIDs.Length; i++)
|
||||
{
|
||||
if (m_triggerTypeIDs[i] == in_ID)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
private int BuildCurrentMaskValue(System.Collections.Generic.List<uint> currentTriggers)
|
||||
{
|
||||
var maskToReturn = 0;
|
||||
for (var i = 0; i < currentTriggers.Count; i++)
|
||||
{
|
||||
var idIndex = GetIdIndex(currentTriggers[i]);
|
||||
if (idIndex != -1)
|
||||
maskToReturn |= 1 << idIndex;
|
||||
}
|
||||
|
||||
return maskToReturn;
|
||||
}
|
||||
|
||||
private void SaveNewTriggers(System.Collections.Generic.List<uint> currentTriggers)
|
||||
{
|
||||
m_triggerList.ClearArray();
|
||||
for (var i = 0; i < currentTriggers.Count; i++)
|
||||
{
|
||||
m_triggerList.InsertArrayElementAtIndex(i);
|
||||
m_triggerList.GetArrayElementAtIndex(i).intValue = (int) currentTriggers[i];
|
||||
}
|
||||
}
|
||||
|
||||
private bool Contain(string[] in_array, string in_value)
|
||||
{
|
||||
for (var i = 0; i < in_array.Length; i++)
|
||||
{
|
||||
if (in_array[i].Equals(in_value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4b5645b53695972468201e16d0b4f9fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue