diff --git a/.gitignore b/.gitignore index f7e2beb..53b6135 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,8 @@ crashlytics-build.properties .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -98,3 +99,21 @@ Icon Network Trash Folder Temporary Items .apdisk + +# Never ignore DLLs in the FMOD subfolder. +!/[Aa]ssets/Plugins/FMOD/**/lib/* + +# Don't ignore images and gizmos used by FMOD in the Unity Editor. +!/[Aa]ssets/Gizmos/FMOD/* +!/[Aa]ssets/Editor Default Resources/FMOD/* + +# Ignore the Cache folder since it is updated locally. +/[Aa]ssets/Plugins/FMOD/Cache/* + +# Ignore bank files in the StreamingAssets folder. +/[Aa]ssets/StreamingAssets/**/*.bank +/[Aa]ssets/StreamingAssets/**/*.bank.meta + +# If the source bank files are kept outside of the StreamingAssets folder then these can be ignored. +# Log files can be ignored. +fmod_editor.log diff --git a/Assets/5_Scenes/DreconDemo.unity b/Assets/5_Scenes/DreconDemo.unity index 3761230..38d18e1 100644 --- a/Assets/5_Scenes/DreconDemo.unity +++ b/Assets/5_Scenes/DreconDemo.unity @@ -2627,7 +2627,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &153031624 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2651,7 +2651,7 @@ MonoBehaviour: m_Lens: FieldOfView: 179 OrthographicSize: 10 - NearClipPlane: 4 + NearClipPlane: 0.1 FarClipPlane: 5000 Dutch: 0 ModeOverride: 0 @@ -4762,6 +4762,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Text: {fileID: 2115541934} + m_NarrationSFX: + Guid: + Data1: 620445385 + Data2: 1100201321 + Data3: 465179553 + Data4: -1727987524 + Path: event:/NarratorLong --- !u!1 &278102529 GameObject: m_ObjectHideFlags: 0 @@ -5276,9 +5283,9 @@ GameObject: m_Component: - component: {fileID: 330585546} - component: {fileID: 330585545} - - component: {fileID: 330585544} - component: {fileID: 330585548} - component: {fileID: 330585549} + - component: {fileID: 330585550} m_Layer: 0 m_Name: CM Brain m_TagString: MainCamera @@ -5286,14 +5293,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!81 &330585544 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330585543} - m_Enabled: 1 --- !u!20 &330585545 Camera: m_ObjectHideFlags: 0 @@ -5325,11 +5324,11 @@ Camera: y: 0 width: 1 height: 1 - near clip plane: 1 + near clip plane: 0.1 far clip plane: 5000 - field of view: 9 + field of view: 10 orthographic: 0 - orthographic size: 0.63 + orthographic size: 10 m_Depth: -1 m_CullingMask: serializedVersion: 2 @@ -5353,8 +5352,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} serializedVersion: 2 - m_LocalRotation: {x: 0.31746292, y: -0.6318365, z: 0.6318365, w: 0.31746292} - m_LocalPosition: {x: 20, y: 11.34, z: 1.87} + m_LocalRotation: {x: -0, y: 0.99859816, z: 0.052931547, w: 0} + m_LocalPosition: {x: 18.113062, y: 8.481609, z: 4.3685308} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -5523,6 +5522,19 @@ MonoBehaviour: enableFptlForForwardOpaque: 0 enableBigTilePrepass: 0 isFptlEnabled: 0 +--- !u!114 &330585550 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 330585543} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 86c6556701af9e04380698b89f691b6e, type: 3} + m_Name: + m_EditorClassIdentifier: + attenuationObject: {fileID: 0} --- !u!1 &342869235 GameObject: m_ObjectHideFlags: 0 @@ -5884,7 +5896,7 @@ MonoBehaviour: m_LookAt: {fileID: 0} m_Follow: {fileID: 0} m_Lens: - FieldOfView: 6.71 + FieldOfView: 4.64 OrthographicSize: 0.63 NearClipPlane: 0.01 FarClipPlane: 5000 @@ -7331,7 +7343,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &552738672 Transform: m_ObjectHideFlags: 0 @@ -9508,6 +9520,7 @@ Transform: m_Children: - {fileID: 756894921} - {fileID: 273313794} + - {fileID: 1403332545} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &762459446 @@ -10511,7 +10524,7 @@ MonoBehaviour: m_Lens: FieldOfView: 100 OrthographicSize: 10 - NearClipPlane: 4 + NearClipPlane: 0.01 FarClipPlane: 5000 Dutch: -95 ModeOverride: 0 @@ -13441,8 +13454,8 @@ MonoBehaviour: m_LookaheadTime: 0 m_LookaheadSmoothing: 0 m_LookaheadIgnoreY: 0 - m_HorizontalDamping: 1 - m_VerticalDamping: 1 + m_HorizontalDamping: 10.6 + m_VerticalDamping: 11 m_ScreenX: 0.5 m_ScreenY: 0.5 m_DeadZoneWidth: 0 @@ -13484,8 +13497,8 @@ MonoBehaviour: m_BindingMode: 0 m_FollowOffset: {x: 0, y: 0, z: 5} m_XDamping: 10 - m_YDamping: 1 - m_ZDamping: 0.5 + m_YDamping: 9.9 + m_ZDamping: 6 m_AngularDampingMode: 0 m_PitchDamping: 0 m_YawDamping: 0 @@ -15171,6 +15184,57 @@ Transform: m_Children: [] m_Father: {fileID: 891845390} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1403332544 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1403332545} + - component: {fileID: 1403332546} + m_Layer: 0 + m_Name: Audio Manager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1403332545 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1403332544} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 760971828} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1403332546 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1403332544} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b2f2b9ea71903e74f9f1e3023ebc6765, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Soundtrack: + Guid: + Data1: -708604503 + Data2: 1302344469 + Data3: -567375949 + Data4: 1149958008 + Path: event:/Music --- !u!1 &1411305332 GameObject: m_ObjectHideFlags: 0 @@ -21630,7 +21694,7 @@ MonoBehaviour: m_Lens: FieldOfView: 10 OrthographicSize: 10 - NearClipPlane: 4 + NearClipPlane: 1.11 FarClipPlane: 5000 Dutch: 0 ModeOverride: 0 @@ -23527,7 +23591,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext + m_text: moloch m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -23560,7 +23624,7 @@ MonoBehaviour: m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 - m_fontStyle: 2 + m_fontStyle: 8 m_HorizontalAlignment: 2 m_VerticalAlignment: 512 m_textAlignment: 65535 diff --git a/Assets/8_Scripts/1_Managers/AudioManager.cs b/Assets/8_Scripts/1_Managers/AudioManager.cs new file mode 100644 index 0000000..36ef13c --- /dev/null +++ b/Assets/8_Scripts/1_Managers/AudioManager.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using FMODUnity; +using FMOD.Studio; + +public class AudioManager : MonoBehaviour +{ + public static AudioManager instance { get; private set; } + [SerializeField] public EventReference m_Soundtrack; + + private void Awake() + { + if (instance != null) + Debug.LogError("Found more than one Audio Manager in the scene"); + instance = this; + } + + private void Start() + { + //StartSoundtrack(); + Time.timeScale = .75f; + } + + public void StartSoundtrack() + { + if (!m_Soundtrack.IsNull) + { + RuntimeManager.PlayOneShot(m_Soundtrack); + } + } + + public EventInstance PlaySound(EventReference sound) + { + EventInstance soundInst = RuntimeManager.CreateInstance(sound); + soundInst.start(); + return soundInst; + } + + public void StopSound(EventInstance soundInst) + { + soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); + soundInst.release(); + soundInst.clearHandle(); + } +} \ No newline at end of file diff --git a/Assets/8_Scripts/1_Managers/AudioManager.cs.meta b/Assets/8_Scripts/1_Managers/AudioManager.cs.meta new file mode 100644 index 0000000..b011016 --- /dev/null +++ b/Assets/8_Scripts/1_Managers/AudioManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b2f2b9ea71903e74f9f1e3023ebc6765 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8_Scripts/1_Managers/NarrationManager.cs b/Assets/8_Scripts/1_Managers/NarrationManager.cs index 657edf4..a75cfec 100644 --- a/Assets/8_Scripts/1_Managers/NarrationManager.cs +++ b/Assets/8_Scripts/1_Managers/NarrationManager.cs @@ -30,7 +30,8 @@ public class NarrationManager : MonoBehaviour { if (_instance != null) Destroy(this); - DontDestroyOnLoad(this); + else + _instance = this; } // Read in a text file, split into sentences, and add to list. diff --git a/Assets/8_Scripts/1_Managers/SubtitleManager.cs b/Assets/8_Scripts/1_Managers/SubtitleManager.cs index 86ad202..0db7d1e 100644 --- a/Assets/8_Scripts/1_Managers/SubtitleManager.cs +++ b/Assets/8_Scripts/1_Managers/SubtitleManager.cs @@ -1,16 +1,21 @@ -using Mono.Cecil; +using FMOD.Studio; +using FMODUnity; using System.Collections; using System.Collections.Generic; using TMPro; using Unity.VisualScripting; using UnityEngine; -using static UnityEngine.ParticleSystem; public class SubtitleManager : MonoBehaviour { [Header("Text")] public TMP_Text m_Text; [Header("Audio")] + [Header("Audio")] + [SerializeField] + private EventReference m_NarrationSFX; + [SerializeField] + private EventInstance m_NarrationSFXInst; private float m_TimeElapsed; @@ -35,25 +40,25 @@ public class SubtitleManager : MonoBehaviour private void UpdateText(string sentence, float waitTime) { - //FMOD.Studio.PLAYBACK_STATE state; + FMOD.Studio.PLAYBACK_STATE state; - //m_NarrationSFXInst = AudioManager.instance.PlaySound(m_NarrationSFX); + m_NarrationSFXInst = AudioManager.instance.PlaySound(m_NarrationSFX); - //m_NarrationSFXInst.getPlaybackState(out state); + m_NarrationSFXInst.getPlaybackState(out state); - //if (m_FirstRun) - //{ - // m_FirstRun = false; - // m_NarrationSFXInst.start(); - //} - //else - //{ - // m_NarrationSFXInst.getPlaybackState(out state); - // if (state == PLAYBACK_STATE.STOPPED) - // { - // m_NarrationSFXInst.start(); - // } - //} + if (m_FirstRun) + { + m_FirstRun = false; + m_NarrationSFXInst.start(); + } + else + { + m_NarrationSFXInst.getPlaybackState(out state); + if (state == PLAYBACK_STATE.STOPPED) + { + m_NarrationSFXInst.start(); + } + } StartCoroutine(TextScroll(sentence, waitTime)); } @@ -74,7 +79,7 @@ public class SubtitleManager : MonoBehaviour earlyOffset = offset / Random.Range(2, 4); offset -= earlyOffset; yield return new WaitForSecondsRealtime(earlyOffset); - //AudioManager.instance.StopSound(m_NarrationSFXInst); + AudioManager.instance.StopSound(m_NarrationSFXInst); } yield return new WaitForSecondsRealtime(offset); m_Text.text = ""; @@ -104,7 +109,7 @@ public class SubtitleManager : MonoBehaviour // // Stop audio early based on probability // if (randomStoppingValue == index && earlyStop) // { - // //AudioManager.instance.StopSound(m_NarrationSFXInst); + // AudioManager.instance.StopSound(m_NarrationSFXInst); // } //} diff --git a/Assets/8_Scripts/3_Script/Howl by Alan Ginsberg.txt b/Assets/8_Scripts/3_Script/Howl by Alan Ginsberg.txt index 546ea9e..2d5523f 100644 --- a/Assets/8_Scripts/3_Script/Howl by Alan Ginsberg.txt +++ b/Assets/8_Scripts/3_Script/Howl by Alan Ginsberg.txt @@ -1,3 +1,4 @@ + what sphinx of cement and aluminum bashed open their skulls and ate up their brains and imagination? moloch solitude diff --git a/Assets/ML-Agents/Timers/DreconDemo_timers.json b/Assets/ML-Agents/Timers/DreconDemo_timers.json index 3bfd79d..1b76723 100644 --- a/Assets/ML-Agents/Timers/DreconDemo_timers.json +++ b/Assets/ML-Agents/Timers/DreconDemo_timers.json @@ -1 +1 @@ -{"count":1,"self":11.190443199999999,"total":11.464506,"children":{"InitializeActuators":{"count":1,"self":0.000509,"total":0.000509,"children":null},"InitializeSensors":{"count":1,"self":0.0015046,"total":0.0015046,"children":null},"AgentSendState":{"count":458,"self":0.0005938,"total":0.059389899999999995,"children":{"CollectObservations":{"count":229,"self":0.048258699999999995,"total":0.048258699999999995,"children":null},"WriteActionMask":{"count":229,"self":0,"total":0,"children":null},"RequestDecision":{"count":229,"self":0.010537399999999999,"total":0.010537399999999999,"children":null}}},"DecideAction":{"count":458,"self":0.1365659,"total":0.1365659,"children":null},"AgentAct":{"count":458,"self":0.0760933,"total":0.0760933,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712239133","unity_version":"2022.3.5f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.5f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_3-Moloch\\2_Unity\\Expeirments\\Drecon2022 -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-caile -hubSessionId f88630f1-920b-4dbe-b665-558da63c889d -accessToken j9cV6YRoUof5axDzFeIFUEeVZBbcpurLrJC0wa7ct1A005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"DreconDemo","end_time_seconds":"1712239145"}} \ No newline at end of file +{"count":1,"self":114.7394176,"total":118.127117,"children":{"InitializeActuators":{"count":1,"self":0.0009998,"total":0.0009998,"children":null},"InitializeSensors":{"count":1,"self":0,"total":0,"children":null},"AgentSendState":{"count":6698,"self":0.033098499999999996,"total":1.0356267,"children":{"CollectObservations":{"count":3349,"self":0.97570309999999993,"total":0.97570309999999993,"children":null},"WriteActionMask":{"count":3349,"self":0.0042159,"total":0.0042159,"children":null},"RequestDecision":{"count":3349,"self":0.0226092,"total":0.0226092,"children":null}}},"DecideAction":{"count":6698,"self":1.4307372,"total":1.4307372,"children":null},"AgentAct":{"count":6698,"self":0.9193313,"total":0.9193313,"children":null}},"gauges":{"DReCon-v0.CumulativeReward":{"count":1,"max":66.1008759,"min":66.1008759,"runningAverage":66.1008759,"value":66.1008759,"weightedAverage":66.1008759}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712242994","unity_version":"2022.3.5f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.5f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_3-Moloch\\2_Unity\\Expeirments\\Drecon2022 -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-caile -hubSessionId f88630f1-920b-4dbe-b665-558da63c889d -accessToken j9cV6YRoUof5axDzFeIFUEeVZBbcpurLrJC0wa7ct1A005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"DreconDemo","end_time_seconds":"1712243112"}} \ No newline at end of file diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..94cf324 --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c5114318de6db6b4ca480e83310bf15e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD.meta b/Assets/Plugins/FMOD.meta new file mode 100644 index 0000000..6b217dd --- /dev/null +++ b/Assets/Plugins/FMOD.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 06ae579381df01a4a87bb149dec89954 +folderAsset: yes +timeCreated: 1429061260 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/Cache.meta b/Assets/Plugins/FMOD/Cache.meta new file mode 100644 index 0000000..e7448e7 --- /dev/null +++ b/Assets/Plugins/FMOD/Cache.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 89210a71482773245a019fb903a68096 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/FMODUnity.asmdef b/Assets/Plugins/FMOD/FMODUnity.asmdef new file mode 100644 index 0000000..ef2f0b3 --- /dev/null +++ b/Assets/Plugins/FMOD/FMODUnity.asmdef @@ -0,0 +1,45 @@ +{ + "name": "FMODUnity", + "references": [ + "Unity.Timeline", + "Unity.Addressables", + "Unity.ResourceManager", + "Unity.RenderPipelines.Universal.Runtime" + + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.timeline", + "expression": "1.0.0", + "define": "UNITY_TIMELINE_EXIST" + }, + { + "name": "com.unity.addressables", + "expression": "1.0.0", + "define": "UNITY_ADDRESSABLES_EXIST" + }, + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "UNITY_PHYSICS_EXIST" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "UNITY_PHYSICS2D_EXIST" + }, + { + "name": "com.unity.urp", + "expression": "1.0.0", + "define": "UNITY_URP_EXIST" + } + ], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Plugins/FMOD/FMODUnity.asmdef.meta b/Assets/Plugins/FMOD/FMODUnity.asmdef.meta new file mode 100644 index 0000000..5f7fa24 --- /dev/null +++ b/Assets/Plugins/FMOD/FMODUnity.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0c752da273b17c547ae705acf0f2adf2 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/LICENSE.txt b/Assets/Plugins/FMOD/LICENSE.txt new file mode 100644 index 0000000..c2f8863 --- /dev/null +++ b/Assets/Plugins/FMOD/LICENSE.txt @@ -0,0 +1,157 @@ + FMOD END USER LICENCE AGREEMENT + =============================== + +This End User Licence Agreement (EULA) is a legal agreement between you and +Firelight Technologies Pty Ltd (ACN 099 182 448) (us or we) and governs your use +of FMOD Studio Authoring Tool and FMOD Studio Engine, together the Software. + +1. GRANT OF LICENCE + +1.1 FMOD Studio Authoring Tool + +This EULA grants you the right to use FMOD Studio Authoring Tool for all use, +including Commercial use, subject to the following: + + i. FMOD Studio Authoring Tool is used to create content for use with the + FMOD Studio Engine only; + + ii. FMOD Studio Authoring Tool is not redistributed in any form. + +1.2 FMOD Studio Engine + +This EULA grants you the right to use FMOD Studio Engine, for personal +(hobbyist), educational (students and teachers) or Non-Commercial use only, +subject to the following: + + i. FMOD Studio Engine is integrated and redistributed in a software + application (Product) only; + + ii. FMOD Studio Engine is not distributed as part of a game engine or tool + set; + + iii. FMOD Studio Engine is not used in any Commercial enterprise or for any + Commercial production or subcontracting, except for the purposes of + Evaluation or Development of a Commercial Product; + + iv. Non-Commercial use does not involve any form of monetisation, + sponsorship or promotion; + + v. Product includes attribution in accordance with Clause 3. + +2.OTHER USE + +For all Commercial use, and any Non Commercial use not permitted by this +license, a separate license is required. Refer to www.fmod.com/licensing for +information. + +3. CREDITS + +All Products require an in game credit line which must include the words “FMOD +Studio” and “Firelight Technologies Pty Ltd”. Refer to www.fmod.com/attribution +for examples. + +4. INTELLECTUAL PROPERTY RIGHTS + +We are and remain at all times the owner of the Software (including all +intellectual property rights in or to the Software). For the avoidance of doubt, +nothing in this EULA may be deemed to grant or assign to you any proprietary or +ownership interest or intellectual property rights in or to the Software other +than the rights licensed pursuant to Clause 1. + +You acknowledge and agree that you have no right, title or interest in and to +the intellectual property rights in the Software. + +5. SECURITY AND RISK + +You are responsible for protecting the Software and any related materials at all +times from unauthorised access, use or damage. + +6. WARRANTY AND LIMITATION OF LIABILITY + +The Software is provided by us “as is” and, to the maximum extent permitted by +law, any express or implied warranties of any kind, including (but not limited +to) all implied warranties of merchantability and fitness for a particular +purpose are disclaimed. + +In no event shall we (and our employees, contractors and subcontractors), +developers and contributors be liable for any direct, special, indirect or +consequential damages whatsoever resulting from loss of data or profits, whether +in an action of contract, negligence or other tortious conduct, arising out of +or in connection with the use or performance of the Software. + +7. OGG VORBIS CODEC + +FMOD uses the Ogg Vorbis codec © 2002, Xiph.Org Foundation. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + i. Redistributions of source code must retain the above copyright notice, + the list of conditions and the following disclaimer. + + ii. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other material provided with the distribution. + + iii. Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +8. RESONANCE AUDIO SDK + +FMOD includes Resonance Audio SDK, licensed under the Apache Licence, Version +2.0 (the Licence); you may not use this file except in compliance with the +License. You may obtain a copy of the License at: + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +8. ANDROID PLATFORM CODE + +Copyright (C) 2010 The Android Open Source Project All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +9. AUDIOMOTORS DEMO CONTENT + +The audiogaming_audiomotors_demo_engine.agp file is provided for evaluation +purposes only and is not to be redistributed. AudioMotors V2 Pro is required to +create your own engine content. Refer to https://lesound.io for information. diff --git a/Assets/Plugins/FMOD/LICENSE.txt.meta b/Assets/Plugins/FMOD/LICENSE.txt.meta new file mode 100644 index 0000000..9d0acf8 --- /dev/null +++ b/Assets/Plugins/FMOD/LICENSE.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0804af276402ab14a96bd2aca46a568a +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/README.txt b/Assets/Plugins/FMOD/README.txt new file mode 100644 index 0000000..885c47c --- /dev/null +++ b/Assets/Plugins/FMOD/README.txt @@ -0,0 +1,14 @@ +Welcome to FMOD for Unity + +This package allows you to easily play back audio events created in FMOD Studio +within your Unity project. + +The best place to start is with our online documentation: +https://fmod.com/docs/2.02/unity + +If you prefer a more step-by-step guide, try our integration tutorial that +builds on the familiar Karting Microgame: +https://fmod.com/unity-integrate + +For support, join the conversation on our Unity forums: +https://qa.fmod.com/c/unity diff --git a/Assets/Plugins/FMOD/README.txt.meta b/Assets/Plugins/FMOD/README.txt.meta new file mode 100644 index 0000000..aedadd8 --- /dev/null +++ b/Assets/Plugins/FMOD/README.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 081074d1d9d6ab448b88688c3730e8a1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/Resources.meta b/Assets/Plugins/FMOD/Resources.meta new file mode 100644 index 0000000..dc2d6c0 --- /dev/null +++ b/Assets/Plugins/FMOD/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cae3ab6f2c16b7a4bb7a2483cf479d20 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset new file mode 100644 index 0000000..3d24a0b --- /dev/null +++ b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset @@ -0,0 +1,959 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-7182341999295018764 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3abeb1429547a134480f4f2f1efc7e21, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: c88d16e5272a4e241b0ef0ac2e53b73d + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &-5909266463515542072 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97ba6cc2660c0ca498540d254701057a, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: 2fea114e74ecf3c4f920e1d5cc1c4c40 + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &-5758646544469270795 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b87314b32fbe18943af496e4b47136c6, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: 46fbfdf3fc43db0458918377fd40293e + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &-3101377979375174063 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 17eea195bdfbf014e91ba7620ee491f8, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: e7a046c753c3c3d4aacc91f6597f310d + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &-1084653349285507691 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 335f0a4b26fb46942858ea029e030d2a, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: playInEditor + parentIdentifier: + active: 1 + Properties: + LiveUpdate: + Value: 1 + HasValue: 1 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 1 + HasValue: 1 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 48000 + HasValue: 1 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 1024 + HasValue: 1 + RealChannelCount: + Value: 256 + HasValue: 1 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &-275396404907009037 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8f591a193113347409efedcc618e83d6, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: de700ef3f37a49b58a57ae3addf01ad9 + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eef8d824ea7b63742966aaa0e94ac383, type: 3} + m_Name: FMODStudioSettings + m_EditorClassIdentifier: + switchSettingsMigration: 1 + HasSourceProject: 1 + HasPlatforms: 1 + sourceProjectPath: ../../../../../../Documents/FMOD Studio/moloch/moloch.fspro + sourceBankPath: ../../../../../../Documents/FMOD Studio/moloch/Build + sourceBankPathUnformatted: + BankRefreshCooldown: 5 + ShowBankRefreshWindow: 1 + AutomaticEventLoading: 1 + BankLoadType: 0 + AutomaticSampleLoading: 0 + EncryptionKey: + ImportType: 0 + TargetAssetPath: FMODBanks + TargetBankFolder: + EventLinkage: 0 + LoggingLevel: 2 + SpeakerModeSettings: [] + SampleRateSettings: [] + LiveUpdateSettings: [] + OverlaySettings: [] + BankDirectorySettings: [] + VirtualChannelSettings: [] + RealChannelSettings: [] + Plugins: [] + MasterBanks: + - Master + Banks: + - Music + - Narrator + - SFX + BanksToLoad: [] + LiveUpdatePort: 9264 + EnableMemoryTracking: 0 + AndroidUseOBB: 0 + AndroidPatchBuild: 0 + MeterChannelOrdering: 0 + StopEventsOutsideMaxDistance: 0 + BoltUnitOptionsBuildPending: 0 + EnableErrorCallback: 0 + SharedLibraryUpdateStage: 0 + SharedLibraryTimeSinceStart: 0 + CurrentVersion: 131617 + HideSetupWizard: 1 + LastEventReferenceScanVersion: 131617 + Platforms: + - {fileID: -1084653349285507691} + - {fileID: 3507167696192820055} + - {fileID: -5758646544469270795} + - {fileID: -5909266463515542072} + - {fileID: 5517720983551350773} + - {fileID: 2008630260488902593} + - {fileID: -275396404907009037} + - {fileID: 7907157645451068484} + - {fileID: 3283688279085925031} + - {fileID: -7182341999295018764} + - {fileID: -3101377979375174063} + - {fileID: 7415655360749205681} + MigratedPlatforms: 080000001200000006000000050000000b000000000000000a000000090000000c000000150000000200000001000000 +--- !u!114 &2008630260488902593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 73549a74f689f0849a8271d9e908c514, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: b7716510a1f36934c87976f3a81dbf3d + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &3283688279085925031 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93a382382f106584e8f8f62412fee177, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: fd7c55dab0fce234b8c25f6ffca523c1 + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &3507167696192820055 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9587379c972e4a54da1949613f11e1c6, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: default + parentIdentifier: + active: 1 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 9264 + HasValue: 1 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 1 + StaticPlugins: + Value: [] + HasValue: 1 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: + - 46fbfdf3fc43db0458918377fd40293e + - 2fea114e74ecf3c4f920e1d5cc1c4c40 + - 52eb9df5db46521439908db3a29a1bbb + - b7716510a1f36934c87976f3a81dbf3d + - de700ef3f37a49b58a57ae3addf01ad9 + - 0f8eb3f400726694eb47beb1a9f94ce8 + - fd7c55dab0fce234b8c25f6ffca523c1 + - c88d16e5272a4e241b0ef0ac2e53b73d + - e7a046c753c3c3d4aacc91f6597f310d + - 2c5177b11d81d824dbb064f9ac8527da + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &5517720983551350773 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d92d0baf34dae0e4ea032a42bd6107c0, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: 52eb9df5db46521439908db3a29a1bbb + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &7415655360749205681 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9660e62d6232af242877f0cc2b90c63d, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: 2c5177b11d81d824dbb064f9ac8527da + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 +--- !u!114 &7907157645451068484 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bc1f51bc35d549941904cf062bae93a3, type: 3} + m_Name: FMODStudioSettingsPlatform + m_EditorClassIdentifier: + identifier: 0f8eb3f400726694eb47beb1a9f94ce8 + parentIdentifier: default + active: 0 + Properties: + LiveUpdate: + Value: 0 + HasValue: 0 + LiveUpdatePort: + Value: 0 + HasValue: 0 + Overlay: + Value: 0 + HasValue: 0 + OverlayPosition: + Value: 0 + HasValue: 0 + OverlayFontSize: + Value: 0 + HasValue: 0 + Logging: + Value: 0 + HasValue: 0 + SampleRate: + Value: 0 + HasValue: 0 + BuildDirectory: + Value: + HasValue: 0 + SpeakerMode: + Value: 0 + HasValue: 0 + VirtualChannelCount: + Value: 0 + HasValue: 0 + RealChannelCount: + Value: 0 + HasValue: 0 + DSPBufferLength: + Value: 0 + HasValue: 0 + DSPBufferCount: + Value: 0 + HasValue: 0 + Plugins: + Value: [] + HasValue: 0 + StaticPlugins: + Value: [] + HasValue: 0 + CallbackHandler: + Value: {fileID: 0} + HasValue: 0 + OutputTypeName: + threadAffinities: + Value: [] + HasValue: 0 + displaySortOrder: 0 + childIdentifiers: [] + codecChannels: + Value: [] + HasValue: 0 diff --git a/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset.meta b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset.meta new file mode 100644 index 0000000..5bad0f1 --- /dev/null +++ b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 672d8d9e002bd3042bab1f7fde2df4eb +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons.meta b/Assets/Plugins/FMOD/addons.meta new file mode 100644 index 0000000..378c8d9 --- /dev/null +++ b/Assets/Plugins/FMOD/addons.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 850b7bf08237b964b8b005fe703774f9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio.meta new file mode 100644 index 0000000..fdcef73 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce39533effc93ba409e337ba540bf789 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor.meta new file mode 100644 index 0000000..6cea53f --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 93923a20291353a40809350917bab197 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef new file mode 100644 index 0000000..3063883 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef @@ -0,0 +1,17 @@ +{ + "name": "FMODUnityResonanceEditor", + "references": [ + "FMODUnityResonance" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef.meta new file mode 100644 index 0000000..8b6366f --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FMODUnityResonanceEditor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 194213485063a984b98ce9410892267a +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs new file mode 100644 index 0000000..e86ca73 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs @@ -0,0 +1,122 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; +using UnityEditor; +using System.Collections; + +namespace FMODUnityResonance +{ + /// A custom editor for properties on the FmodResonanceAudioRoom script. This appears in the + /// Inspector window of a FmodResonanceAudioRoom object. + [CustomEditor(typeof(FmodResonanceAudioRoom))] + [CanEditMultipleObjects] + public class FmodResonanceAudioRoomEditor : Editor + { + private SerializedProperty leftWall = null; + private SerializedProperty rightWall = null; + private SerializedProperty floor = null; + private SerializedProperty ceiling = null; + private SerializedProperty backWall = null; + private SerializedProperty frontWall = null; + private SerializedProperty reflectivity = null; + private SerializedProperty reverbGainDb = null; + private SerializedProperty reverbBrightness = null; + private SerializedProperty reverbTime = null; + private SerializedProperty size = null; + + private GUIContent surfaceMaterialsLabel = new GUIContent("Surface Materials", + "Room surface materials to calculate the acoustic properties of the room."); + private GUIContent surfaceMaterialLabel = new GUIContent("Surface Material", + "Surface material used to calculate the acoustic properties of the room."); + private GUIContent reflectivityLabel = new GUIContent("Reflectivity", + "Adjusts what proportion of the direct sound is reflected back by each surface, after an " + + "appropriate delay. Reverberation is unaffected by this setting."); + private GUIContent reverbGainLabel = new GUIContent("Gain (dB)", + "Applies a gain adjustment to the reverberation in the room. The default value will leave " + + "reverb unaffected."); + private GUIContent reverbPropertiesLabel = new GUIContent("Reverb Properties", + "Parameters to adjust the reverb properties of the room."); + private GUIContent reverbBrightnessLabel = new GUIContent("Brightness", + "Adjusts the balance between high and low frequencies in the reverb."); + private GUIContent reverbTimeLabel = new GUIContent("Time", + "Adjusts the overall duration of the reverb by a positive scaling factor."); + private GUIContent sizeLabel = new GUIContent("Size", "Sets the room dimensions."); + + private void OnEnable() + { + leftWall = serializedObject.FindProperty("LeftWall"); + rightWall = serializedObject.FindProperty("RightWall"); + floor = serializedObject.FindProperty("Floor"); + ceiling = serializedObject.FindProperty("Ceiling"); + backWall = serializedObject.FindProperty("BackWall"); + frontWall = serializedObject.FindProperty("FrontWall"); + reflectivity = serializedObject.FindProperty("Reflectivity"); + reverbGainDb = serializedObject.FindProperty("ReverbGainDb"); + reverbBrightness = serializedObject.FindProperty("ReverbBrightness"); + reverbTime = serializedObject.FindProperty("ReverbTime"); + size = serializedObject.FindProperty("Size"); + } + + /// @cond + public override void OnInspectorGUI() + { + serializedObject.Update(); + + // Add clickable script field, as would have been provided by DrawDefaultInspector() + MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour); + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false); + EditorGUI.EndDisabledGroup(); + + EditorGUILayout.LabelField(surfaceMaterialsLabel); + ++EditorGUI.indentLevel; + DrawSurfaceMaterial(leftWall); + DrawSurfaceMaterial(rightWall); + DrawSurfaceMaterial(floor); + DrawSurfaceMaterial(ceiling); + DrawSurfaceMaterial(backWall); + DrawSurfaceMaterial(frontWall); + --EditorGUI.indentLevel; + + EditorGUILayout.Separator(); + + EditorGUILayout.Slider(reflectivity, 0.0f, FmodResonanceAudio.MaxReflectivity, reflectivityLabel); + + EditorGUILayout.Separator(); + + EditorGUILayout.LabelField(reverbPropertiesLabel); + ++EditorGUI.indentLevel; + EditorGUILayout.Slider(reverbGainDb, FmodResonanceAudio.MinGainDb, FmodResonanceAudio.MaxGainDb, + reverbGainLabel); + EditorGUILayout.Slider(reverbBrightness, FmodResonanceAudio.MinReverbBrightness, + FmodResonanceAudio.MaxReverbBrightness, reverbBrightnessLabel); + EditorGUILayout.Slider(reverbTime, 0.0f, FmodResonanceAudio.MaxReverbTime, reverbTimeLabel); + --EditorGUI.indentLevel; + + EditorGUILayout.Separator(); + + EditorGUILayout.PropertyField(size, sizeLabel); + + serializedObject.ApplyModifiedProperties(); + } + /// @endcond + + private void DrawSurfaceMaterial(SerializedProperty surfaceMaterial) + { + surfaceMaterialLabel.text = surfaceMaterial.displayName; + EditorGUILayout.PropertyField(surfaceMaterial, surfaceMaterialLabel); + } + } +} diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs.meta new file mode 100644 index 0000000..98b5365 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Editor/FmodResonanceAudioRoomEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 935c6716e27bd481e97897dd9e1de595 +timeCreated: 1511395157 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts.meta new file mode 100644 index 0000000..3e4a638 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05a6a02c28ee77a49b6fcadf67aff3b7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef new file mode 100644 index 0000000..a23912c --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef @@ -0,0 +1,15 @@ +{ + "name": "FMODUnityResonance", + "references": [ + "FMODUnity" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef.meta new file mode 100644 index 0000000..25e9a50 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FMODUnityResonance.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 44d09cf463b68274884d8a3c8a94e528 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs new file mode 100644 index 0000000..c6c6b36 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs @@ -0,0 +1,290 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using FMODUnity; + +namespace FMODUnityResonance +{ + /// This is the main Resonance Audio class that communicates with the FMOD Unity integration. Native + /// functions of the system can only be called through this class to preserve the internal system + /// functionality. + public static class FmodResonanceAudio + { + /// Maximum allowed gain value in decibels. + public const float MaxGainDb = 24.0f; + + /// Minimum allowed gain value in decibels. + public const float MinGainDb = -24.0f; + + /// Maximum allowed reverb brightness modifier value. + public const float MaxReverbBrightness = 1.0f; + + /// Minimum allowed reverb brightness modifier value. + public const float MinReverbBrightness = -1.0f; + + /// Maximum allowed reverb time modifier value. + public const float MaxReverbTime = 3.0f; + + /// Maximum allowed reflectivity multiplier of a room surface material. + public const float MaxReflectivity = 2.0f; + + // Right-handed to left-handed matrix converter (and vice versa). + private static readonly Matrix4x4 flipZ = Matrix4x4.Scale(new Vector3(1, 1, -1)); + + // Get a handle to the Resonance Audio Listener FMOD Plugin. + private static readonly string listenerPluginName = "Resonance Audio Listener"; + + // Size of |RoomProperties| struct in bytes. + private static readonly int roomPropertiesSize = FMOD.MarshalHelper.SizeOf(typeof(RoomProperties)); + + // Plugin data parameter index for the room properties. + private static readonly int roomPropertiesIndex = 1; + + // Boundaries instance to be used in room detection logic. + private static Bounds bounds = new Bounds(Vector3.zero, Vector3.zero); + + // Container to store the currently active rooms in the scene. + private static List enabledRooms = new List(); + + // Current listener position. + private static FMOD.VECTOR listenerPositionFmod = new FMOD.VECTOR(); + + // FMOD Resonance Audio Listener Plugin. + private static FMOD.DSP listenerPlugin; + + /// Updates the room effects of the environment with given |room| properties. + /// @note This should only be called from the main Unity thread. + public static void UpdateAudioRoom(FmodResonanceAudioRoom room, bool roomEnabled) + { + // Update the enabled rooms list. + if (roomEnabled) + { + if (!enabledRooms.Contains(room)) + { + enabledRooms.Add(room); + } + } + else + { + enabledRooms.Remove(room); + } + // Update the current room effects to be applied. + if (enabledRooms.Count > 0) + { + FmodResonanceAudioRoom currentRoom = enabledRooms[enabledRooms.Count - 1]; + RoomProperties roomProperties = GetRoomProperties(currentRoom); + // Pass the room properties into a pointer. + IntPtr roomPropertiesPtr = Marshal.AllocHGlobal(roomPropertiesSize); + Marshal.StructureToPtr(roomProperties, roomPropertiesPtr, false); + ListenerPlugin.setParameterData(roomPropertiesIndex, GetBytes(roomPropertiesPtr, + roomPropertiesSize)); + Marshal.FreeHGlobal(roomPropertiesPtr); + } + else + { + // Set the room properties to a null room, which will effectively disable the room effects. + ListenerPlugin.setParameterData(roomPropertiesIndex, GetBytes(IntPtr.Zero, 0)); + } + } + + /// Returns whether the listener is currently inside the given |room| boundaries. + public static bool IsListenerInsideRoom(FmodResonanceAudioRoom room) + { + // Compute the room position relative to the listener. + FMOD.VECTOR unused; + RuntimeManager.CoreSystem.get3DListenerAttributes(0, out listenerPositionFmod, out unused, + out unused, out unused); + Vector3 listenerPosition = new Vector3(listenerPositionFmod.x, listenerPositionFmod.y, + listenerPositionFmod.z); + Vector3 relativePosition = listenerPosition - room.transform.position; + Quaternion rotationInverse = Quaternion.Inverse(room.transform.rotation); + // Set the size of the room as the boundary and return whether the listener is inside. + bounds.size = Vector3.Scale(room.transform.lossyScale, room.Size); + return bounds.Contains(rotationInverse * relativePosition); + } + + [StructLayout(LayoutKind.Sequential)] + private struct RoomProperties + { + // Center position of the room in world space. + public float PositionX; + public float PositionY; + public float PositionZ; + + // Rotation (quaternion) of the room in world space. + public float RotationX; + public float RotationY; + public float RotationZ; + public float RotationW; + + // Size of the shoebox room in world space. + public float DimensionsX; + public float DimensionsY; + public float DimensionsZ; + + // Material name of each surface of the shoebox room. + public FmodResonanceAudioRoom.SurfaceMaterial MaterialLeft; + public FmodResonanceAudioRoom.SurfaceMaterial MaterialRight; + public FmodResonanceAudioRoom.SurfaceMaterial MaterialBottom; + public FmodResonanceAudioRoom.SurfaceMaterial MaterialTop; + public FmodResonanceAudioRoom.SurfaceMaterial MaterialFront; + public FmodResonanceAudioRoom.SurfaceMaterial MaterialBack; + + // User defined uniform scaling factor for reflectivity. This parameter has no effect when set + // to 1.0f. + public float ReflectionScalar; + + // User defined reverb tail gain multiplier. This parameter has no effect when set to 0.0f. + public float ReverbGain; + + // Adjusts the reverberation time across all frequency bands. RT60 values are multiplied by this + // factor. Has no effect when set to 1.0f. + public float ReverbTime; + + // Controls the slope of a line from the lowest to the highest RT60 values (increases high + // frequency RT60s when positive, decreases when negative). Has no effect when set to 0.0f. + public float ReverbBrightness; + }; + + // Returns the FMOD Resonance Audio Listener Plugin. + private static FMOD.DSP ListenerPlugin + { + get + { + if (!listenerPlugin.hasHandle()) + { + listenerPlugin = Initialize(); + } + return listenerPlugin; + } + } + + // Converts given |db| value to its amplitude equivalent where 'dB = 20 * log10(amplitude)'. + private static float ConvertAmplitudeFromDb(float db) + { + return Mathf.Pow(10.0f, 0.05f * db); + } + + // Converts given |position| and |rotation| from Unity space to audio space. + private static void ConvertAudioTransformFromUnity(ref Vector3 position, + ref Quaternion rotation) + { + // Compose the transformation matrix. + Matrix4x4 transformMatrix = Matrix4x4.TRS(position, rotation, Vector3.one); + // Convert the transformation matrix from left-handed to right-handed. + transformMatrix = flipZ * transformMatrix * flipZ; + // Update |position| and |rotation| respectively. + position = transformMatrix.GetColumn(3); + rotation = Quaternion.LookRotation(transformMatrix.GetColumn(2), transformMatrix.GetColumn(1)); + } + + // Returns a byte array of |length| created from |ptr|. + private static byte[] GetBytes(IntPtr ptr, int length) + { + if (ptr != IntPtr.Zero) + { + byte[] byteArray = new byte[length]; + Marshal.Copy(ptr, byteArray, 0, length); + return byteArray; + } + // Return an empty array if the pointer is null. + return new byte[1]; + } + + // Returns room properties of the given |room|. + private static RoomProperties GetRoomProperties(FmodResonanceAudioRoom room) + { + RoomProperties roomProperties; + Vector3 position = room.transform.position; + Quaternion rotation = room.transform.rotation; + Vector3 scale = Vector3.Scale(room.transform.lossyScale, room.Size); + ConvertAudioTransformFromUnity(ref position, ref rotation); + roomProperties.PositionX = position.x; + roomProperties.PositionY = position.y; + roomProperties.PositionZ = position.z; + roomProperties.RotationX = rotation.x; + roomProperties.RotationY = rotation.y; + roomProperties.RotationZ = rotation.z; + roomProperties.RotationW = rotation.w; + roomProperties.DimensionsX = scale.x; + roomProperties.DimensionsY = scale.y; + roomProperties.DimensionsZ = scale.z; + roomProperties.MaterialLeft = room.LeftWall; + roomProperties.MaterialRight = room.RightWall; + roomProperties.MaterialBottom = room.Floor; + roomProperties.MaterialTop = room.Ceiling; + roomProperties.MaterialFront = room.FrontWall; + roomProperties.MaterialBack = room.BackWall; + roomProperties.ReverbGain = ConvertAmplitudeFromDb(room.ReverbGainDb); + roomProperties.ReverbTime = room.ReverbTime; + roomProperties.ReverbBrightness = room.ReverbBrightness; + roomProperties.ReflectionScalar = room.Reflectivity; + return roomProperties; + } + + // Initializes and returns the FMOD Resonance Audio Listener Plugin. + private static FMOD.DSP Initialize() + { + // Search through all busses on in banks. + int numBanks = 0; + FMOD.DSP dsp = new FMOD.DSP(); + FMOD.Studio.Bank[] banks = null; + RuntimeManager.StudioSystem.getBankCount(out numBanks); + RuntimeManager.StudioSystem.getBankList(out banks); + for (int currentBank = 0; currentBank < numBanks; ++currentBank) + { + int numBusses = 0; + FMOD.Studio.Bus[] busses = null; + banks[currentBank].getBusCount(out numBusses); + banks[currentBank].getBusList(out busses); + for (int currentBus = 0; currentBus < numBusses; ++currentBus) + { + // Make sure the channel group of the current bus is assigned properly. + string busPath = null; + busses[currentBus].getPath(out busPath); + RuntimeManager.StudioSystem.getBus(busPath, out busses[currentBus]); + busses[currentBus].lockChannelGroup(); + RuntimeManager.StudioSystem.flushCommands(); + FMOD.ChannelGroup channelGroup; + busses[currentBus].getChannelGroup(out channelGroup); + if (channelGroup.hasHandle()) + { + int numDsps = 0; + channelGroup.getNumDSPs(out numDsps); + for (int currentDsp = 0; currentDsp < numDsps; ++currentDsp) + { + channelGroup.getDSP(currentDsp, out dsp); + string dspNameSb; + int unusedInt = 0; + uint unusedUint = 0; + dsp.getInfo(out dspNameSb, out unusedUint, out unusedInt, out unusedInt, out unusedInt); + if (dspNameSb.ToString().Equals(listenerPluginName) && dsp.hasHandle()) + { + return dsp; + } + } + } + busses[currentBus].unlockChannelGroup(); + } + } + RuntimeUtils.DebugLogError(listenerPluginName + " not found in the FMOD project."); + return dsp; + } + } +} diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs.meta new file mode 100644 index 0000000..847a975 --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudio.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6794e6301575a445d8588930a0752568 +timeCreated: 1511395157 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs new file mode 100644 index 0000000..e74449c --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs @@ -0,0 +1,121 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; +using UnityEngine.Serialization; +using System.Collections; + +namespace FMODUnityResonance +{ + /// Resonance Audio room component that simulates environmental effects of a room with respect to + /// the properties of the attached game object. + [AddComponentMenu("ResonanceAudio/FmodResonanceAudioRoom")] + public class FmodResonanceAudioRoom : MonoBehaviour + { + /// Material type that determines the acoustic properties of a room surface. + public enum SurfaceMaterial + { + Transparent = 0, ///< Transparent + AcousticCeilingTiles = 1, ///< Acoustic ceiling tiles + BrickBare = 2, ///< Brick, bare + BrickPainted = 3, ///< Brick, painted + ConcreteBlockCoarse = 4, ///< Concrete block, coarse + ConcreteBlockPainted = 5, ///< Concrete block, painted + CurtainHeavy = 6, ///< Curtain, heavy + FiberglassInsulation = 7, ///< Fiberglass insulation + GlassThin = 8, ///< Glass, thin + GlassThick = 9, ///< Glass, thick + Grass = 10, ///< Grass + LinoleumOnConcrete = 11, ///< Linoleum on concrete + Marble = 12, ///< Marble + Metal = 13, ///< Galvanized sheet metal + ParquetOnConcrete = 14, ///< Parquet on concrete + PlasterRough = 15, ///< Plaster, rough + PlasterSmooth = 16, ///< Plaster, smooth + PlywoodPanel = 17, ///< Plywood panel + PolishedConcreteOrTile = 18, ///< Polished concrete or tile + Sheetrock = 19, ///< Sheetrock + WaterOrIceSurface = 20, ///< Water or ice surface + WoodCeiling = 21, ///< Wood ceiling + WoodPanel = 22 ///< Wood panel + } + + /// Room surface material in negative x direction. + [FormerlySerializedAs("leftWall")] + public SurfaceMaterial LeftWall = SurfaceMaterial.ConcreteBlockCoarse; + + /// Room surface material in positive x direction. + [FormerlySerializedAs("rightWall")] + public SurfaceMaterial RightWall = SurfaceMaterial.ConcreteBlockCoarse; + + /// Room surface material in negative y direction. + [FormerlySerializedAs("floor")] + public SurfaceMaterial Floor = SurfaceMaterial.ParquetOnConcrete; + + /// Room surface material in positive y direction. + [FormerlySerializedAs("ceiling")] + public SurfaceMaterial Ceiling = SurfaceMaterial.PlasterRough; + + /// Room surface material in negative z direction. + [FormerlySerializedAs("backWall")] + public SurfaceMaterial BackWall = SurfaceMaterial.ConcreteBlockCoarse; + + /// Room surface material in positive z direction. + [FormerlySerializedAs("frontWall")] + public SurfaceMaterial FrontWall = SurfaceMaterial.ConcreteBlockCoarse; + + /// Reflectivity scalar for each surface of the room. + [FormerlySerializedAs("reflectivity")] + public float Reflectivity = 1.0f; + + /// Reverb gain modifier in decibels. + [FormerlySerializedAs("reverbGainDb")] + public float ReverbGainDb = 0.0f; + + /// Reverb brightness modifier. + [FormerlySerializedAs("reverbBrightness")] + public float ReverbBrightness = 0.0f; + + /// Reverb time modifier. + [FormerlySerializedAs("reverbTime")] + public float ReverbTime = 1.0f; + + /// Size of the room (normalized with respect to scale of the game object). + [FormerlySerializedAs("size")] + public Vector3 Size = Vector3.one; + + private void OnEnable() + { + FmodResonanceAudio.UpdateAudioRoom(this, FmodResonanceAudio.IsListenerInsideRoom(this)); + } + + private void OnDisable() + { + FmodResonanceAudio.UpdateAudioRoom(this, false); + } + + private void Update() + { + FmodResonanceAudio.UpdateAudioRoom(this, FmodResonanceAudio.IsListenerInsideRoom(this)); + } + + private void OnDrawGizmosSelected() + { + // Draw shoebox model wireframe of the room. + Gizmos.color = Color.yellow; + Gizmos.matrix = transform.localToWorldMatrix; + Gizmos.DrawWireCube(Vector3.zero, Size); + } + } +} diff --git a/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs.meta b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs.meta new file mode 100644 index 0000000..abc3eca --- /dev/null +++ b/Assets/Plugins/FMOD/addons/ResonanceAudio/Scripts/FmodResonanceAudioRoom.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6b0c5e63920ee4f55b7ec5248525af4b +timeCreated: 1511395157 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images.meta b/Assets/Plugins/FMOD/images.meta new file mode 100644 index 0000000..1120798 --- /dev/null +++ b/Assets/Plugins/FMOD/images.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 27e5eef2bd66ffe429eebdc4579b7231 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/AddIcon.png b/Assets/Plugins/FMOD/images/AddIcon.png new file mode 100644 index 0000000..62d6e58 --- /dev/null +++ b/Assets/Plugins/FMOD/images/AddIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:860e3a60f97b4f9961eda80617e922ceffeb67aa145077ba0599863ca306a467 +size 380 diff --git a/Assets/Plugins/FMOD/images/AddIcon.png.meta b/Assets/Plugins/FMOD/images/AddIcon.png.meta new file mode 100644 index 0000000..f3f5a53 --- /dev/null +++ b/Assets/Plugins/FMOD/images/AddIcon.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 3300e81f02e64924eb7cb7782713b126 +timeCreated: 1455151837 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/ArrowIcon.png b/Assets/Plugins/FMOD/images/ArrowIcon.png new file mode 100644 index 0000000..d618441 --- /dev/null +++ b/Assets/Plugins/FMOD/images/ArrowIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ad41545295b579cf3d262f069c5b9ec48b03bd5a1f64a465b7af44272f66cb7 +size 292 diff --git a/Assets/Plugins/FMOD/images/ArrowIcon.png.meta b/Assets/Plugins/FMOD/images/ArrowIcon.png.meta new file mode 100644 index 0000000..e0695f8 --- /dev/null +++ b/Assets/Plugins/FMOD/images/ArrowIcon.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 01c0101f357b9da4ba78b8f58c290f86 +timeCreated: 1455161898 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/BankIcon.png b/Assets/Plugins/FMOD/images/BankIcon.png new file mode 100644 index 0000000..2de820b --- /dev/null +++ b/Assets/Plugins/FMOD/images/BankIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:057c16f44a3725bb4228401150c905b384ce1e1dfde6902ab074b8405c05b7c7 +size 3699 diff --git a/Assets/Plugins/FMOD/images/BankIcon.png.meta b/Assets/Plugins/FMOD/images/BankIcon.png.meta new file mode 100644 index 0000000..1d669c5 --- /dev/null +++ b/Assets/Plugins/FMOD/images/BankIcon.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: a7e06068a7215854a84bf5ed8280ed15 +timeCreated: 1433208188 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/Border.png b/Assets/Plugins/FMOD/images/Border.png new file mode 100644 index 0000000..4d9969e --- /dev/null +++ b/Assets/Plugins/FMOD/images/Border.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe700034ded2e2586d707689971698310ce5964018d1a774fb6c6ed9f9060d27 +size 179 diff --git a/Assets/Plugins/FMOD/images/Border.png.meta b/Assets/Plugins/FMOD/images/Border.png.meta new file mode 100644 index 0000000..a61b1b0 --- /dev/null +++ b/Assets/Plugins/FMOD/images/Border.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 40848578d1961334d820821bec6175a4 +timeCreated: 1455150446 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/BrowserIcon.png b/Assets/Plugins/FMOD/images/BrowserIcon.png new file mode 100644 index 0000000..6e0acd4 --- /dev/null +++ b/Assets/Plugins/FMOD/images/BrowserIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e45e42c47b7bf4214d50dcdca6ee7c7b47cce163eb948f8ffcdbf99837fe504c +size 3194 diff --git a/Assets/Plugins/FMOD/images/BrowserIcon.png.meta b/Assets/Plugins/FMOD/images/BrowserIcon.png.meta new file mode 100644 index 0000000..7af4942 --- /dev/null +++ b/Assets/Plugins/FMOD/images/BrowserIcon.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: c783b763d12874147876e070661b66ab +timeCreated: 1455688158 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png b/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png new file mode 100644 index 0000000..e317c4c --- /dev/null +++ b/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:765322a24dd9be4feda19b5338f83cfdb4250a329c7ddd6e784b4205cb9e5f40 +size 3234 diff --git a/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png.meta b/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png.meta new file mode 100644 index 0000000..e0177f1 --- /dev/null +++ b/Assets/Plugins/FMOD/images/ContinuousParameterIcon.png.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: b92803770616fc747bc3c40ffaec0a42 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/CopyIcon.png b/Assets/Plugins/FMOD/images/CopyIcon.png new file mode 100644 index 0000000..41013f2 --- /dev/null +++ b/Assets/Plugins/FMOD/images/CopyIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2b04ee62fd5d8072051bce97cf0edb1465ed43e71ac14485869297157ea05a9 +size 552 diff --git a/Assets/Plugins/FMOD/images/CopyIcon.png.meta b/Assets/Plugins/FMOD/images/CopyIcon.png.meta new file mode 100644 index 0000000..67405ae --- /dev/null +++ b/Assets/Plugins/FMOD/images/CopyIcon.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 6e164dcb85fc8ad4b9ab2f1e883862d2 +timeCreated: 1455688729 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/CrossYellow.png b/Assets/Plugins/FMOD/images/CrossYellow.png new file mode 100644 index 0000000..ab9a2f6 --- /dev/null +++ b/Assets/Plugins/FMOD/images/CrossYellow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76090493a60a8bf675e1ab27c5183fc0c1624c889ca6dfe64a703cde2187e88d +size 278 diff --git a/Assets/Plugins/FMOD/images/CrossYellow.png.meta b/Assets/Plugins/FMOD/images/CrossYellow.png.meta new file mode 100644 index 0000000..ef4e356 --- /dev/null +++ b/Assets/Plugins/FMOD/images/CrossYellow.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: 348d2265b48c67342a4db2a7062813fa +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/Delete.png b/Assets/Plugins/FMOD/images/Delete.png new file mode 100644 index 0000000..3bbc094 --- /dev/null +++ b/Assets/Plugins/FMOD/images/Delete.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ca01b263c0395dce602ba7ff5a836d7f461216d860427a0e3df55a7ab71efa6 +size 221 diff --git a/Assets/Plugins/FMOD/images/Delete.png.meta b/Assets/Plugins/FMOD/images/Delete.png.meta new file mode 100644 index 0000000..6a64cd2 --- /dev/null +++ b/Assets/Plugins/FMOD/images/Delete.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 196080340db65c44883dd3f599556fb9 +timeCreated: 1434604329 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png b/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png new file mode 100644 index 0000000..b5fd7a7 --- /dev/null +++ b/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bae2b164cbe65ba21d1d509da1f6861c82256a1e8402a7d6d265e7f98d5ebc11 +size 3041 diff --git a/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png.meta b/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png.meta new file mode 100644 index 0000000..81ee869 --- /dev/null +++ b/Assets/Plugins/FMOD/images/DiscreteParameterIcon.png.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: 509563e7079a6ed4cbf3b3240327e702 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/EventIcon.png b/Assets/Plugins/FMOD/images/EventIcon.png new file mode 100644 index 0000000..639d035 --- /dev/null +++ b/Assets/Plugins/FMOD/images/EventIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:846f36969a9193bb47cde4c12d2b39c76d3eaa9db4d8ba8b16eb76d21225f24b +size 705 diff --git a/Assets/Plugins/FMOD/images/EventIcon.png.meta b/Assets/Plugins/FMOD/images/EventIcon.png.meta new file mode 100644 index 0000000..1e4321f --- /dev/null +++ b/Assets/Plugins/FMOD/images/EventIcon.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: a602f206f9cb31f439c79a2fe23687c5 +timeCreated: 1432616010 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/FMODLogoBlack.png b/Assets/Plugins/FMOD/images/FMODLogoBlack.png new file mode 100644 index 0000000..84f5bfc --- /dev/null +++ b/Assets/Plugins/FMOD/images/FMODLogoBlack.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cece587e055d82ea2776b0ebff697ce32e024f301ed62077a573e851c75dcab +size 9688 diff --git a/Assets/Plugins/FMOD/images/FMODLogoBlack.png.meta b/Assets/Plugins/FMOD/images/FMODLogoBlack.png.meta new file mode 100644 index 0000000..8a39f85 --- /dev/null +++ b/Assets/Plugins/FMOD/images/FMODLogoBlack.png.meta @@ -0,0 +1,144 @@ +fileFormatVersion: 2 +guid: 36e46b3c334e47e41a0b4ff2f26905ea +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: PS4 + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/FMODLogoWhite.png b/Assets/Plugins/FMOD/images/FMODLogoWhite.png new file mode 100644 index 0000000..7af7037 --- /dev/null +++ b/Assets/Plugins/FMOD/images/FMODLogoWhite.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b766d70460bfa442ede86dcdaeac016650552c511be711319c94b74554a7fd9f +size 8803 diff --git a/Assets/Plugins/FMOD/images/FMODLogoWhite.png.meta b/Assets/Plugins/FMOD/images/FMODLogoWhite.png.meta new file mode 100644 index 0000000..7b306ec --- /dev/null +++ b/Assets/Plugins/FMOD/images/FMODLogoWhite.png.meta @@ -0,0 +1,144 @@ +fileFormatVersion: 2 +guid: 8fd8ccb8d7e81d943b28ea7975c7185d +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: PS4 + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/FolderIconClosed.png b/Assets/Plugins/FMOD/images/FolderIconClosed.png new file mode 100644 index 0000000..014196b --- /dev/null +++ b/Assets/Plugins/FMOD/images/FolderIconClosed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e0e2cfe75a26e20382f957b843f704ce604a0b24e5152470ebd28208cfac212 +size 2963 diff --git a/Assets/Plugins/FMOD/images/FolderIconClosed.png.meta b/Assets/Plugins/FMOD/images/FolderIconClosed.png.meta new file mode 100644 index 0000000..b1c8788 --- /dev/null +++ b/Assets/Plugins/FMOD/images/FolderIconClosed.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 70efeb6d97126f843b30b8ed62d18a4f +timeCreated: 1432621560 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/FolderIconOpen.png b/Assets/Plugins/FMOD/images/FolderIconOpen.png new file mode 100644 index 0000000..ffded31 --- /dev/null +++ b/Assets/Plugins/FMOD/images/FolderIconOpen.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a5f22962370823cae68458fcc089dd0759636aff6d1e2f45bd701d740aa5598 +size 3221 diff --git a/Assets/Plugins/FMOD/images/FolderIconOpen.png.meta b/Assets/Plugins/FMOD/images/FolderIconOpen.png.meta new file mode 100644 index 0000000..7c23994 --- /dev/null +++ b/Assets/Plugins/FMOD/images/FolderIconOpen.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: d2b54e4f7f80b9448a41d3c5985f5672 +timeCreated: 1432621574 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/LabeledParameterIcon.png b/Assets/Plugins/FMOD/images/LabeledParameterIcon.png new file mode 100644 index 0000000..bbc2757 --- /dev/null +++ b/Assets/Plugins/FMOD/images/LabeledParameterIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:929ddbd86aad8bc5ae3b466bb2f5f36ed953da22b04cbf4dd8ab8166e4ef91b4 +size 3101 diff --git a/Assets/Plugins/FMOD/images/LabeledParameterIcon.png.meta b/Assets/Plugins/FMOD/images/LabeledParameterIcon.png.meta new file mode 100644 index 0000000..0a82481 --- /dev/null +++ b/Assets/Plugins/FMOD/images/LabeledParameterIcon.png.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: b4d696e5c0be6f44bb2f02aa41320656 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/LevelMeter.png b/Assets/Plugins/FMOD/images/LevelMeter.png new file mode 100644 index 0000000..27ffcca --- /dev/null +++ b/Assets/Plugins/FMOD/images/LevelMeter.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf765236491fd508c50e16b64a19b8f27e79f2174d94c61dd2399dd39ebf8d88 +size 2685 diff --git a/Assets/Plugins/FMOD/images/LevelMeter.png.meta b/Assets/Plugins/FMOD/images/LevelMeter.png.meta new file mode 100644 index 0000000..88006b9 --- /dev/null +++ b/Assets/Plugins/FMOD/images/LevelMeter.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 21e7a3d41a926364a8b9a6704ebe80d8 +timeCreated: 1433917421 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/LevelMeterOff.png b/Assets/Plugins/FMOD/images/LevelMeterOff.png new file mode 100644 index 0000000..81068bd --- /dev/null +++ b/Assets/Plugins/FMOD/images/LevelMeterOff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e162e74d2e9c71d12514bd3199c46cb79046e2e2df315aa8bf5587f61bbd6cd +size 2194 diff --git a/Assets/Plugins/FMOD/images/LevelMeterOff.png.meta b/Assets/Plugins/FMOD/images/LevelMeterOff.png.meta new file mode 100644 index 0000000..dc84de4 --- /dev/null +++ b/Assets/Plugins/FMOD/images/LevelMeterOff.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 48dc5470d93f669419f294fcd33f7b7c +timeCreated: 1434426551 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/NotFound.png b/Assets/Plugins/FMOD/images/NotFound.png new file mode 100644 index 0000000..ca6e7b5 --- /dev/null +++ b/Assets/Plugins/FMOD/images/NotFound.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ae518102dd2ae8fab1a9bd2f526c8897de491f55f28ceb72ac3a4e0365d330d +size 3139 diff --git a/Assets/Plugins/FMOD/images/NotFound.png.meta b/Assets/Plugins/FMOD/images/NotFound.png.meta new file mode 100644 index 0000000..8f92d9a --- /dev/null +++ b/Assets/Plugins/FMOD/images/NotFound.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 1138ab068176f29499337d7a73dfecd9 +timeCreated: 1432798099 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/Preview.png b/Assets/Plugins/FMOD/images/Preview.png new file mode 100644 index 0000000..b4416d3 --- /dev/null +++ b/Assets/Plugins/FMOD/images/Preview.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5442882e67f6bd03f05d5cdaf38b12ab53099e2fc002c17ff9d75fe74d917ad1 +size 17576 diff --git a/Assets/Plugins/FMOD/images/Preview.png.meta b/Assets/Plugins/FMOD/images/Preview.png.meta new file mode 100644 index 0000000..2b0ddfe --- /dev/null +++ b/Assets/Plugins/FMOD/images/Preview.png.meta @@ -0,0 +1,56 @@ +fileFormatVersion: 2 +guid: 0793eda432fc5df4ab1291e6baacd771 +timeCreated: 1434430906 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/PreviewEmitter.png b/Assets/Plugins/FMOD/images/PreviewEmitter.png new file mode 100644 index 0000000..bbbbe10 --- /dev/null +++ b/Assets/Plugins/FMOD/images/PreviewEmitter.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d555a49c7381486bc846b226dbaedf52ae4bf3206e7f150c07756641b3228e88 +size 278 diff --git a/Assets/Plugins/FMOD/images/PreviewEmitter.png.meta b/Assets/Plugins/FMOD/images/PreviewEmitter.png.meta new file mode 100644 index 0000000..51c50d1 --- /dev/null +++ b/Assets/Plugins/FMOD/images/PreviewEmitter.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 9519043db3741934fa01455c47683e8c +timeCreated: 1434431177 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/SearchIconBlack.png b/Assets/Plugins/FMOD/images/SearchIconBlack.png new file mode 100644 index 0000000..4118e53 --- /dev/null +++ b/Assets/Plugins/FMOD/images/SearchIconBlack.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17a08ec9844a6c30a78346c21d4ea627645fa217d8e1e6ef8225885e80c663ef +size 3025 diff --git a/Assets/Plugins/FMOD/images/SearchIconBlack.png.meta b/Assets/Plugins/FMOD/images/SearchIconBlack.png.meta new file mode 100644 index 0000000..99b7987 --- /dev/null +++ b/Assets/Plugins/FMOD/images/SearchIconBlack.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: 99471facfde9fb84dbe4a81ad570ebce +timeCreated: 1434602090 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/SelectedAlt.png b/Assets/Plugins/FMOD/images/SelectedAlt.png new file mode 100644 index 0000000..b39f163 --- /dev/null +++ b/Assets/Plugins/FMOD/images/SelectedAlt.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9450a6d1836697cc7b196df8d9b829c66dc9e38400cd00e78abc0fa0d4290b84 +size 170 diff --git a/Assets/Plugins/FMOD/images/SelectedAlt.png.meta b/Assets/Plugins/FMOD/images/SelectedAlt.png.meta new file mode 100644 index 0000000..7de4e05 --- /dev/null +++ b/Assets/Plugins/FMOD/images/SelectedAlt.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 8ce9b717b1bc7564cbe35664f2f178a7 +timeCreated: 1455161898 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/SnapshotIcon.png b/Assets/Plugins/FMOD/images/SnapshotIcon.png new file mode 100644 index 0000000..86ac78d --- /dev/null +++ b/Assets/Plugins/FMOD/images/SnapshotIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a64f883f76eec0a308b9af0607394b4030b3c0b25e22afaae48779b7525c2ef9 +size 737 diff --git a/Assets/Plugins/FMOD/images/SnapshotIcon.png.meta b/Assets/Plugins/FMOD/images/SnapshotIcon.png.meta new file mode 100644 index 0000000..4cad600 --- /dev/null +++ b/Assets/Plugins/FMOD/images/SnapshotIcon.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: cf2bba5fb8be7e64ca39979f18eb372a +timeCreated: 1434600422 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/StudioIcon.png b/Assets/Plugins/FMOD/images/StudioIcon.png new file mode 100644 index 0000000..d5b631b --- /dev/null +++ b/Assets/Plugins/FMOD/images/StudioIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adb4854cc54817bc18bab8f51b6b9f5dd49220f7019877e596cb02fddf009dd8 +size 3581 diff --git a/Assets/Plugins/FMOD/images/StudioIcon.png.meta b/Assets/Plugins/FMOD/images/StudioIcon.png.meta new file mode 100644 index 0000000..5689d7b --- /dev/null +++ b/Assets/Plugins/FMOD/images/StudioIcon.png.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: a4edfa5854cdec34b98b1c55f0562bdd +timeCreated: 1434601223 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TickGreen.png b/Assets/Plugins/FMOD/images/TickGreen.png new file mode 100644 index 0000000..67a6b13 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TickGreen.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6d253361b6878408e62b8aa8da4edb6167fa97c038748f18ebad22292cb6e65 +size 244 diff --git a/Assets/Plugins/FMOD/images/TickGreen.png.meta b/Assets/Plugins/FMOD/images/TickGreen.png.meta new file mode 100644 index 0000000..0f39bc1 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TickGreen.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: 27533226416c4f549b9bec9c024100f7 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TransportOpen.png b/Assets/Plugins/FMOD/images/TransportOpen.png new file mode 100644 index 0000000..cd382e1 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportOpen.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09901dc10713d986ef1df3b28d6d637d978263f86eebd18fddb57b8d7d3cf472 +size 4234 diff --git a/Assets/Plugins/FMOD/images/TransportOpen.png.meta b/Assets/Plugins/FMOD/images/TransportOpen.png.meta new file mode 100644 index 0000000..ce8b9c9 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportOpen.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: b0fb832e401d1514a9611735d8d340b1 +timeCreated: 1453178387 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png b/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png new file mode 100644 index 0000000..382eaf7 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7235df4b7a8cc331595984bae5f2f11f18a2da8808a92cbc268454ad7836999d +size 3525 diff --git a/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png.meta b/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png.meta new file mode 100644 index 0000000..8bccd3a --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportPlayButtonOff.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 29258b1336a580946bc144df00b74ac1 +timeCreated: 1453177025 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png b/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png new file mode 100644 index 0000000..71dc6f0 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b3ef1497d5583fc59777d3e32b7f0841a1b40cad462f6c7b76e02b600cbe7d2 +size 3715 diff --git a/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png.meta b/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png.meta new file mode 100644 index 0000000..507877f --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportPlayButtonOn.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 2d777c9a14189d241aea1afeeeff448c +timeCreated: 1453177025 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TransportStopButtonOff.png b/Assets/Plugins/FMOD/images/TransportStopButtonOff.png new file mode 100644 index 0000000..7cb939f --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportStopButtonOff.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3813b737ddf9a4c4ccbad813498d029e168f5d2bdb55ac4940f380f0ef34b9b +size 3290 diff --git a/Assets/Plugins/FMOD/images/TransportStopButtonOff.png.meta b/Assets/Plugins/FMOD/images/TransportStopButtonOff.png.meta new file mode 100644 index 0000000..f287d40 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportStopButtonOff.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: cafa069c15865d543a07375373f0a18e +timeCreated: 1453177025 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/TransportStopButtonOn.png b/Assets/Plugins/FMOD/images/TransportStopButtonOn.png new file mode 100644 index 0000000..d913100 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportStopButtonOn.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b575ed82986cacca2633358315b4ff642d81fd277825afd54f4ddc5d97880b32 +size 3463 diff --git a/Assets/Plugins/FMOD/images/TransportStopButtonOn.png.meta b/Assets/Plugins/FMOD/images/TransportStopButtonOn.png.meta new file mode 100644 index 0000000..d71b3f1 --- /dev/null +++ b/Assets/Plugins/FMOD/images/TransportStopButtonOn.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: eab53cb0959d1244aadeacf8b76c755c +timeCreated: 1453177025 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: 1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/images/Wrench.png b/Assets/Plugins/FMOD/images/Wrench.png new file mode 100644 index 0000000..196c857 --- /dev/null +++ b/Assets/Plugins/FMOD/images/Wrench.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d6b8c5858c1ee781c129bd611fe94412088d7198285766ce88433901f85a22f +size 521 diff --git a/Assets/Plugins/FMOD/images/Wrench.png.meta b/Assets/Plugins/FMOD/images/Wrench.png.meta new file mode 100644 index 0000000..294315a --- /dev/null +++ b/Assets/Plugins/FMOD/images/Wrench.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: 507cd805ad331e54cb9e9cab5a9270b5 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: 1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platform_ios.mm b/Assets/Plugins/FMOD/platform_ios.mm new file mode 100644 index 0000000..2f06928 --- /dev/null +++ b/Assets/Plugins/FMOD/platform_ios.mm @@ -0,0 +1,81 @@ +#import +#import + +void (*gSuspendCallback)(bool suspend); +bool gIsSuspended = false; + +extern "C" void RegisterSuspendCallback(void (*callback)(bool)) +{ + if (!gSuspendCallback) + { + gSuspendCallback = callback; + + [[NSNotificationCenter defaultCenter] addObserverForName:AVAudioSessionInterruptionNotification object:nil queue:nil usingBlock:^(NSNotification *notification) + { + bool began = [[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] intValue] == AVAudioSessionInterruptionTypeBegan; + if (began == gIsSuspended) + { + return; + } + + if (began) + { + // Starting in iOS 10, if the system suspended the app process and deactivated the audio session + // then we get a delayed interruption notification when the app is re-activated. Just ignore that here. + if (@available(iOS 14.5, *)) + { + if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionReasonKey] intValue] == AVAudioSessionInterruptionReasonAppWasSuspended) + { + return; + } + } + else if (@available(iOS 10.3, *)) + { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionWasSuspendedKey] boolValue]) + { + return; + } +#pragma clang diagnostic pop + } + } + + gIsSuspended = began; + if (!began) + { + [[AVAudioSession sharedInstance] setActive:TRUE error:nil]; + } + if (gSuspendCallback) + { + gSuspendCallback(began); + } + }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *notification) + { +#ifndef TARGET_OS_TV + if (!gIsSuspended) + { + return; + } +#else + if (gSuspendCallback) + { + gSuspendCallback(true); + } +#endif + NSError *errorMessage; + if(![[AVAudioSession sharedInstance] setActive:TRUE error:&errorMessage]) + { + NSLog(@"UIApplicationDidBecomeActiveNotification: AVAudioSession.setActive() failed: %@", errorMessage); + return; + } + if (gSuspendCallback) + { + gSuspendCallback(false); + } + gIsSuspended = false; + }]; + } +} diff --git a/Assets/Plugins/FMOD/platform_ios.mm.meta b/Assets/Plugins/FMOD/platform_ios.mm.meta new file mode 100644 index 0000000..53d926f --- /dev/null +++ b/Assets/Plugins/FMOD/platform_ios.mm.meta @@ -0,0 +1,112 @@ +fileFormatVersion: 2 +guid: fc7eb3c9194584004bdf04921e5cb057 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 0 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + VisionOS: VisionOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + CPU: AnyCPU + FrameworkDependencies: + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms.meta b/Assets/Plugins/FMOD/platforms.meta new file mode 100644 index 0000000..d6fd594 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b617f082dd1f0645bde3b4ff3cbc25a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android.meta b/Assets/Plugins/FMOD/platforms/android.meta new file mode 100644 index 0000000..67a97ad --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca9461535f8115a4fb8293c748bcd2e1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib.meta b/Assets/Plugins/FMOD/platforms/android/lib.meta new file mode 100644 index 0000000..bce0b76 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 328160e4bc4e8b74296f830386ae016b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a.meta new file mode 100644 index 0000000..a37fe47 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54305e5cd6046514181f9b21fb0c44ed +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so new file mode 100644 index 0000000..82f7e2d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so.meta new file mode 100644 index 0000000..d701741 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmod.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 1 +guid: 159cb3726937c6c498fa49eb627b0d96 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARM64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so new file mode 100644 index 0000000..d96d7ff Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so.meta new file mode 100644 index 0000000..9606d42 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 1 +guid: 6f74d8321b529d948a7672da4ca54356 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARM64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so new file mode 100644 index 0000000..7e89cf2 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so.meta new file mode 100644 index 0000000..fe3f639 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 1 +guid: e4d6c68823f34e440bfe4e4ecba4c113 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARM64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so new file mode 100644 index 0000000..870f968 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so.meta new file mode 100644 index 0000000..2aeaca1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libfmodstudioL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 1 +guid: 85af50ee41bfd9c4fbd8107aee814c50 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARM64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so new file mode 100644 index 0000000..a77bf1a Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so.meta new file mode 100644 index 0000000..7f2ce70 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/arm64-v8a/libresonanceaudio.so.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 2bd9aca31d63ca248bf159e7562a3609 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: + CPU: ARM64 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a.meta new file mode 100644 index 0000000..87e24b5 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 49cc70c20e469a541a7974182c9f588a +folderAsset: yes +timeCreated: 1447698325 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so new file mode 100644 index 0000000..5c4afbd Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so.meta new file mode 100644 index 0000000..a5d9796 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmod.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: f71c8f89be7646142baed6d482d5e89c +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so new file mode 100644 index 0000000..256952c Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so.meta new file mode 100644 index 0000000..e65ac8c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 0e95029f987dfa248934eaa63745b504 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so new file mode 100644 index 0000000..ed8c84d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so.meta new file mode 100644 index 0000000..32a556f --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: cf01ad74bd6e5df46996c61b81ba590c +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so new file mode 100644 index 0000000..034cd1a Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so.meta new file mode 100644 index 0000000..dc7579c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libfmodstudioL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 8de47c7524234f64fb6a7d661154b1a3 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so new file mode 100644 index 0000000..162d439 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so.meta new file mode 100644 index 0000000..1a47aaa --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/armeabi-v7a/libresonanceaudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: fb0aabfc61c4c1548ac6990286c84327 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar b/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar new file mode 100644 index 0000000..2cb8485 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar.meta b/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar.meta new file mode 100644 index 0000000..19efd70 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/fmod.jar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: cba124c31f7e10640bc2ff9464f8ac15 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86.meta new file mode 100644 index 0000000..3ef5b42 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 95bcdcdca315ef640bec049de80ee3eb +folderAsset: yes +timeCreated: 1447698325 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so new file mode 100644 index 0000000..3066fa7 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so.meta new file mode 100644 index 0000000..01a0984 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmod.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 099e80baee62d0c439475fae45e69f4e +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so new file mode 100644 index 0000000..62fc841 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so.meta new file mode 100644 index 0000000..b99f6cc --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 54236e4c5b88f494598efb4d226b44f0 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so new file mode 100644 index 0000000..72a2e1b Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so.meta new file mode 100644 index 0000000..6845b41 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: a20d361b085100b4997c4e5b0b83af31 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so new file mode 100644 index 0000000..b0182ee Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so.meta new file mode 100644 index 0000000..1df26b1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86/libfmodstudioL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 0975b093811db4e4e9e67bc483ad2299 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so b/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so new file mode 100644 index 0000000..f85f8fa Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so.meta new file mode 100644 index 0000000..275946e --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86/libresonanceaudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 5c35d7fa6769b114aa63172aaf1fd782 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64.meta new file mode 100644 index 0000000..bed4933 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cec4a5a2edc0af748b10bef5d4aac727 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so new file mode 100644 index 0000000..b49be24 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so.meta new file mode 100644 index 0000000..bb9b46e --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmod.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 7b1a5b0e7617bcf49885fb2dd09d7085 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86_64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so new file mode 100644 index 0000000..cd194ce Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so.meta new file mode 100644 index 0000000..96e79ff --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 51dea0d403c47f345a6efe70b23fe6e3 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86_64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so new file mode 100644 index 0000000..98bdb60 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so.meta new file mode 100644 index 0000000..959af8c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 8c078c4748d95c2489bb3b82aa144194 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86_64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so new file mode 100644 index 0000000..d06237d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so.meta new file mode 100644 index 0000000..0ae12cc --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libfmodstudioL.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 9a5fc9953c8c261488bf0cb6c202e04b +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86_64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so new file mode 100644 index 0000000..9789f29 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so.meta b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so.meta new file mode 100644 index 0000000..fa3c00d --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/lib/x86_64/libresonanceaudio.so.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 295b4c80a560c81409d44c273128b743 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86_64 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/src.meta b/Assets/Plugins/FMOD/platforms/android/src.meta new file mode 100644 index 0000000..c06295c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 03be3f097a522854dbe1d585023925fb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs b/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs new file mode 100644 index 0000000..edbf978 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_ANDROID && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "fmod" + dllSuffix; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "fmodstudio" + dllSuffix; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformAndroid : Platform + { + static PlatformAndroid() + { + Settings.AddPlatformTemplate("2fea114e74ecf3c4f920e1d5cc1c4c40"); + } + + internal override string DisplayName { get { return "Android"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.Android, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.Android; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.Android; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("android", "Plugins/Android/libs"); + } + + private static readonly string[] Architectures = { "arm64-v8a", "armeabi-v7a", "x86", "x86_64" }; + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield return new FileRecord("fmod.jar") + .WithAbsoluteVersion(FileLayout.Release_1_10, "Plugins/Android/fmod.jar"); + + foreach (string architecture in Architectures) + { + yield return new FileRecord(string.Format("{0}/libfmod{1}.so", architecture, suffix)); + yield return new FileRecord(string.Format("{0}/libfmodstudio{1}.so", architecture, suffix)); + } + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + foreach (string architecture in Architectures) + { + yield return new FileRecord(string.Format("{0}/libgvraudio.so", architecture)); + yield return new FileRecord(string.Format("{0}/libresonanceaudio.so", architecture)); + } + } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + // Unity parses --additional-cpp arguments specified via + // PlayerSettings.SetAdditionalIl2CppArgs() incorrectly when the Android + // Export Project option is set. + return false; + } +#endif + + internal override string GetBankFolder() + { + return StaticGetBankFolder(); + } + + internal static string StaticGetBankFolder() + { + return (Settings.Instance.AndroidUseOBB || Settings.Instance.AndroidPatchBuild) + ? Application.streamingAssetsPath : "file:///android_asset"; + } + + internal override string GetPluginPath(string pluginName) + { + return StaticGetPluginPath(pluginName); + } + + internal static string StaticGetPluginPath(string pluginName) + { + return string.Format("lib{0}.so", pluginName); + } +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Java Audio Track", outputType = FMOD.OUTPUTTYPE.AUDIOTRACK }, + new OutputType() { displayName = "OpenSL ES", outputType = FMOD.OUTPUTTYPE.OPENSL }, + new OutputType() { displayName = "AAudio", outputType = FMOD.OUTPUTTYPE.AAUDIO }, + }; + + internal override int CoreCount { get { return MaximumCoreCount; } } +#endif + } +} diff --git a/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs.meta b/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs.meta new file mode 100644 index 0000000..ea89309 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/android/src/PlatformAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97ba6cc2660c0ca498540d254701057a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5.meta b/Assets/Plugins/FMOD/platforms/html5.meta new file mode 100644 index 0000000..82517eb --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e8b0cce3730fcf4e996e9cd562a9858 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib.meta b/Assets/Plugins/FMOD/platforms/html5/lib.meta new file mode 100644 index 0000000..7e944c8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b177b3448f6e68e4b9f8c04bee3914aa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19.meta b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19.meta new file mode 100644 index 0000000..8c7ea11 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54847690d6c23734ca89652cb5ad8efb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a new file mode 100644 index 0000000..6d40cd7 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a differ diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a.meta b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a.meta new file mode 100644 index 0000000..5187cc7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudio.a.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 18569240b868e8b44a20d32b2df12f5c +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + WebGL: WebGL + second: + enabled: 0 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a new file mode 100644 index 0000000..33eb9be Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a differ diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a.meta b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a.meta new file mode 100644 index 0000000..0f5921f --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib/2.0.19/libfmodstudioL.a.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 072de5b62d53c944fa2bae4cc3cd1754 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + WebGL: WebGL + second: + enabled: 0 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc new file mode 100644 index 0000000..1b706f5 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc differ diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc.meta b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc.meta new file mode 100644 index 0000000..4e2e166 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 254f6ee9df4d3024d9c550104ea5feaf +timeCreated: 1518408468 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + WebGL: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc new file mode 100644 index 0000000..4b7691e Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc differ diff --git a/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc.meta b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc.meta new file mode 100644 index 0000000..e02866f --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounitypluginL.bc.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 2dab3dda051681d4a9ea3ed67cb9877f +timeCreated: 1518408468 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + WebGL: + enabled: 0 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/src.meta b/Assets/Plugins/FMOD/platforms/html5/src.meta new file mode 100644 index 0000000..934cfff --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21a9406360b210946b0f52e8bf5ca333 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs b/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs new file mode 100644 index 0000000..3c183e1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs @@ -0,0 +1,100 @@ +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_WEBGL && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "__Internal"; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "__Internal"; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformWebGL : Platform + { + static PlatformWebGL() + { + Settings.AddPlatformTemplate("46fbfdf3fc43db0458918377fd40293e"); + } + + internal override string DisplayName { get { return "WebGL"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.WebGLPlayer, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.WebGL; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.WebGL; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("html5", "Plugins/WebGL"); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + #if UNITY_2021_2_OR_NEWER + bool useWASM = true; + #else + bool useWASM = false; + #endif + + if (allVariants || useWASM) + { + yield return new FileRecord(string.Format("2.0.19/libfmodstudio{0}.a", suffix)); + } + + if (allVariants || !useWASM) + { + yield return new FileRecord(string.Format("libfmodstudiounityplugin{0}.bc", suffix)); + } + } + + internal override bool IsFMODStaticallyLinked { get { return true; } } +#endif + + internal override string GetPluginPath(string pluginName) + { + #if UNITY_2021_2_OR_NEWER + return string.Format("{0}/{1}.a", GetPluginBasePath(), pluginName); + #else + return string.Format("{0}/{1}.bc", GetPluginBasePath(), pluginName); + #endif + } +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "JavaScript webaudio output", outputType = FMOD.OUTPUTTYPE.WEBAUDIO }, + }; +#endif + } +} diff --git a/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs.meta b/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs.meta new file mode 100644 index 0000000..ff186e1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/html5/src/PlatformWebGL.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b87314b32fbe18943af496e4b47136c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios.meta b/Assets/Plugins/FMOD/platforms/ios.meta new file mode 100644 index 0000000..db1a7b9 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 56ef07f8e7caf5f4589a020791b532cd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib.meta b/Assets/Plugins/FMOD/platforms/ios/lib.meta new file mode 100644 index 0000000..957cdc9 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf8c331b8ccdb944fa925884d9ffa69c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a new file mode 100644 index 0000000..5bded5b Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a.meta new file mode 100644 index 0000000..3873ef3 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounityplugin.a.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 79c89db1833831740aee981c0d90d2d4 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a new file mode 100644 index 0000000..9b81727 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a.meta new file mode 100644 index 0000000..1b10142 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginL.a.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 5aa4057a8deee1c45a69677125e2c241 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 0 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a new file mode 100644 index 0000000..cbfec1d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a.meta new file mode 100644 index 0000000..8f575c7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulator.a.meta @@ -0,0 +1,113 @@ +fileFormatVersion: 2 +guid: 26235204f425d41479c8e41c99e96f50 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a new file mode 100644 index 0000000..4917151 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a.meta new file mode 100644 index 0000000..5ecf686 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libfmodstudiounitypluginsimulatorL.a.meta @@ -0,0 +1,113 @@ +fileFormatVersion: 2 +guid: 9aed261b7fbc24099a9b58cbbf374583 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a new file mode 100644 index 0000000..87a9520 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a.meta new file mode 100644 index 0000000..36103b9 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudio.a.meta @@ -0,0 +1,61 @@ +fileFormatVersion: 2 +guid: bc5d15d8f7607af478126b815040cbd2 +timeCreated: 1511469552 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 0 + settings: + CPU: None + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 0 + settings: + CPU: None + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a new file mode 100644 index 0000000..657242d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a.meta b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a.meta new file mode 100644 index 0000000..ec71201 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/lib/libresonanceaudiosimulator.a.meta @@ -0,0 +1,113 @@ +fileFormatVersion: 2 +guid: 5ad1791b3b48a4ba39c30a2b4f438486 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/src.meta b/Assets/Plugins/FMOD/platforms/ios/src.meta new file mode 100644 index 0000000..7dd91fd --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb7a0bd9281687744b74c40dd220a50f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs b/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs new file mode 100644 index 0000000..11b837d --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_IPHONE && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "__Internal"; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "__Internal"; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformIOS : Platform + { + static PlatformIOS() + { + Settings.AddPlatformTemplate("0f8eb3f400726694eb47beb1a9f94ce8"); + } + + internal override string DisplayName { get { return "iOS"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.IPhonePlayer, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.iOS; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.iOS; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("ios", "Plugins/iOS"); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + if (allVariants || PlayerSettings.iOS.sdkVersion == iOSSdkVersion.DeviceSDK) + { + yield return new FileRecord(string.Format("libfmodstudiounityplugin{0}.a", suffix)); + } + + if (allVariants || PlayerSettings.iOS.sdkVersion == iOSSdkVersion.SimulatorSDK) + { + yield return new FileRecord(string.Format("libfmodstudiounitypluginsimulator{0}.a", suffix)); + } + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + if (allVariants || PlayerSettings.iOS.sdkVersion == iOSSdkVersion.DeviceSDK) + { + yield return new FileRecord("libgvraudio.a"); + yield return new FileRecord("libresonanceaudio.a"); + } + + if (allVariants || PlayerSettings.iOS.sdkVersion == iOSSdkVersion.SimulatorSDK) + { + yield return new FileRecord("libresonanceaudiosimulator.a"); + } + } + + internal override bool IsFMODStaticallyLinked { get { return true; } } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + return StaticSupportsAdditionalCpp(); + } + + public static bool StaticSupportsAdditionalCpp() + { + return false; + } +#endif + + internal override void LoadPlugins(FMOD.System coreSystem, Action reportResult) + { + StaticLoadPlugins(this, coreSystem, reportResult); + } + + public static void StaticLoadPlugins(Platform platform, FMOD.System coreSystem, + Action reportResult) + { + platform.LoadStaticPlugins(coreSystem, reportResult); + + } + +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Core Audio", outputType = FMOD.OUTPUTTYPE.COREAUDIO }, + }; +#endif + } +} diff --git a/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs.meta b/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs.meta new file mode 100644 index 0000000..41fa2df --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/ios/src/PlatformIOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc1f51bc35d549941904cf062bae93a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux.meta b/Assets/Plugins/FMOD/platforms/linux.meta new file mode 100644 index 0000000..1d182ec --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 127a9ee57a2a27a439bf9e6b2d5731b6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/lib.meta b/Assets/Plugins/FMOD/platforms/linux/lib.meta new file mode 100644 index 0000000..6da4e80 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b28687fd18577ce4c838b916a4ed5c54 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64.meta b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64.meta new file mode 100644 index 0000000..265b71a --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f99f1bb123ca3b6449fc49fc745c0fed +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so new file mode 100644 index 0000000..843e1aa Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so.meta b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so.meta new file mode 100644 index 0000000..67f8f9a --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudio.so.meta @@ -0,0 +1,65 @@ +fileFormatVersion: 2 +guid: 9063aa11b1fcfcf4cb6030a076d14a30 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 0 + settings: + CPU: None + OSXIntel64: + enabled: 0 + settings: + CPU: None + OSXUniversal: + enabled: 0 + settings: + CPU: None + SamsungTV: + enabled: 0 + settings: + STV_MODEL: STANDARD_15 + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 0 + settings: + CPU: None + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so new file mode 100644 index 0000000..6b8afbc Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so differ diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so.meta b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so.meta new file mode 100644 index 0000000..9d83d94 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libfmodstudioL.so.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: fb60b62312efdba4aa80a07a98b8a032 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + OS: Linux + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so new file mode 100644 index 0000000..1724bd3 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so differ diff --git a/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so.meta b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so.meta new file mode 100644 index 0000000..10a9902 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/lib/x86_64/libresonanceaudio.so.meta @@ -0,0 +1,69 @@ +fileFormatVersion: 2 +guid: bca6f630c310b4945b52486d2ed1da0a +timeCreated: 1511469552 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: + CPU: AnyCPU + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Linux + Linux: + enabled: 0 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: None + OSXIntel64: + enabled: 0 + settings: + CPU: None + OSXUniversal: + enabled: 0 + settings: + CPU: None + SamsungTV: + enabled: 0 + settings: + STV_MODEL: STANDARD_15 + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 0 + settings: + CPU: AnyCPU + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: \ No newline at end of file diff --git a/Assets/Plugins/FMOD/platforms/linux/src.meta b/Assets/Plugins/FMOD/platforms/linux/src.meta new file mode 100644 index 0000000..2625b93 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb8b6c816014ed44ebc2db5f8dc5e03e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs b/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs new file mode 100644 index 0000000..25a7ff1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_STANDALONE_LINUX && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "fmodstudio" + dllSuffix; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "fmodstudio" + dllSuffix; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformLinux : Platform + { + static PlatformLinux() + { + Settings.AddPlatformTemplate("b7716510a1f36934c87976f3a81dbf3d"); + } + + internal override string DisplayName { get { return "Linux"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.LinuxPlayer, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.StandaloneLinux64; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.Linux; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("linux", "Plugins"); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield return new FileRecord(string.Format("x86_64/libfmodstudio{0}.so", suffix)); + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + if (allVariants) + { + yield return new FileRecord("x86_64/libfmod.so"); + yield return new FileRecord("x86_64/libfmodL.so"); + } + + yield return new FileRecord("x86_64/libgvraudio.so"); + yield return new FileRecord("x86_64/libresonanceaudio.so"); + } + + protected override IEnumerable GetObsoleteFiles() + { + yield return "platforms/linux/lib/x86/libfmodstudio.so"; + yield return "platforms/linux/lib/x86/libfmodstudioL.so"; + } +#endif + + internal override string GetPluginPath(string pluginName) + { + return string.Format("{0}/lib{1}.so", GetPluginBasePath(), pluginName); + } + +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Pulse Audio", outputType = FMOD.OUTPUTTYPE.PULSEAUDIO }, + new OutputType() { displayName = "Advanced Linux Sound Architecture", outputType = FMOD.OUTPUTTYPE.ALSA }, + }; +#endif + + internal override List DefaultCodecChannels { get { return staticCodecChannels; } } + + private static List staticCodecChannels = new List() + { + new CodecChannelCount { format = CodecType.FADPCM, channels = 0 }, + new CodecChannelCount { format = CodecType.Vorbis, channels = 32 }, + }; + } +} diff --git a/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs.meta b/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs.meta new file mode 100644 index 0000000..f9b88e1 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/linux/src/PlatformLinux.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 73549a74f689f0849a8271d9e908c514 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac.meta b/Assets/Plugins/FMOD/platforms/mac.meta new file mode 100644 index 0000000..3bf1fba --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5dd2bfa8b9eb6874b9e50b79490891a7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib.meta b/Assets/Plugins/FMOD/platforms/mac/lib.meta new file mode 100644 index 0000000..d4b4fb8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 98f2ca7007fe2074d953e949a6fdf971 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle.meta new file mode 100644 index 0000000..12f00c6 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 4f94b6752a0d5ad489274786cbfbc6e5 +folderAsset: yes +timeCreated: 1442816865 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: OSX + Linux: + enabled: 1 + settings: + CPU: x86 + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 0 + settings: + STV_MODEL: STANDARD_13 + Win: + enabled: 1 + settings: + CPU: AnyCPU + Win64: + enabled: 1 + settings: + CPU: AnyCPU + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents.meta new file mode 100644 index 0000000..d527a58 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2879b055c8551c44caa264ce7208ea17 +folderAsset: yes +timeCreated: 1432606678 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist new file mode 100644 index 0000000..98befae --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist @@ -0,0 +1,36 @@ + + + + + BuildMachineOSBuild + 17G4015 + CFBundleDevelopmentRegion + English + CFBundleExecutable + fmodstudio + CFBundleIdentifier + com.fmod.fmodstudio + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0 + CSResourcesFileMapped + no + LSRequiresIPhoneOS + + MinimumOSVersion + 10.7 + NSHighResolutionCapable + + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist.meta new file mode 100644 index 0000000..8434f92 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fdf09afde87e8e440a6e331d1850add6 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS.meta new file mode 100644 index 0000000..8241efa --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4c7ef954631945d4981884adcc603e81 +folderAsset: yes +timeCreated: 1432606678 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio new file mode 100644 index 0000000..2245c35 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio differ diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio.meta new file mode 100644 index 0000000..c9f7db9 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/MacOS/fmodstudio.meta @@ -0,0 +1,6 @@ +fileFormatVersion: 2 +guid: c5e926e235023354fb6b94bc154a8d2c +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature.meta new file mode 100644 index 0000000..b0d36f8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0731b3df0eb593f4ebe376b7a4fe7b96 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..d5d0fd7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 0000000..ecde5de --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a7e866ce49bf582479f3675646324389 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle.meta new file mode 100644 index 0000000..336e01a --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: f945bd88ddff26547b75228cab779ac0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: AnyCPU + OS: OSX + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents.meta new file mode 100644 index 0000000..b93a3b4 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99d82b6758d211244a26db33da5df6ae +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist new file mode 100644 index 0000000..2760ee7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist @@ -0,0 +1,36 @@ + + + + + BuildMachineOSBuild + 17G4015 + CFBundleDevelopmentRegion + English + CFBundleExecutable + fmodstudioL + CFBundleIdentifier + com.fmod.fmodstudioL + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0 + CSResourcesFileMapped + no + LSRequiresIPhoneOS + + MinimumOSVersion + 10.7 + NSHighResolutionCapable + + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist.meta new file mode 100644 index 0000000..a59b05c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 28bc99f6ddbcf4149a24dfd29409a5cc +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS.meta new file mode 100644 index 0000000..9946415 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5bcb432be37dff04297a06a32bdaf5a8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL new file mode 100644 index 0000000..24736b0 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL differ diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL.meta new file mode 100644 index 0000000..71c84f6 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/MacOS/fmodstudioL.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a298d76594bb27a4b839b827b7ccc56b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature.meta new file mode 100644 index 0000000..affd343 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d1a5963d0d6bca41983f249e84c6d82 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..d5d0fd7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources.meta b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 0000000..a01fc2e --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6f4387888d43e8e459737087caf63eeb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle.meta new file mode 100644 index 0000000..345a01c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: 04e20ff877bea8747ae257229c720dcc +folderAsset: yes +timeCreated: 1511469544 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 0 + settings: + CPU: None + OSXIntel: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents.meta new file mode 100644 index 0000000..b7007ba --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a5e43a852000e2443a14695f63ceffd7 +folderAsset: yes +timeCreated: 1511469545 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist new file mode 100644 index 0000000..95ee74a --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist @@ -0,0 +1,36 @@ + + + + + BuildMachineOSBuild + 17G4015 + CFBundleDevelopmentRegion + English + CFBundleExecutable + resonanceaudio + CFBundleIdentifier + com.fmod.resonanceaudio + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0 + CSResourcesFileMapped + no + LSRequiresIPhoneOS + + MinimumOSVersion + 10.7 + NSHighResolutionCapable + + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist.meta new file mode 100644 index 0000000..b2bd0fa --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ea043299abb5407419ae750dbbee6564 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS.meta new file mode 100644 index 0000000..6039062 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 242a6e2e6d91dcf45a7ef7bdd7bfe227 +folderAsset: yes +timeCreated: 1511469545 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio new file mode 100644 index 0000000..6bfe536 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio differ diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio.meta new file mode 100644 index 0000000..7d94aec --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/MacOS/resonanceaudio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e2968e9faea7be4ea2b24d5bd144749 +timeCreated: 1511469545 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature.meta new file mode 100644 index 0000000..b5fc209 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5ff1efee5fe0cee4d969f44cbce4294f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..d5d0fd7 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources.meta b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 0000000..78599bd --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e84a173ce5cfbbe4b8d3cf667e97df31 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/src.meta b/Assets/Plugins/FMOD/platforms/mac/src.meta new file mode 100644 index 0000000..d51d5c9 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29af24c23c3906b44bbaeaa0c832f235 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs b/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs new file mode 100644 index 0000000..66802d8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; +using System.IO; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_STANDALONE_OSX && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "fmodstudio" + dllSuffix; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "fmodstudio" + dllSuffix; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformMac : Platform + { + static PlatformMac() + { + Settings.AddPlatformTemplate("52eb9df5db46521439908db3a29a1bbb"); + } + + internal override string DisplayName { get { return "macOS"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.OSXPlayer, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.StandaloneOSX; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.Mac; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("mac", "Plugins"); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield return new FileRecord(string.Format("fmodstudio{0}.bundle", suffix)); + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + yield return new FileRecord("gvraudio.bundle"); + yield return new FileRecord("resonanceaudio.bundle"); + } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + return false; + } +#endif + + internal override string GetPluginPath(string pluginName) + { + string pluginPath = string.Format("{0}/{1}.bundle", GetPluginBasePath(), pluginName); + if (System.IO.Directory.Exists((pluginPath))) + { + return pluginPath; + } + else + { + return string.Format("{0}/{1}.dylib", GetPluginBasePath(), pluginName); + } + } +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Core Audio", outputType = FMOD.OUTPUTTYPE.COREAUDIO }, + }; +#endif + + internal override List DefaultCodecChannels { get { return staticCodecChannels; } } + + private static List staticCodecChannels = new List() + { + new CodecChannelCount { format = CodecType.FADPCM, channels = 0 }, + new CodecChannelCount { format = CodecType.Vorbis, channels = 32 }, + }; + } +} diff --git a/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs.meta b/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs.meta new file mode 100644 index 0000000..68dbe88 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/mac/src/PlatformMac.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d92d0baf34dae0e4ea032a42bd6107c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos.meta b/Assets/Plugins/FMOD/platforms/tvos.meta new file mode 100644 index 0000000..7ddd670 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b878fb13ea2d16a40b79b4400b5149ba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib.meta b/Assets/Plugins/FMOD/platforms/tvos/lib.meta new file mode 100644 index 0000000..c767ae4 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3ba8f748d2f09ff46a33e76a54eb551f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a new file mode 100644 index 0000000..6d82b4f Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a differ diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a.meta b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a.meta new file mode 100644 index 0000000..856dcf3 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounityplugin.a.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: 4abc247d0f34143ec95396c7b6bec6a8 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + tvOS: + enabled: 1 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a new file mode 100644 index 0000000..b98099e Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a differ diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a.meta b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a.meta new file mode 100644 index 0000000..1ec7431 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginL.a.meta @@ -0,0 +1,20 @@ +fileFormatVersion: 2 +guid: 982978af662f9ea43b7979c7f61bbad3 +timeCreated: 1507179416 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a new file mode 100644 index 0000000..2b3f585 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a.meta b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a.meta new file mode 100644 index 0000000..c38a112 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulator.a.meta @@ -0,0 +1,113 @@ +fileFormatVersion: 2 +guid: 86d28a38815714041bf19dc4cc59ce65 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a new file mode 100644 index 0000000..e5ca874 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a differ diff --git a/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a.meta b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a.meta new file mode 100644 index 0000000..af33c6b --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/lib/libfmodstudiounitypluginsimulatorL.a.meta @@ -0,0 +1,113 @@ +fileFormatVersion: 2 +guid: 649598f6abf894e128aa33102756da99 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/src.meta b/Assets/Plugins/FMOD/platforms/tvos/src.meta new file mode 100644 index 0000000..88418f4 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a36cddbc75870b64e98ebaac7424553e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs b/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs new file mode 100644 index 0000000..71a25a8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_TVOS && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "__Internal"; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "__Internal"; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformAppleTV : Platform + { + static PlatformAppleTV() + { + Settings.AddPlatformTemplate("e7a046c753c3c3d4aacc91f6597f310d"); + } + + internal override string DisplayName { get { return "Apple TV"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.tvOS, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.tvOS; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.AppleTV; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("tvos", "Plugins/tvOS"); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + if (allVariants || PlayerSettings.tvOS.sdkVersion == tvOSSdkVersion.Device) + { + yield return new FileRecord(string.Format("libfmodstudiounityplugin{0}.a", suffix)); + } + + if (allVariants || PlayerSettings.tvOS.sdkVersion == tvOSSdkVersion.Simulator) + { + yield return new FileRecord(string.Format("libfmodstudiounitypluginsimulator{0}.a", suffix)); + } + } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + return PlatformIOS.StaticSupportsAdditionalCpp(); + } +#endif + +#if !UNITY_EDITOR + internal override void LoadPlugins(FMOD.System coreSystem, Action reportResult) + { + PlatformIOS.StaticLoadPlugins(this, coreSystem, reportResult); + } +#endif + +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Core Audio", outputType = FMOD.OUTPUTTYPE.COREAUDIO }, + }; +#endif + } +} diff --git a/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs.meta b/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs.meta new file mode 100644 index 0000000..a49dadf --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/tvos/src/PlatformAppleTV.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17eea195bdfbf014e91ba7620ee491f8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp.meta b/Assets/Plugins/FMOD/platforms/uwp.meta new file mode 100644 index 0000000..797ac19 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 76cc08b21e1f3d04e9cc8fdf3cef9eda +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib.meta b/Assets/Plugins/FMOD/platforms/uwp/lib.meta new file mode 100644 index 0000000..cfc2439 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: faacb4351a5f83845b1cea9370b4d244 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/arm.meta new file mode 100644 index 0000000..c227127 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/arm.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0cddbb9418c24f44d87fc49581769340 +folderAsset: yes +timeCreated: 1457408139 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll new file mode 100644 index 0000000..c2d105c Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll.meta new file mode 100644 index 0000000..539467c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmod.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 907f4331811d73442b58d50627a775d4 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: ARM + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll new file mode 100644 index 0000000..7251fde Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll.meta new file mode 100644 index 0000000..769b7a6 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 82bacb4b0f3cc85418d2a1aa2ca57df6 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: ARM + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll new file mode 100644 index 0000000..173dca1 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll.meta new file mode 100644 index 0000000..db9d809 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudio.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: a7c1eb40b6cc0b8468c161b5ba9a6df6 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: ARM + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll new file mode 100644 index 0000000..de563b1 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll.meta new file mode 100644 index 0000000..785578d --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/arm/fmodstudioL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 5476dd86ee3260f4bb2283aef1d9a883 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: ARM + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x64.meta new file mode 100644 index 0000000..cee6034 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x64.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 81189b2e21a815647a28e3437c86beb2 +folderAsset: yes +timeCreated: 1457064777 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll new file mode 100644 index 0000000..b3a229f Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll.meta new file mode 100644 index 0000000..f27fec3 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmod.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 68f9a982a926833498d438319388a455 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X64 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll new file mode 100644 index 0000000..12e5ec1 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll.meta new file mode 100644 index 0000000..f50278e --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: d15f9d3e1089b114a8f625e994fea839 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X64 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll new file mode 100644 index 0000000..56e774b Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll.meta new file mode 100644 index 0000000..eea7d12 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudio.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 29800d7cce1a5fc46ae163c8a68d8346 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X64 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll new file mode 100644 index 0000000..785f13e Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll.meta new file mode 100644 index 0000000..7b34777 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x64/fmodstudioL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 813ca429588de5d40b5c8a184a15bcd9 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X64 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x86.meta new file mode 100644 index 0000000..5ef6d14 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x86.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fa5c1a42d40246b4a83af1e8192b6bdf +folderAsset: yes +timeCreated: 1457063023 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll new file mode 100644 index 0000000..22bf4c0 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll.meta new file mode 100644 index 0000000..92ded47 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmod.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 39f9a761a2a032045a853a069db31081 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X86 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll new file mode 100644 index 0000000..b7cca9d Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll.meta new file mode 100644 index 0000000..cb53015 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 243e8fba07980f74b8d49ef345dadd64 +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X86 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll new file mode 100644 index 0000000..9f91c77 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll.meta new file mode 100644 index 0000000..b9996f4 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudio.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: ecb0cc0019197154b9baeef623b6ec0a +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X86 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll new file mode 100644 index 0000000..6825799 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll.meta b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll.meta new file mode 100644 index 0000000..6ec5c6d --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/uwp/lib/x86/fmodstudioL.dll.meta @@ -0,0 +1,58 @@ +fileFormatVersion: 2 +guid: 43ab9a198caf2d841b813eb81e02486d +timeCreated: 1457408139 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: X86 + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos.meta b/Assets/Plugins/FMOD/platforms/visionos.meta new file mode 100644 index 0000000..5bffd1c --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c0af21c1e7f184d6f860c5bb39642057 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib.meta b/Assets/Plugins/FMOD/platforms/visionos/lib.meta new file mode 100644 index 0000000..45f9180 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b847b610a434440b0854bdda3a8522fe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a new file mode 100644 index 0000000..51279e4 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a.meta new file mode 100644 index 0000000..b70ffcf --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xros.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: 240b87501d4c14726b85b03230183106 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a new file mode 100644 index 0000000..2bc9bd1 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a.meta new file mode 100644 index 0000000..c285a5e --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudioL_xrsimulator.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: cc7984acfd746420c810ab83b89887c4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a new file mode 100644 index 0000000..d446f66 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a.meta new file mode 100644 index 0000000..546c988 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xros.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: b06ee804ac1c44c538ef636ef4e034c1 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a new file mode 100644 index 0000000..adce1fe Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a.meta new file mode 100644 index 0000000..620add3 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libfmodstudio_xrsimulator.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: da47e54c091124c7baa78e13f90216f3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a new file mode 100644 index 0000000..fcdfeb7 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a.meta new file mode 100644 index 0000000..d53c937 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xros.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: c56aac88d64894d01a74d1cf8f609da6 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a new file mode 100644 index 0000000..ed183d5 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a differ diff --git a/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a.meta b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a.meta new file mode 100644 index 0000000..92f85c8 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/lib/libresonanceaudio_xrsimulator.a.meta @@ -0,0 +1,73 @@ +fileFormatVersion: 2 +guid: ab84f09ed56d54cd3867c72395f7658c +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + VisionOS: VisionOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: ARM64 + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/src.meta b/Assets/Plugins/FMOD/platforms/visionos/src.meta new file mode 100644 index 0000000..0d0d591 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dbc65c69ec16043268c63c40c92f8bf0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs b/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs new file mode 100644 index 0000000..84232ff --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_VISIONOS && !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "__Internal"; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "__Internal"; + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformVisionOS : Platform + { + static PlatformVisionOS() + { + Settings.AddPlatformTemplate("de700ef3f37a49b58a57ae3addf01ad9"); + } + + internal override string DisplayName { get { return "visionOS"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + #if UNITY_VISIONOS + settings.DeclareRuntimePlatform(RuntimePlatform.VisionOS, this); + #endif + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + #if UNITY_VISIONOS + yield return BuildTarget.VisionOS; + #else + yield return BuildTarget.NoTarget; + #endif + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.None; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return new BinaryAssetFolderInfo("visionos", FileLayout.Release_2_2); + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + #if UNITY_VISIONOS + if (allVariants || PlayerSettings.VisionOS.sdkVersion == VisionOSSdkVersion.Device) + #endif + { + yield return new FileRecord(string.Format("libfmodstudio{0}_xros.a", suffix)); + } + + #if UNITY_VISIONOS + if (allVariants || PlayerSettings.VisionOS.sdkVersion == VisionOSSdkVersion.Simulator) + #endif + { + yield return new FileRecord(string.Format("libfmodstudio{0}_xrsimulator.a", suffix)); + } + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + #if UNITY_VISIONOS + if (allVariants || PlayerSettings.VisionOS.sdkVersion == VisionOSSdkVersion.Device) + #endif + { + yield return new FileRecord("libresonanceaudio_xros.a"); + } + + #if UNITY_VISIONOS + if (allVariants || PlayerSettings.VisionOS.sdkVersion == VisionOSSdkVersion.Simulator) + #endif + { + yield return new FileRecord("libresonanceaudio_xrsimulator.a"); + } + } + + internal override bool IsFMODStaticallyLinked { get { return true; } } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + return PlatformIOS.StaticSupportsAdditionalCpp(); + } +#endif + +#if !UNITY_EDITOR + internal override void LoadPlugins(FMOD.System coreSystem, Action reportResult) + { + PlatformIOS.StaticLoadPlugins(this, coreSystem, reportResult); + } +#endif + +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Core Audio", outputType = FMOD.OUTPUTTYPE.COREAUDIO }, + }; +#endif + } +} diff --git a/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs.meta b/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs.meta new file mode 100644 index 0000000..d4ad7e0 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/visionos/src/PlatformVisionOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8f591a193113347409efedcc618e83d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win.meta b/Assets/Plugins/FMOD/platforms/win.meta new file mode 100644 index 0000000..6414d98 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c66754bc90bcdd74dbacaa9bc9adf48b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib.meta b/Assets/Plugins/FMOD/platforms/win/lib.meta new file mode 100644 index 0000000..c8a4d9d --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4ad89dfcd36045640a8e902f16b09363 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86.meta new file mode 100644 index 0000000..7b87105 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 03f590b69e4afe14fa1c73f89a98a203 +folderAsset: yes +timeCreated: 1432606678 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll new file mode 100644 index 0000000..c9cf527 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll.meta new file mode 100644 index 0000000..a32046a --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudio.dll.meta @@ -0,0 +1,78 @@ +fileFormatVersion: 2 +guid: 1550e5c882b8c2445a1f14f8b1b23d41 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + CPU: x86 + DefaultValueInitialized: true + OS: Windows + Linux: + enabled: 1 + settings: + CPU: x86 + Linux64: + enabled: 1 + settings: + CPU: None + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 1 + settings: + CPU: None + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 0 + settings: + STV_MODEL: STANDARD_13 + WP8: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + Win: + enabled: 1 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: None + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll new file mode 100644 index 0000000..8d5a26e Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll.meta new file mode 100644 index 0000000..3efa5a6 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86/fmodstudioL.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 70e8356cc2a93664e9b62d9c6c7a6564 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86 + OS: Windows + - first: + Standalone: Win + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll new file mode 100644 index 0000000..0a1e0b5 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll.meta new file mode 100644 index 0000000..b47d546 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86/resonanceaudio.dll.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: b2c11f1e03736f748bd861d7bf4f8952 +timeCreated: 1511469552 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Editor: + enabled: 0 + settings: + CPU: x86 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 1 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: None + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86_64.meta new file mode 100644 index 0000000..dfce3ea --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86_64.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8105cca2fc4eb2e488e010278c3ea1bf +folderAsset: yes +timeCreated: 1432606678 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll new file mode 100644 index 0000000..2ee0a6e Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll.meta new file mode 100644 index 0000000..2059acb --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudio.dll.meta @@ -0,0 +1,78 @@ +fileFormatVersion: 2 +guid: 684d4d47a018ed14080e15f4c99b8e86 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 0 + settings: + STV_MODEL: STANDARD_13 + WP8: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll new file mode 100644 index 0000000..68be8bc Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll.meta new file mode 100644 index 0000000..80557c0 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/fmodstudioL.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: c1ac5f8bec79ee94c95595b599106dd3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + OS: Windows + - first: + Standalone: Win64 + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll new file mode 100644 index 0000000..aea7ae8 Binary files /dev/null and b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll differ diff --git a/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll.meta b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll.meta new file mode 100644 index 0000000..69301bb --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/lib/x86_64/resonanceaudio.dll.meta @@ -0,0 +1,50 @@ +fileFormatVersion: 2 +guid: 4c8fb9b92ea2eae4f9112a3941c4f128 +timeCreated: 1511469552 +licenseType: Store +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/src.meta b/Assets/Plugins/FMOD/platforms/win/src.meta new file mode 100644 index 0000000..14b32eb --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e3438d4d60981a7489133b13b11958ec +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs b/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs new file mode 100644 index 0000000..1c5a162 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs @@ -0,0 +1,171 @@ +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if !UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { +#if UNITY_STANDALONE_WIN + public const string dll = "fmodstudio" + dllSuffix; +#elif UNITY_WSA + public const string dll = "fmod" + dllSuffix; +#endif + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { +#if UNITY_STANDALONE_WIN || UNITY_WSA + public const string dll = "fmodstudio" + dllSuffix; +#endif + } +} +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformWindows : Platform + { + static PlatformWindows() + { + Settings.AddPlatformTemplate("2c5177b11d81d824dbb064f9ac8527da"); + } + + internal override string DisplayName { get { return "Windows"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.WindowsPlayer, this); + settings.DeclareRuntimePlatform(RuntimePlatform.WSAPlayerX86, this); + settings.DeclareRuntimePlatform(RuntimePlatform.WSAPlayerX64, this); + settings.DeclareRuntimePlatform(RuntimePlatform.WSAPlayerARM, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield return BuildTarget.StandaloneWindows; + yield return BuildTarget.StandaloneWindows64; + yield return BuildTarget.WSAPlayer; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.Windows; } } +#endif + +#if UNITY_WINRT_8_1 || UNITY_WSA_10_0 + internal override string GetBankFolder() + { + return "ms-appx:///Data/StreamingAssets"; + } +#endif + +#if UNITY_EDITOR + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + switch (buildTarget) + { + case BuildTarget.StandaloneWindows: + case BuildTarget.StandaloneWindows64: + return new BinaryAssetFolderInfo("win", "Plugins"); + case BuildTarget.WSAPlayer: + return new BinaryAssetFolderInfo("uwp", "Plugins/UWP"); + default: + throw new System.ArgumentException("Unrecognised build target: " + buildTarget); + } + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + string dllSuffix = suffix + ".dll"; + + switch (buildTarget) + { + case BuildTarget.StandaloneWindows: + yield return new FileRecord("x86/fmodstudio" + dllSuffix); + break; + case BuildTarget.StandaloneWindows64: + yield return new FileRecord("x86_64/fmodstudio" + dllSuffix); + break; + case BuildTarget.WSAPlayer: + foreach (string architecture in new[] { "arm", "x64", "x86" }) + { + yield return new FileRecord(string.Format("{0}/fmod{1}", architecture, dllSuffix)); + yield return new FileRecord(string.Format("{0}/fmodstudio{1}", architecture, dllSuffix)); + } + break; + default: + throw new System.NotSupportedException("Unrecognised Build Target"); + } + } + + protected override IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + switch (buildTarget) + { + case BuildTarget.StandaloneWindows: + yield return new FileRecord("x86/gvraudio.dll"); + yield return new FileRecord("x86/resonanceaudio.dll"); + break; + case BuildTarget.StandaloneWindows64: + yield return new FileRecord("x86_64/gvraudio.dll"); + yield return new FileRecord("x86_64/resonanceaudio.dll"); + break; + case BuildTarget.WSAPlayer: + yield break; + default: + throw new System.NotSupportedException("Unrecognised Build Target"); + } + } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + return target != BuildTarget.WSAPlayer; + } +#endif + + internal override string GetPluginPath(string pluginName) + { +#if UNITY_STANDALONE_WIN + #if UNITY_64 + return string.Format("{0}/X86_64/{1}.dll", GetPluginBasePath(), pluginName); + #else + return string.Format("{0}/X86/{1}.dll", GetPluginBasePath(), pluginName); + #endif +#else // UNITY_WSA + return string.Format("{0}.dll", pluginName); +#endif + } +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes + { + get + { + return sValidOutputTypes; + } + } + + private static OutputType[] sValidOutputTypes = { + new OutputType() { displayName = "Windows Audio Session API", outputType = FMOD.OUTPUTTYPE.WASAPI }, + new OutputType() { displayName = "Windows Sonic", outputType = FMOD.OUTPUTTYPE.WINSONIC }, + }; + + internal override int CoreCount { get { return MaximumCoreCount; } } +#endif + + internal override List DefaultCodecChannels { get { return staticCodecChannels; } } + + private static List staticCodecChannels = new List() + { + new CodecChannelCount { format = CodecType.FADPCM, channels = 0 }, + new CodecChannelCount { format = CodecType.Vorbis, channels = 32 }, + }; + } +} diff --git a/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs.meta b/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs.meta new file mode 100644 index 0000000..ac31c99 --- /dev/null +++ b/Assets/Plugins/FMOD/platforms/win/src/PlatformWindows.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9660e62d6232af242877f0cc2b90c63d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src.meta b/Assets/Plugins/FMOD/src.meta new file mode 100644 index 0000000..e435fc4 --- /dev/null +++ b/Assets/Plugins/FMOD/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2994e348941404549b266423c2ac329f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/AutomatableSlots.cs b/Assets/Plugins/FMOD/src/AutomatableSlots.cs new file mode 100644 index 0000000..777eb4b --- /dev/null +++ b/Assets/Plugins/FMOD/src/AutomatableSlots.cs @@ -0,0 +1,85 @@ +using System; +using UnityEngine.Serialization; + +namespace FMODUnity +{ + [Serializable] + public struct AutomatableSlots + { + public const int Count = 16; + + [FormerlySerializedAs("slot00")] + public float Slot00; + [FormerlySerializedAs("slot01")] + public float Slot01; + [FormerlySerializedAs("slot02")] + public float Slot02; + [FormerlySerializedAs("slot03")] + public float Slot03; + [FormerlySerializedAs("slot04")] + public float Slot04; + [FormerlySerializedAs("slot05")] + public float Slot05; + [FormerlySerializedAs("slot06")] + public float Slot06; + [FormerlySerializedAs("slot07")] + public float Slot07; + [FormerlySerializedAs("slot08")] + public float Slot08; + [FormerlySerializedAs("slot09")] + public float Slot09; + [FormerlySerializedAs("slot10")] + public float Slot10; + [FormerlySerializedAs("slot11")] + public float Slot11; + [FormerlySerializedAs("slot12")] + public float Slot12; + [FormerlySerializedAs("slot13")] + public float Slot13; + [FormerlySerializedAs("slot14")] + public float Slot14; + [FormerlySerializedAs("slot15")] + public float Slot15; + + public float GetValue(int index) + { + switch(index) + { + case 0: + return Slot00; + case 1: + return Slot01; + case 2: + return Slot02; + case 3: + return Slot03; + case 4: + return Slot04; + case 5: + return Slot05; + case 6: + return Slot06; + case 7: + return Slot07; + case 8: + return Slot08; + case 9: + return Slot09; + case 10: + return Slot10; + case 11: + return Slot11; + case 12: + return Slot12; + case 13: + return Slot13; + case 14: + return Slot14; + case 15: + return Slot15; + default: + throw new ArgumentException(string.Format("Invalid slot index: {0}", index)); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/AutomatableSlots.cs.meta b/Assets/Plugins/FMOD/src/AutomatableSlots.cs.meta new file mode 100644 index 0000000..890a60b --- /dev/null +++ b/Assets/Plugins/FMOD/src/AutomatableSlots.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c13d4e62f5f7b44bb33162cbf29a9f8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/BankRefAttribute.cs b/Assets/Plugins/FMOD/src/BankRefAttribute.cs new file mode 100644 index 0000000..de44917 --- /dev/null +++ b/Assets/Plugins/FMOD/src/BankRefAttribute.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace FMODUnity +{ + public class BankRefAttribute : PropertyAttribute + { + } +} diff --git a/Assets/Plugins/FMOD/src/BankRefAttribute.cs.meta b/Assets/Plugins/FMOD/src/BankRefAttribute.cs.meta new file mode 100644 index 0000000..e31fa65 --- /dev/null +++ b/Assets/Plugins/FMOD/src/BankRefAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a8ab5f38e7776644297d8b3687c39b49 +timeCreated: 1445488716 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor.meta b/Assets/Plugins/FMOD/src/Editor.meta new file mode 100644 index 0000000..ea0ad52 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdb2bdc82b47a634b803bb658c6e312b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs b/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs new file mode 100644 index 0000000..c126d05 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs @@ -0,0 +1,66 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomPropertyDrawer(typeof(BankRefAttribute))] + public class BankRefDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Texture browseIcon = EditorUtils.LoadImage("SearchIconBlack.png"); + + SerializedProperty pathProperty = property; + + EditorGUI.BeginProperty(position, label, property); + + Event e = Event.current; + if (e.type == EventType.DragPerform && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) + { + pathProperty.stringValue = ((EditorBankRef)DragAndDrop.objectReferences[0]).Name; + + e.Use(); + } + } + if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Move; + DragAndDrop.AcceptDrag(); + e.Use(); + } + } + + float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y; + + position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); + + var buttonStyle = new GUIStyle(GUI.skin.button); + buttonStyle.padding.top = buttonStyle.padding.bottom = 1; + + Rect searchRect = new Rect(position.x + position.width - browseIcon.width - 15, position.y, browseIcon.width + 10, baseHeight); + Rect pathRect = new Rect(position.x, position.y, searchRect.x - position.x - 5, baseHeight); + + EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none); + if (GUI.Button(searchRect, new GUIContent(browseIcon, "Select FMOD Bank"), buttonStyle)) + { + var eventBrowser = ScriptableObject.CreateInstance(); + + eventBrowser.ChooseBank(property); + var windowRect = position; + windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); + windowRect.height = searchRect.height + 1; + eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400)); + } + + EditorGUI.EndProperty(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs.meta b/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs.meta new file mode 100644 index 0000000..f2f2c6a --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 49ebe6fea5e4bfc4bb492bba062b2afe +timeCreated: 1433209573 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs b/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs new file mode 100644 index 0000000..533c84e --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs @@ -0,0 +1,237 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + public class BankRefreshWindow : EditorWindow + { + private static BankRefreshWindow instance = null; + + private SerializedObject serializedSettings; + private SerializedProperty cooldown; + private SerializedProperty showWindow; + + private bool readyToRefreshBanks = false; + private float closeTime = float.MaxValue; + private string lastRefreshError = null; + + private const float CloseDelay = 5; + + public static bool IsVisible { get { return instance != null; } } + + public static bool ReadyToRefreshBanks { get { return instance == null || instance.readyToRefreshBanks; } } + + public static void ShowWindow() + { + if (instance == null) + { + instance = CreateInstance(); + instance.titleContent = new GUIContent("FMOD Bank Refresh Status"); + instance.minSize = new Vector2(400, 200); + instance.maxSize = new Vector2(1000, 200); + + instance.ShowUtility(); + } + } + + private void OnEnable() + { + serializedSettings = new SerializedObject(Settings.Instance); + cooldown = serializedSettings.FindProperty("BankRefreshCooldown"); + showWindow = serializedSettings.FindProperty("ShowBankRefreshWindow"); + + // instance is set to null when scripts are recompiled + if (instance == null) + { + instance = this; + } + else if (instance != this) + { + Close(); + } + } + + private void OnDestroy() + { + if (instance == this) + { + instance = null; + } + } + + private void OnInspectorUpdate() + { + Repaint(); + + if (BankRefresher.TimeUntilBankRefresh() != float.MaxValue) + { + closeTime = float.MaxValue; + } + + if (Time.realtimeSinceStartup > closeTime) + { + Close(); + } + } + + public static void HandleBankRefresh(string error) + { + if (error != null) + { + RuntimeUtils.DebugLogErrorFormat("FMOD: Bank refresh failed: {0}", error); + } + + if (instance != null) + { + instance.readyToRefreshBanks = false; + instance.lastRefreshError = error; + + if (error == null) + { + instance.closeTime = Time.realtimeSinceStartup + CloseDelay; + } + } + } + + private void OnGUI() + { + serializedSettings.Update(); + + DrawStatus(); + + GUILayout.FlexibleSpace(); + + SettingsEditor.DisplayBankRefreshSettings(cooldown, showWindow, false); + + DrawButtons(); + + serializedSettings.ApplyModifiedProperties(); + } + + private bool ConsumeEscapeKey() + { + if ((focusedWindow == this) && Event.current.isKey && Event.current.keyCode == KeyCode.Escape) + { + Event.current.Use(); + return true; + } + else + { + return false; + } + } + + private void DrawStatus() + { + GUIStyle labelStyle = new GUIStyle(EditorStyles.whiteLargeLabel); + labelStyle.alignment = TextAnchor.MiddleCenter; + + GUIStyle largeErrorStyle = new GUIStyle(labelStyle); + largeErrorStyle.normal.textColor = Color.red; + + GUIStyle errorStyle = new GUIStyle(GUI.skin.box); + errorStyle.alignment = TextAnchor.UpperLeft; + errorStyle.wordWrap = true; + errorStyle.normal.textColor = Color.red; + + float timeSinceFileChange = BankRefresher.TimeSinceSourceFileChange(); + + if (timeSinceFileChange != float.MaxValue) + { + GUILayout.Label(string.Format("The FMOD source banks changed {0} ago.", + EditorUtils.DurationString(timeSinceFileChange)), labelStyle); + + float timeUntilBankRefresh = BankRefresher.TimeUntilBankRefresh(); + + if (timeUntilBankRefresh == 0) + { + GUILayout.Label("Refreshing banks now...", labelStyle); + readyToRefreshBanks = true; + } + else if (timeUntilBankRefresh != float.MaxValue) + { + if (DrawCountdown("Refreshing banks", timeUntilBankRefresh, Settings.Instance.BankRefreshCooldown, labelStyle) + || ConsumeEscapeKey()) + { + BankRefresher.DisableAutoRefresh(); + } + } + else + { + GUILayout.Label("Would you like to refresh banks?", labelStyle); + } + } + else + { + if (lastRefreshError == null) + { + GUILayout.Label("The FMOD banks are up to date.", labelStyle); + } + else + { + GUILayout.Label("Bank refresh failed:", largeErrorStyle); + GUILayout.Box(lastRefreshError, errorStyle, GUILayout.ExpandWidth(true)); + } + } + + if (closeTime != float.MaxValue) + { + float timeUntilClose = Mathf.Max(0, closeTime - Time.realtimeSinceStartup); + + if (DrawCountdown("Closing", timeUntilClose, CloseDelay, labelStyle) || ConsumeEscapeKey()) + { + closeTime = float.MaxValue; + } + } + } + + private static bool DrawCountdown(string text, float remainingTime, float totalTime, GUIStyle labelStyle) + { + GUILayout.Label(string.Format("{0} in {1}...", text, EditorUtils.DurationString(remainingTime)), labelStyle); + + const float boxHeight = 2; + + Rect controlRect = EditorGUILayout.GetControlRect(false, boxHeight * 2); + + Rect boxRect = controlRect; + boxRect.width *= remainingTime / totalTime; + boxRect.x += (controlRect.width - boxRect.width) / 2; + boxRect.height = 2; + + GUI.DrawTexture(boxRect, EditorGUIUtility.whiteTexture); + + GUIContent cancelContent = new GUIContent("Cancel"); + + controlRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * 2); + + Rect buttonRect = controlRect; + buttonRect.width = 100; + buttonRect.x += (controlRect.width - buttonRect.width) / 2; + + return GUI.Button(buttonRect, cancelContent); + } + + private void DrawButtons() + { + Rect rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * 2); + + int buttonCount = 2; + + Rect closeRect = rect; + closeRect.width = rect.width / buttonCount; + + Rect refreshRect = rect; + refreshRect.xMin = closeRect.xMax; + + if (GUI.Button(closeRect, "Close")) + { + Close(); + } + + if (GUI.Button(refreshRect, "Refresh Banks Now")) + { + EventManager.RefreshBanks(); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs.meta b/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs.meta new file mode 100644 index 0000000..efec694 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefreshWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 40a1ca322d08d704eacd449863718b31 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs b/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs new file mode 100644 index 0000000..0c75f5e --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs @@ -0,0 +1,167 @@ +using System; +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + public class BankRefresher + { + private static string currentWatchPath; + private static FileSystemWatcher sourceFileWatcher; + private static bool sourceFilesChanged = false; + private static float lastSourceFileChange = float.MaxValue; + private static bool autoRefresh = true; + private static float nextFilePollTime = float.MinValue; + + private const int FilePollPeriod = 5; + + public static void DisableAutoRefresh() + { + autoRefresh = false; + } + + public static void Startup() + { + sourceFileWatcher = new FileSystemWatcher(); + sourceFileWatcher.IncludeSubdirectories = true; + sourceFileWatcher.NotifyFilter = NotifyFilters.LastWrite; + + sourceFileWatcher.Changed += OnSourceFileChanged; + sourceFileWatcher.Created += OnSourceFileChanged; + sourceFileWatcher.Deleted += OnSourceFileChanged; + + EditorApplication.update += Update; + } + + private static void OnSourceFileChanged(object source, FileSystemEventArgs e) + { + sourceFilesChanged = true; + } + + private static void Update() + { + UpdateFileWatcherPath(); + CheckSourceFilesChanged(); + CheckCacheFileExists(); + RefreshBanksIfReady(); + } + + private static void UpdateFileWatcherPath() + { + string sourceBankPath = Settings.Instance.SourceBankPath; + + string pathToWatch; + + if (Path.IsPathRooted(sourceBankPath)) + { + pathToWatch = Path.GetFullPath(sourceBankPath); + } + else + { + pathToWatch = Path.GetFullPath(Environment.CurrentDirectory + "/" + sourceBankPath); + } + + if (currentWatchPath != pathToWatch) + { + currentWatchPath = pathToWatch; + + try { + sourceFileWatcher.EnableRaisingEvents = false; + sourceFilesChanged = false; + + if (!string.IsNullOrEmpty(sourceBankPath)) + { + sourceFileWatcher.Path = pathToWatch; + sourceFileWatcher.EnableRaisingEvents = true; + } + } + catch (ArgumentException e) + { + RuntimeUtils.DebugLogWarningFormat("Error watching {0}: {1}", pathToWatch, e.Message); + } + } + } + + private static void CheckSourceFilesChanged() + { + if (sourceFilesChanged) + { + lastSourceFileChange = Time.realtimeSinceStartup; + sourceFilesChanged = false; + + if (!BankRefreshWindow.IsVisible) + { + autoRefresh = true; + } + + if (IsWindowEnabled()) + { + BankRefreshWindow.ShowWindow(); + } + } + } + + private static void CheckCacheFileExists() + { + if (Time.realtimeSinceStartup >= nextFilePollTime) + { + if (!File.Exists(EventManager.CacheAssetFullName)) + { + EventManager.RefreshBanks(); + } + + nextFilePollTime = Time.realtimeSinceStartup + FilePollPeriod; + } + } + + private static void RefreshBanksIfReady() + { + if (TimeUntilBankRefresh() == 0 && BankRefreshWindow.ReadyToRefreshBanks) + { + EventManager.RefreshBanks(); + } + } + + public static void HandleBankRefresh(string result) + { + lastSourceFileChange = float.MaxValue; + BankRefreshWindow.HandleBankRefresh(result); + } + + private static bool IsWindowEnabled() + { + Settings settings = Settings.Instance; + + return settings.BankRefreshCooldown == Settings.BankRefreshPrompt + || (settings.BankRefreshCooldown >= 0 && settings.ShowBankRefreshWindow); + } + + public static float TimeSinceSourceFileChange() + { + if (lastSourceFileChange == float.MaxValue) + { + return float.MaxValue; + } + else + { + return Mathf.Max(0, Time.realtimeSinceStartup - lastSourceFileChange); + } + } + + public static float TimeUntilBankRefresh() + { + if (!autoRefresh + || lastSourceFileChange == float.MaxValue + || Settings.Instance.BankRefreshCooldown < 0) + { + return float.MaxValue; + } + else + { + float nextRefreshTime = lastSourceFileChange + Settings.Instance.BankRefreshCooldown; + return Mathf.Max(0, nextRefreshTime - Time.realtimeSinceStartup); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs.meta b/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs.meta new file mode 100644 index 0000000..fb73361 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e564c074e96205b49b91ff80126983c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs b/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs new file mode 100644 index 0000000..8c954e2 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using UnityEngine; +using UnityEditor; +using UnityEditor.Build; + +#if (UNITY_VISUALSCRIPTING_EXIST) +using Unity.VisualScripting; +#elif (UNITY_BOLT_EXIST) +using Ludiq; +using Bolt; +#endif + +namespace FMODUnity +{ + public class BoltIntegration : MonoBehaviour + { + [MenuItem("FMOD/Generate Visual Scripting Units")] + public static void GenerateBoltUnitOptions() + { +#if (UNITY_BOLT_EXIST || UNITY_VISUALSCRIPTING_EXIST) + BuildBoltUnitOptions(); +#else + TriggerBuild(); +#endif + } + +#if !(UNITY_BOLT_EXIST || UNITY_VISUALSCRIPTING_EXIST) + [MenuItem("FMOD/Generate Visual Scripting Units", true)] + private static bool IsBoltPresent() + { + Assembly ludiqCoreRuntimeAssembly = null; + Assembly boltFlowEditorAssembly = null; + + try + { + ludiqCoreRuntimeAssembly = Assembly.Load("Ludiq.Core.Runtime"); + boltFlowEditorAssembly = Assembly.Load("Bolt.Flow.Editor"); + } + catch (FileNotFoundException) + { + return false; + } + + return true; + } + + private static void TriggerBuild() + { + BuildTarget target = EditorUserBuildSettings.activeBuildTarget; + BuildTargetGroup group = BuildPipeline.GetBuildTargetGroup(target); +#if UNITY_2021_2_OR_NEWER + NamedBuildTarget namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(group); + string previousSymbols = PlayerSettings.GetScriptingDefineSymbols(namedBuildTarget); +#else + string previousSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group); +#endif + + if (!previousSymbols.Contains("UNITY_BOLT_EXIST")) + { +#if UNITY_2021_2_OR_NEWER + PlayerSettings.SetScriptingDefineSymbols(namedBuildTarget, previousSymbols + ";UNITY_BOLT_EXIST"); +#else + PlayerSettings.SetScriptingDefineSymbolsForGroup(group, previousSymbols + ";UNITY_BOLT_EXIST"); +#endif + } + Settings.Instance.BoltUnitOptionsBuildPending = true; + AssetDatabase.Refresh(); + } + +#else + private static void BuildBoltUnitOptions() + { +#if (UNITY_BOLT_EXIST) + DictionaryAsset projectSettings = AssetDatabase.LoadAssetAtPath(PathUtility.FromProject(LudiqCore.Paths.projectSettings), typeof(DictionaryAsset)) as DictionaryAsset; + List assemblyOptions = projectSettings.dictionary["assemblyOptions"] as List; +#else + List assemblyOptions = BoltCore.Configuration.assemblyOptions; +#endif + + if (!assemblyOptions.Contains("FMODUnity")) + { + assemblyOptions.Add("FMODUnity"); + } + + if (!assemblyOptions.Contains("FMODUnityResonance")) + { + assemblyOptions.Add("FMODUnityResonance"); + } +#if (UNITY_BOLT_EXIST) + List typeOptions = projectSettings.dictionary["typeOptions"] as List; +#else + List typeOptions = BoltCore.Configuration.typeOptions; +#endif + Assembly fmodUnityAssembly = Assembly.Load("FMODUnity"); + Assembly fmodUnityResonanceAssembly = Assembly.Load("FMODUnityResonance"); + + List allTypes = new List(GetTypesForNamespace(fmodUnityAssembly, "FMOD")); + allTypes.AddRange(GetTypesForNamespace(fmodUnityAssembly, "FMOD.Studio")); + allTypes.AddRange(GetTypesForNamespace(fmodUnityAssembly, "FMODUnity")); + allTypes.AddRange(GetTypesForNamespace(fmodUnityResonanceAssembly, "FMODUnityResonance")); + + foreach (Type type in allTypes) + { + if (!typeOptions.Contains(type)) + { + typeOptions.Add(type); + } + } + + Codebase.UpdateSettings(); +#if (UNITY_BOLT_EXIST) + UnitBase.Build(); +#else + BoltCore.Configuration.Save(); + UnitBase.Rebuild(); +#endif + } + + private static IEnumerable GetTypesForNamespace(Assembly assembly, string requestedNamespace) + { + return assembly.GetTypes() + .Where(t => string.Equals(t.Namespace, requestedNamespace, StringComparison.Ordinal)); + } +#endif + + public static void Startup() + { +#if (UNITY_BOLT_EXIST || UNITY_VISUALSCRIPTING_EXIST) + if (Settings.Instance.BoltUnitOptionsBuildPending) + { + Settings.Instance.BoltUnitOptionsBuildPending = false; + BuildBoltUnitOptions(); + } +#endif + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs.meta b/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs.meta new file mode 100644 index 0000000..0ab100c --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/BoltIntegration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f876942dd549ef444a82ab923e75ccb1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs b/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs new file mode 100644 index 0000000..f9ff18c --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs @@ -0,0 +1,124 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace FMODUnity +{ + public static class CodeGeneration + { + public static void GenerateStaticPluginRegistration(string filePath, Platform platform, + Action reportError) + { + List validatedPlugins = ValidateStaticPlugins(platform.StaticPlugins, reportError); + + using (StreamWriter file = new StreamWriter(filePath)) + { + WriteStaticPluginRegistration(file, platform.IsFMODStaticallyLinked, validatedPlugins); + } + } + + private static void WriteStaticPluginRegistration(StreamWriter file, bool isFMODStaticallyLinked, + IEnumerable pluginFunctions) + { + file.WriteLine("#if ENABLE_IL2CPP"); + file.WriteLine(); + file.WriteLine("// This file was generated by FMOD for Unity from the Static Plugins list in the FMOD settings."); + file.WriteLine(); + + file.WriteLine("using System;"); + file.WriteLine("using System.Runtime.InteropServices;"); + file.WriteLine(); + + file.WriteLine("namespace FMODUnity"); + file.WriteLine("{"); + + file.WriteLine(" class {0}", Platform.RegisterStaticPluginsClassName); + file.WriteLine(" {"); + + // Import the plugin functions + foreach (string pluginFunction in pluginFunctions) + { + file.WriteLine(" [DllImport(\"__Internal\")]"); + file.WriteLine(" private static extern IntPtr {0}();", pluginFunction); + file.WriteLine(); + } + + // Import the RegisterDSP function + file.WriteLine(" [DllImport(FMOD.VERSION.dll)]"); + file.WriteLine(" private static extern FMOD.RESULT FMOD5_System_RegisterDSP(IntPtr system, IntPtr description, IntPtr handle);"); + file.WriteLine(); + + file.WriteLine(" public static void {0}(FMOD.System coreSystem, Action reportResult)", + Platform.RegisterStaticPluginsFunctionName); + file.WriteLine(" {"); + + if (pluginFunctions.Any()) + { + file.WriteLine(" FMOD.RESULT result;"); + + foreach (string pluginFunction in pluginFunctions) + { + file.WriteLine(); + file.WriteLine(" result = FMOD5_System_RegisterDSP(coreSystem.handle, {0}(), IntPtr.Zero);", pluginFunction); + file.WriteLine(" reportResult(result, \"Registering static plugin '{0}'\");", pluginFunction); + } + } + + file.WriteLine(" }"); + file.WriteLine(" }"); + file.WriteLine("}"); + file.WriteLine(""); + file.WriteLine("#endif // ENABLE_IL2CPP"); + } + + private static List ValidateStaticPlugins(List staticPlugins, Action reportError) + { + List result = new List(); + + for (int i = 0; i < staticPlugins.Count; ++i) + { + string functionName = staticPlugins[i]; + + string trimmedName = (functionName != null) ? functionName.Trim() : null; + + if (string.IsNullOrEmpty(trimmedName)) + { + reportError(string.Format("Static plugin {0} has no name and will be ignored.", i + 1)); + } + else if (IsValidFunctionName(trimmedName, reportError)) + { + result.Add(trimmedName); + } + } + + return result; + } + + private static bool IsValidFunctionName(string name, Action reportError) + { + if (!(char.IsLetter(name[0]) || name[0] == '_')) + { + reportError(string.Format( + "Plugin name '{0}' is not valid. Names must start with a letter or an underscore ('_').", name)); + return false; + } + + for (int i = 1; i < name.Length; ++i) + { + if (!(char.IsLetterOrDigit(name[i]) || name[i] == '_')) + { + reportError(string.Format( + "Plugin name '{0}' is not valid. " + + "Character '{1}' at position {2} is invalid - it must be a letter, a number, or an underscore ('_').", + name, name[i], i)); + return false; + } + } + + return true; + } + } +} +#endif diff --git a/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs.meta b/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs.meta new file mode 100644 index 0000000..31bb1fd --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/CodeGeneration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 438155f6a2d689e45b5cc7701d412b80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs b/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs new file mode 100644 index 0000000..fd6d7d1 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs @@ -0,0 +1,402 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEditor; + +namespace FMODUnity +{ + public class CreateEventPopup : EditorWindow + { + private class FolderEntry + { + public FolderEntry parent; + public string name; + public string guid; + public List entries = new List(); + public Rect rect; + } + + private SerializedProperty outputProperty; + + private FolderEntry rootFolder; + private FolderEntry currentFolder; + private List banks; + + private int lastHover = 0; + private string eventFolder = "/"; + private string eventName = ""; + private string currentFilter = ""; + private int selectedBank = 0; + private bool resetCursor = true; + private Vector2 scrollPos = new Vector2(); + private Rect scrollRect = new Rect(); + private bool isConnected = false; + + internal void SelectEvent(SerializedProperty property) + { + outputProperty = property; + } + + private class BankEntry + { + public string name; + public string guid; + } + + public CreateEventPopup() + { + } + + private void BuildTree() + { + var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id"); + rootFolder = new FolderEntry(); + rootFolder.guid = rootGuid; + BuildTreeItem(rootFolder); + wantsMouseMove = true; + banks = new List(); + + const string buildBankTreeFunc = + @"function() { + var output = """"; + const items = [ studio.project.workspace.masterBankFolder ]; + while (items.length > 0) { + var currentItem = items.shift(); + if (currentItem.isOfType(""BankFolder"")) { + currentItem.items.reverse().forEach(function(val) { + items.unshift(val); + }); + } else { + output += "","" + currentItem.id + currentItem.getPath().replace(""bank:/"", """"); + } + } + return output; + }"; + + string bankList = EditorUtils.GetScriptOutput(string.Format("({0})()", buildBankTreeFunc)); + string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (var bank in bankListSplit) + { + var entry = new BankEntry(); + entry.guid = bank.Substring(0, 38); + entry.name = bank.Substring(38); + banks.Add(entry); + } + } + + private void BuildTreeItem(FolderEntry entry) + { + // lookup the entry + EditorUtils.GetScriptOutput(string.Format("cur = studio.project.lookup(\"{0}\");", entry.guid)); + + // get child count + string itemCountString = EditorUtils.GetScriptOutput("cur.items.length;"); + int itemCount; + Int32.TryParse(itemCountString, out itemCount); + + // iterate children looking for folder + for (int item = 0; item < itemCount; item++) + { + EditorUtils.GetScriptOutput(String.Format("child = cur.items[{0}]", item)); + + // check if it's a folder + string isFolder = EditorUtils.GetScriptOutput("child.isOfExactType(\"EventFolder\")"); + if (isFolder == "false") + { + continue; + } + + // Get guid and name + string info = EditorUtils.GetScriptOutput("child.id + child.name"); + + var childEntry = new FolderEntry(); + childEntry.guid = info.Substring(0, 38); + childEntry.name = info.Substring(38); + childEntry.parent = entry; + entry.entries.Add(childEntry); + } + + // Recurse for child entries + foreach(var childEntry in entry.entries) + { + BuildTreeItem(childEntry); + } + } + + public void OnGUI() + { + var borderIcon = EditorUtils.LoadImage("Border.png"); + var border = new GUIStyle(GUI.skin.box); + border.normal.background = borderIcon; + GUI.Box(new Rect(1, 1, position.width - 1, position.height - 1), GUIContent.none, border); + + if (Event.current.type == EventType.Layout) + { + isConnected = EditorUtils.IsConnectedToStudio(); + } + + if (!isConnected) + { + this.ShowNotification(new GUIContent("FMOD Studio not running")); + return; + } + + this.RemoveNotification(); + + if (rootFolder == null) + { + BuildTree(); + currentFolder = rootFolder; + } + + var arrowIcon = EditorUtils.LoadImage("ArrowIcon.png"); + var hoverIcon = EditorUtils.LoadImage("SelectedAlt.png"); + + var nextEntry = currentFolder; + + var filteredEntries = currentFolder.entries.FindAll((x) => x.name.StartsWith(currentFilter, StringComparison.CurrentCultureIgnoreCase)); + + // Process key strokes for the folder list + { + if (Event.current.keyCode == KeyCode.UpArrow) + { + if (Event.current.type == EventType.KeyDown) + { + lastHover = Math.Max(lastHover - 1, 0); + if (filteredEntries[lastHover].rect.y < scrollPos.y) + { + scrollPos.y = filteredEntries[lastHover].rect.y; + } + } + Event.current.Use(); + } + if (Event.current.keyCode == KeyCode.DownArrow) + { + if (Event.current.type == EventType.KeyDown) + { + lastHover = Math.Min(lastHover + 1, filteredEntries.Count - 1); + if (filteredEntries[lastHover].rect.y + filteredEntries[lastHover].rect.height > scrollPos.y + scrollRect.height) + { + scrollPos.y = filteredEntries[lastHover].rect.y - scrollRect.height + filteredEntries[lastHover].rect.height * 2; + } + } + Event.current.Use(); + } + if (Event.current.keyCode == KeyCode.RightArrow) + { + if (Event.current.type == EventType.KeyDown) + nextEntry = filteredEntries[lastHover]; + Event.current.Use(); + } + if (Event.current.keyCode == KeyCode.LeftArrow) + { + if (Event.current.type == EventType.KeyDown) + if (currentFolder.parent != null) + { + nextEntry = currentFolder.parent; + } + Event.current.Use(); + } + } + + bool disabled = eventName.Length == 0; + EditorGUI.BeginDisabledGroup(disabled); + if (GUILayout.Button("Create Event")) + { + CreateEventInStudio(); + this.Close(); + } + EditorGUI.EndDisabledGroup(); + + { + GUI.SetNextControlName("name"); + + EditorGUILayout.LabelField("Name"); + eventName = EditorGUILayout.TextField(eventName); + } + + { + EditorGUILayout.LabelField("Bank"); + selectedBank = EditorGUILayout.Popup(selectedBank, banks.Select(x => x.name).ToArray()); + } + + bool updateEventPath = false; + { + GUI.SetNextControlName("folder"); + EditorGUI.BeginChangeCheck(); + EditorGUILayout.LabelField("Path"); + eventFolder = GUILayout.TextField(eventFolder); + if (EditorGUI.EndChangeCheck()) + { + updateEventPath = true; + } + } + + if (resetCursor) + { + resetCursor = false; + + var textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); + if (textEditor != null) + { + textEditor.MoveCursorToPosition(new Vector2(9999, 9999)); + } + } + + // Draw the current folder as a title bar, click to go back one level + { + Rect currentRect = EditorGUILayout.GetControlRect(); + + var bg = new GUIStyle(GUI.skin.box); + Rect bgRect = new Rect(currentRect); + bgRect.x = 2; + bgRect.width = position.width-4; + GUI.Box(bgRect, GUIContent.none, bg); + + Rect textureRect = currentRect; + textureRect.width = arrowIcon.width; + if (currentFolder.name != null) + { + GUI.DrawTextureWithTexCoords(textureRect, arrowIcon, new Rect(1, 1, -1, -1)); + } + + Rect labelRect = currentRect; + labelRect.x += arrowIcon.width; + labelRect.width -= arrowIcon.width; + GUI.Label(labelRect, currentFolder.name != null ? currentFolder.name : "Folders", EditorStyles.boldLabel); + + if (Event.current.type == EventType.MouseDown && currentRect.Contains(Event.current.mousePosition) && + currentFolder.parent != null) + { + nextEntry = currentFolder.parent; + Event.current.Use(); + } + } + + var normal = new GUIStyle(GUI.skin.label); + normal.padding.left = 14; + var hover = new GUIStyle(normal); + hover.normal.background = hoverIcon; + + scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false); + + for (int i = 0; i < filteredEntries.Count; i++) + { + var entry = filteredEntries[i]; + var content = new GUIContent(entry.name); + var rect = EditorGUILayout.GetControlRect(); + if ((rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseMove) || i == lastHover) + { + lastHover = i; + + GUI.Label(rect, content, hover); + if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown) + { + nextEntry = entry; + } + } + else + { + GUI.Label(rect, content, normal); + } + + Rect textureRect = rect; + textureRect.x = textureRect.width - arrowIcon.width; + textureRect.width = arrowIcon.width; + GUI.DrawTexture(textureRect, arrowIcon); + + if (Event.current.type == EventType.Repaint) + { + entry.rect = rect; + } + } + EditorGUILayout.EndScrollView(); + + if (Event.current.type == EventType.Repaint) + { + scrollRect = GUILayoutUtility.GetLastRect(); + } + + if (currentFolder != nextEntry) + { + lastHover = 0; + currentFolder = nextEntry; + UpdateTextFromList(); + Repaint(); + } + + if (updateEventPath) + { + UpdateListFromText(); + } + + if (Event.current.type == EventType.MouseMove) + { + Repaint(); + } + } + + private void CreateEventInStudio() + { + string eventGuid = EditorUtils.CreateStudioEvent(eventFolder, eventName); + + if (!string.IsNullOrEmpty(eventGuid)) + { + EditorUtils.GetScriptOutput(String.Format("studio.project.lookup(\"{0}\").relationships.banks.add(studio.project.lookup(\"{1}\"));", eventGuid, banks[selectedBank].guid)); + EditorUtils.GetScriptOutput("studio.project.build();"); + + if (!eventFolder.EndsWith("/")) + { + eventFolder += "/"; + } + + string fullPath = "event:" + eventFolder + eventName; + outputProperty.SetEventReference(FMOD.GUID.Parse(eventGuid), fullPath); + EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, fullPath); + outputProperty.serializedObject.ApplyModifiedProperties(); + } + } + + private void UpdateListFromText() + { + int endFolders = eventFolder.LastIndexOf("/"); + currentFilter = eventFolder.Substring(endFolders + 1); + + var folders = eventFolder.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + FolderEntry entry = rootFolder; + int i; + for (i = 0; i < folders.Length; i++) + { + var newEntry = entry.entries.Find((x) => x.name.Equals(folders[i], StringComparison.CurrentCultureIgnoreCase)); + if (newEntry == null) + { + break; + } + entry = newEntry; + } + currentFolder = entry; + + // Treat an exact filter match as being in that folder and clear the filter + if (entry.name != null && entry.name.Equals(currentFilter, StringComparison.CurrentCultureIgnoreCase)) + { + currentFilter = ""; + } + } + + private void UpdateTextFromList() + { + string path = ""; + var entry = currentFolder; + while (entry.parent != null) + { + path = entry.name + "/" + path; + entry = entry.parent; + } + + eventFolder = "/" + path; + resetCursor = true; + currentFilter = ""; + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs.meta b/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs.meta new file mode 100644 index 0000000..ddba85a --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/CreateEventPopup.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c9773a32ed4a2b429fd42645175c32b +timeCreated: 1455063674 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs b/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs new file mode 100644 index 0000000..3c82ca9 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +namespace FMODUnity +{ + public class EditorBankRef : ScriptableObject + { + [SerializeField] + public string Path; + + [SerializeField] + public string Name; + + [SerializeField] + public string StudioPath; + + [SerializeField] + private Int64 lastModified; + + [SerializeField] + public List FileSizes; + + public bool Exists; + + public DateTime LastModified + { + get { return new DateTime(lastModified); } + set { lastModified = value.Ticks; } + } + + public static string CalculateName(string filePath, string basePath) + { + string relativePath = filePath.Substring(basePath.Length + 1); + string extension = System.IO.Path.GetExtension(relativePath); + + string name = relativePath.Substring(0, relativePath.Length - extension.Length); + name = RuntimeUtils.GetCommonPlatformPath(name); + + return name; + } + + public void SetPath(string filePath, string basePath) + { + Path = RuntimeUtils.GetCommonPlatformPath(filePath); + Name = CalculateName(filePath, basePath); + base.name = "bank:/" + Name + System.IO.Path.GetExtension(filePath); + } + + public void SetStudioPath(string studioPath) + { + string stringCmp; + stringCmp = System.IO.Path.GetFileName(Name); + if (!studioPath.Contains(stringCmp)) + { + // No match means localization + studioPath = studioPath.Substring(0, studioPath.LastIndexOf("/") + 1); + studioPath += stringCmp; + } + StudioPath = studioPath; + } + + [Serializable] + public class NameValuePair + { + public string Name; + public long Value; + + public NameValuePair(string name, long value) + { + Name = name; + Value = value; + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs.meta b/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs.meta new file mode 100644 index 0000000..f88385e --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorBankRef.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c18180ecb35941f4682ae60107b85b7c +timeCreated: 1432775088 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs b/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs new file mode 100644 index 0000000..406d95d --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEditor; + +namespace FMODUnity +{ + public class EditorEventRef : ScriptableObject + { + [SerializeField] + public string Path; + + [SerializeField] + public FMOD.GUID Guid; + + [SerializeField] + public List Banks; + [SerializeField] + public bool IsStream; + [SerializeField] + public bool Is3D; + [SerializeField] + public bool IsOneShot; + [SerializeField] + public List Parameters; + [SerializeField] + public float MinDistance; + [SerializeField] + public float MaxDistance; + [SerializeField] + public int Length; + + public List LocalParameters + { + get { return Parameters.Where(p => p.IsGlobal == false).OrderBy(p => p.Name).ToList(); } + } + + public List GlobalParameters + { + get { return Parameters.Where(p => p.IsGlobal == true).OrderBy(p => p.Name).ToList(); } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs.meta b/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs.meta new file mode 100644 index 0000000..6c6fd83 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorEventRef.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ceb653cd98e289a4e8697a1af55201f2 +timeCreated: 1432775088 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs b/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs new file mode 100644 index 0000000..c1bc821 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + public enum ParameterType + { + Continuous, + Discrete, + Labeled, + } + + public class EditorParamRef : ScriptableObject + { + [SerializeField] + public string Name; + [SerializeField] + public string StudioPath; + [SerializeField] + public float Min; + [SerializeField] + public float Max; + [SerializeField] + public float Default; + [SerializeField] + public ParameterID ID; + [SerializeField] + public ParameterType Type; + [SerializeField] + public bool IsGlobal; + [SerializeField] + public string[] Labels = { }; + + public bool Exists; + + [Serializable] + public struct ParameterID + { + public static implicit operator ParameterID(FMOD.Studio.PARAMETER_ID source) + { + return new ParameterID { + data1 = source.data1, + data2 = source.data2, + }; + } + + public static implicit operator FMOD.Studio.PARAMETER_ID(ParameterID source) + { + return new FMOD.Studio.PARAMETER_ID { + data1 = source.data1, + data2 = source.data2, + }; + } + + public bool Equals(FMOD.Studio.PARAMETER_ID other) + { + return data1 == other.data1 && data2 == other.data2; + } + + public uint data1; + public uint data2; + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs.meta b/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs.meta new file mode 100644 index 0000000..fef3bd7 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorParamRef.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fecb8ef7f94ca804a8ab72049b86782e +timeCreated: 1432775088 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs b/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs new file mode 100644 index 0000000..3170b61 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs @@ -0,0 +1,713 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEngine; + +namespace FMODUnity +{ + [InitializeOnLoad] + public class EditorSettings : IEditorSettings + { + static EditorSettings() + { + Settings.EditorSettings = new EditorSettings(); + } + + public const string DownloadURL = "https://www.fmod.com/download"; + + // This is used to find the platform that implements the current Unity build target. + private Dictionary PlatformForBuildTarget = new Dictionary(); + + private static string FMODFolderFull => RuntimeUtils.PluginBasePath; + + private const string CacheFolderName = "Cache"; + private static string CacheFolderRelative => $"{RuntimeUtils.PluginBasePath}/{CacheFolderName}"; + private static string CacheFolderFull => $"{FMODFolderFull}/{CacheFolderName}"; + + private const string RegisterStaticPluginsFile = "RegisterStaticPlugins.cs"; + private static string RegisterStaticPluginsAssetPathRelative => $"{CacheFolderRelative}/{RegisterStaticPluginsFile}"; + private static string RegisterStaticPluginsAssetPathFull => $"{CacheFolderFull}/{RegisterStaticPluginsFile}"; + + [NonSerialized] + private Dictionary binaryCompatibilitiesBeforeBuild; + + public static EditorSettings Instance + { + get + { + return Settings.EditorSettings as EditorSettings; + } + } + + public Settings RuntimeSettings { get; set; } + + [MenuItem("FMOD/Edit Settings", priority = 0)] + public static void EditSettings() + { + Selection.activeObject = Settings.Instance; + EditorApplication.ExecuteMenuItem("Window/General/Inspector"); + } + + public void Clear() + { + PlatformForBuildTarget.Clear(); + binaryCompatibilitiesBeforeBuild = null; + } + + public void CreateSettingsAsset(string assetName) + { + string resourcesPath = $"{FMODFolderFull}/Resources"; + + bool inPackagesFolder = resourcesPath.StartsWith("Packages/"); + if (inPackagesFolder) + { + resourcesPath = "Assets/Plugins/FMOD/Resources"; + } + EditorUtils.EnsureFolderExists(resourcesPath); + AssetDatabase.CreateAsset(RuntimeSettings, $"{resourcesPath}/{assetName}.asset"); + + AddPlatformsToAsset(); + } + + public void AddPlatformForBuildTargets(Platform platform) + { + foreach (BuildTarget buildTarget in platform.GetBuildTargets()) + { + if (buildTarget != BuildTarget.NoTarget) + { + try + { + PlatformForBuildTarget.Add(buildTarget, platform); + } + catch (Exception e) + { + RuntimeUtils.DebugLogWarningFormat("FMOD: Error platform {0} already added to build targets. : {1}", buildTarget, e.Message); + } + } + } + } + + // Adds a new platform group to the set of platforms. + public PlatformGroup AddPlatformGroup(string displayName, int sortOrder) + { + PlatformGroup group = PlatformGroup.Create(displayName, Legacy.Platform.None); + group.DisplaySortOrder = sortOrder; + + RuntimeSettings.AddPlatform(group); + AssetDatabase.AddObjectToAsset(group, RuntimeSettings); + + RuntimeSettings.LinkPlatform(group); + + return group; + } + + private void ClearPlatformSettings() + { + RemovePlatformFromAsset(RuntimeSettings.DefaultPlatform); + RemovePlatformFromAsset(RuntimeSettings.PlayInEditorPlatform); + + RuntimeSettings.Platforms.ForEach(RemovePlatformFromAsset); + + foreach (Platform platform in Resources.LoadAll(Settings.SettingsAssetName)) + { + RemovePlatformFromAsset(platform); + } + + RuntimeSettings.DefaultPlatform = null; + RuntimeSettings.PlayInEditorPlatform = null; + + RuntimeSettings.Platforms.Clear(); + PlatformForBuildTarget.Clear(); + RuntimeSettings.PlatformForRuntimePlatform.Clear(); + } + + // Testing function: Resets all platform settings. + public void ResetPlatformSettings() + { + ClearPlatformSettings(); + RuntimeSettings.OnEnable(); + } + + // Testing function: Reimports legacy platform settings. + public void ReimportLegacyPlatforms() + { + ClearPlatformSettings(); + RuntimeSettings.MigratedPlatforms.Clear(); + RuntimeSettings.OnEnable(); + } + + public void UpdateMigratedPlatform(Platform platform) + { + if (!RuntimeSettings.MigratedPlatforms.Contains(platform.LegacyIdentifier)) + { + RuntimeSettings.MigratedPlatforms.Add(platform.LegacyIdentifier); + } + } + + // Adds any missing platforms: + // * From the template collection + // * From the legacy settings + public void AddMissingPlatforms() + { + var newPlatforms = new List(); + + foreach (Settings.PlatformTemplate template in Settings.PlatformTemplates) + { + if (!RuntimeSettings.PlatformExists(template.Identifier)) + { + newPlatforms.Add(template.CreateInstance()); + } + } + + // Ensure that the default platform exists + if (!RuntimeSettings.DefaultPlatform) + { + RuntimeSettings.DefaultPlatform = ScriptableObject.CreateInstance(); + newPlatforms.Add(RuntimeSettings.DefaultPlatform); + } + + // Ensure that the Play In Editor platform exists + if (!RuntimeSettings.PlayInEditorPlatform) + { + RuntimeSettings.PlayInEditorPlatform = ScriptableObject.CreateInstance(); + newPlatforms.Add(RuntimeSettings.PlayInEditorPlatform); + } + + // Ensure that the default and Play In Editor platforms have properties + AffirmPlatformProperties(RuntimeSettings.DefaultPlatform); + AffirmPlatformProperties(RuntimeSettings.PlayInEditorPlatform); + + // Migrate plugins if necessary + var PluginsProperty = Platform.PropertyAccessors.Plugins; + + if (!RuntimeSettings.MigratedPlatforms.Contains(RuntimeSettings.DefaultPlatform.LegacyIdentifier)) + { + PluginsProperty.Set(RuntimeSettings.DefaultPlatform, RuntimeSettings.Plugins); + } + else if (!PluginsProperty.HasValue(RuntimeSettings.DefaultPlatform)) + { + PluginsProperty.Set(RuntimeSettings.DefaultPlatform, new List()); + } + + // Migrate LiveUpdatePort + if (!Platform.PropertyAccessors.LiveUpdatePort.HasValue(RuntimeSettings.DefaultPlatform)) + { + Platform.PropertyAccessors.LiveUpdatePort.Set(RuntimeSettings.DefaultPlatform, RuntimeSettings.LiveUpdatePort); + } + + // Create a map for migrating legacy settings + var platformMap = new Dictionary(); + + foreach (Platform platform in RuntimeSettings.Platforms.Concat(newPlatforms)) + { + if (platform.LegacyIdentifier != Legacy.Platform.None) + { + platformMap.Add(platform.LegacyIdentifier, platform); + } + } + + Func AffirmPlatform = null; + + // Ensures that all of the platform's ancestors exist. + Action AffirmAncestors = (platform) => + { + Legacy.Platform legacyParent = Legacy.Parent(platform.LegacyIdentifier); + + if (legacyParent != Legacy.Platform.None) + { + platform.ParentIdentifier = AffirmPlatform(legacyParent).Identifier; + } + }; + + // Gets the platform corresponding to legacyPlatform (or creates it if it is a group), + // and ensures that it has properties and all of its ancestors exist. + // Returns null if legacyPlatform is unknown. + AffirmPlatform = (legacyPlatform) => + { + Platform platform; + + if (platformMap.TryGetValue(legacyPlatform, out platform)) + { + platform.AffirmProperties(); + } + else if (Legacy.IsGroup(legacyPlatform)) + { + PlatformGroup group = PlatformGroup.Create(Legacy.DisplayName(legacyPlatform), legacyPlatform); + platformMap.Add(legacyPlatform, group); + newPlatforms.Add(group); + + platform = group; + } + else + { + // This is an unknown platform + return null; + } + + AffirmAncestors(platform); + + return platform; + }; + + // Gets the target plaform to use when migrating settings from legacyPlatform. + // Returns null if legacyPlatform is unknown or has already been migrated. + Func getMigrationTarget = (legacyPlatform) => + { + if (RuntimeSettings.MigratedPlatforms.Contains(legacyPlatform)) + { + // Already migrated + return null; + } + + return AffirmPlatform(legacyPlatform); + }; + + var speakerModeSettings = RuntimeSettings.SpeakerModeSettings.ConvertAll( + setting => new Legacy.PlatformSetting() + { + Value = (FMOD.SPEAKERMODE)setting.Value, + Platform = setting.Platform + } + ); + + // Migrate all the legacy settings, creating platforms as we need them via AffirmPlatform + MigrateLegacyPlatforms(speakerModeSettings, Platform.PropertyAccessors.SpeakerMode, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.SampleRateSettings, Platform.PropertyAccessors.SampleRate, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.LiveUpdateSettings, Platform.PropertyAccessors.LiveUpdate, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.OverlaySettings, Platform.PropertyAccessors.Overlay, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.BankDirectorySettings, Platform.PropertyAccessors.BuildDirectory, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.VirtualChannelSettings, Platform.PropertyAccessors.VirtualChannelCount, getMigrationTarget); + MigrateLegacyPlatforms(RuntimeSettings.RealChannelSettings, Platform.PropertyAccessors.RealChannelCount, getMigrationTarget); + + // Now we ensure that if a legacy group has settings, all of its descendants exist + // and inherit from it (even if they have no settings of their own), so that the + // inheritance structure matches the old system. + // We look at all groups (not just newly created ones), because a newly created platform + // may need to inherit from a preexisting group. + var groupsToProcess = new Queue(platformMap.Values.Where( + platform => platform is PlatformGroup + && platform.LegacyIdentifier != Legacy.Platform.None + && platform.HasAnyOverriddenProperties)); + + while (groupsToProcess.Count > 0) + { + Platform group = groupsToProcess.Dequeue(); + + // Ensure that all descendants exist + foreach (var child in platformMap.Values) + { + if (child.Active) + { + // Don't overwrite existing settings + continue; + } + + var legacyPlatform = child.LegacyIdentifier; + + if (legacyPlatform == Legacy.Platform.iOS || legacyPlatform == Legacy.Platform.Android) + { + // These platforms were overridden by MobileHigh and MobileLow in the old system + continue; + } + + if (RuntimeSettings.MigratedPlatforms.Contains(legacyPlatform)) + { + // The user may have deleted this platform since migration, so don't mess with it + continue; + } + + if (Legacy.Parent(legacyPlatform) == group.LegacyIdentifier) + { + child.AffirmProperties(); + child.ParentIdentifier = group.Identifier; + + if (child is PlatformGroup) + { + groupsToProcess.Enqueue(child as PlatformGroup); + } + } + } + } + + // Add all of the new platforms to the set of known platforms + foreach (Platform platform in newPlatforms) + { + RuntimeSettings.AddPlatform(platform); + } + + RuntimeSettings.Platforms.ForEach(UpdateMigratedPlatform); + } + + private void MigrateLegacyPlatforms(List settings, + Platform.PropertyAccessor property, Func getMigrationTarget) + where TSetting : Legacy.PlatformSetting + { + foreach (TSetting setting in settings) + { + Platform platform = getMigrationTarget(setting.Platform); + + if (platform != null) + { + property.Set(platform, setting.Value); + } + } + } + + // The platform that implements the current Unity build target. + public Platform CurrentEditorPlatform + { + get + { + return GetPlatform(EditorUserBuildSettings.activeBuildTarget); + } + } + + public Platform GetPlatform(BuildTarget buildTarget) + { + if (PlatformForBuildTarget.ContainsKey(buildTarget)) + { + return PlatformForBuildTarget[buildTarget]; + } + else + { + return RuntimeSettings.DefaultPlatform; + } + } + + public void SetPlatformParent(Platform platform, Platform newParent) + { + Platform oldParent = RuntimeSettings.FindPlatform(platform.ParentIdentifier); + + if (oldParent != null) + { + oldParent.ChildIdentifiers.Remove(platform.Identifier); + } + + if (newParent != null) + { + platform.ParentIdentifier = newParent.Identifier; + + newParent.ChildIdentifiers.Add(platform.Identifier); + SortPlatformChildren(newParent); + } + else + { + platform.ParentIdentifier = null; + } + } + + public void SetPlatformSortOrder(Platform platform, float sortOrder) + { + if (platform.DisplaySortOrder != sortOrder) + { + platform.DisplaySortOrder = sortOrder; + + if (platform.Parent != null) + { + SortPlatformChildren(platform.Parent); + } + } + } + + public void SortPlatformChildren(Platform platform) + { + platform.ChildIdentifiers.Sort((a, b) => { + Platform platformA = RuntimeSettings.FindPlatform(a); + Platform platformB = RuntimeSettings.FindPlatform(b); + + return platformA.DisplaySortOrder.CompareTo(platformB.DisplaySortOrder); + }); + } + + // Ensures that the given platform has valid properties. + private void AffirmPlatformProperties(Platform platform) + { + if (!platform.Active) + { + RuntimeUtils.DebugLogFormat("[FMOD] Cannot find properties for platform {0}, creating default properties", platform.Identifier); + RuntimeSettings.AddPlatformProperties(platform); + } + } + + private void RemovePlatformFromAsset(Platform platform) + { + if (AssetDatabase.Contains(platform)) + { + UnityEngine.Object.DestroyImmediate(platform, true); + } + } + + public bool CanBuildTarget(BuildTarget target, Platform.BinaryType binaryType, out string error) + { + if (Settings.Instance == null) + { + error = "Settings instance has not been initialized. Unable to continue build."; + return false; + } + + Platform platform; + + if (!PlatformForBuildTarget.TryGetValue(target, out platform)) + { + error = string.Format("No FMOD platform found for build target {0}. " + + "You may need to install a platform specific integration package from {1}.", + target, DownloadURL); + return false; + } + + IEnumerable missingPathsQuery = platform.GetBinaryFilePaths(target, binaryType) + .Where(path => !File.Exists(path) && !Directory.Exists(path)); + + if (missingPathsQuery.Any()) + { + string[] missingPaths = missingPathsQuery.Select(path => "- " + path).ToArray(); + + string summary; + + if (missingPaths.Length == 1) + { + summary = string.Format("There is an FMOD binary missing for build target {0}", target); + } + else + { + summary = string.Format("There are {0} FMOD binaries missing for build target {1}", + missingPaths.Length, target); + } + + if (binaryType == Platform.BinaryType.Logging) + { + summary += " (development build)"; + } + + error = string.Format( + "{0}:\n" + + "{1}\n" + + "Please run the {2} menu command.\n", + summary, string.Join("\n", missingPaths), FileReorganizer.ReorganizerMenuItemPath); + return false; + } + + error = null; + return true; + } + + public void PreprocessBuild(BuildTarget target, Platform.BinaryType binaryType) + { + Platform platform = PlatformForBuildTarget[target]; + + PreprocessStaticPlugins(platform, target); + + SelectBinaries(platform, target, binaryType); + } + + private void PostprocessBuild(BuildTarget target) + { + foreach(string path in binaryCompatibilitiesBeforeBuild.Keys) + { + PluginImporter importer = AssetImporter.GetAtPath(path) as PluginImporter; + + if (importer != null) + { + importer.SetCompatibleWithPlatform(target, binaryCompatibilitiesBeforeBuild[path]); + } + } + } + + private void PreprocessStaticPlugins(Platform platform, BuildTarget target) + { + // Ensure we don't have leftover temporary changes from a previous build. + CleanTemporaryFiles(); + + BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target); +#if UNITY_2021_2_OR_NEWER + NamedBuildTarget namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup); + ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(namedBuildTarget); +#else + ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(buildTargetGroup); +#endif + + if (platform.StaticPlugins.Count > 0) + { + if (scriptingBackend == ScriptingImplementation.IL2CPP) + { + Action reportError = message => { + RuntimeUtils.DebugLogWarningFormat("FMOD: Error processing static plugins for platform {0}: {1}", + platform.DisplayName, message); + }; + + if (!AssetDatabase.IsValidFolder(CacheFolderFull)) + { + RuntimeUtils.DebugLogFormat("Creating {0}", CacheFolderFull); + AssetDatabase.CreateFolder(FMODFolderFull, CacheFolderName); + } + + // Generate registration code and import it so it's included in the build. + RuntimeUtils.DebugLogFormat("FMOD: Generating static plugin registration code in {0}", RegisterStaticPluginsAssetPathFull); + + string filePath = RegisterStaticPluginsAssetPathRelative.Replace("Assets", Application.dataPath); + CodeGeneration.GenerateStaticPluginRegistration(filePath, platform, reportError); + AssetDatabase.ImportAsset(RegisterStaticPluginsAssetPathFull); + } + else + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: Platform {0} has {1} static plugins specified, " + + "but static plugins are only supported on the IL2CPP scripting backend", + platform.DisplayName, platform.StaticPlugins.Count); + } + } + } + + public void CleanTemporaryFiles() + { + DeleteTemporaryFile(RegisterStaticPluginsAssetPathFull); + } + + public void DeleteTemporaryFile(string assetPath) + { + bool assetExists = !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(assetPath)); + + if (assetExists && AssetDatabase.DeleteAsset(assetPath)) + { + RuntimeUtils.DebugLogFormat("FMOD: Removed temporary file {0}", assetPath); + } + } + + private static void SelectBinaries(Platform platform, BuildTarget target, Platform.BinaryType binaryType) + { + string message = string.Format("FMOD: Selected binaries for platform {0}{1}:", target, + (binaryType == Platform.BinaryType.Logging) ? " (development build)" : string.Empty); + + Instance.binaryCompatibilitiesBeforeBuild = new Dictionary(); + + HashSet enabledPaths = new HashSet(); + + foreach (string path in platform.GetBinaryAssetPaths(target, binaryType | Platform.BinaryType.Optional)) + { + PluginImporter importer = AssetImporter.GetAtPath(path) as PluginImporter; + + if (importer is PluginImporter) + { + Instance.binaryCompatibilitiesBeforeBuild.Add(path, importer.GetCompatibleWithPlatform(target)); + + importer.SetCompatibleWithPlatform(target, true); + + enabledPaths.Add(path); + + message += string.Format("\n- Enabled {0}", path); + } + } + + foreach (string path in platform.GetBinaryAssetPaths(target, Platform.BinaryType.All)) + { + if (!enabledPaths.Contains(path)) + { + PluginImporter importer = AssetImporter.GetAtPath(path) as PluginImporter; + + if (importer is PluginImporter) + { + Instance.binaryCompatibilitiesBeforeBuild.Add(path, importer.GetCompatibleWithPlatform(target)); + + importer.SetCompatibleWithPlatform(target, false); + + message += string.Format("\n- Disabled {0}", path); + } + } + } + + RuntimeUtils.DebugLog(message); + } + + public bool ForceLoggingBinaries { get; set; } = false; + + public class BuildProcessor : IPreprocessBuildWithReport, IPostprocessBuildWithReport + { + public int callbackOrder { get { return 0; } } + + public void OnPreprocessBuild(BuildReport report) + { + Platform.BinaryType binaryType; + + if ((report.summary.options & BuildOptions.Development) == BuildOptions.Development + || EditorSettings.Instance.ForceLoggingBinaries) + { + binaryType = Platform.BinaryType.Logging; + } + else + { + binaryType = Platform.BinaryType.Release; + } + + string error; + if (!EditorSettings.Instance.CanBuildTarget(report.summary.platform, binaryType, out error)) + { + throw new BuildFailedException(error); + } + + bool androidPatchBuildPrevious = Settings.Instance.AndroidPatchBuild; + if ((report.summary.options & BuildOptions.PatchPackage) == BuildOptions.PatchPackage) + { + Settings.Instance.AndroidPatchBuild = true; + } + else + { + Settings.Instance.AndroidPatchBuild = false; + } + if (androidPatchBuildPrevious != Settings.Instance.AndroidPatchBuild) + { + EditorUtility.SetDirty(Settings.Instance); + } + + EditorSettings.Instance.PreprocessBuild(report.summary.platform, binaryType); + } + + public void OnPostprocessBuild(BuildReport report) + { + Instance.PostprocessBuild(report.summary.platform); + Settings.Instance.AndroidPatchBuild = false; + } + } + + public void CheckActiveBuildTarget() + { + Settings.EditorSettings.CleanTemporaryFiles(); + + Platform.BinaryType binaryType = EditorUserBuildSettings.development + ? Platform.BinaryType.Logging + : Platform.BinaryType.Release; + + string error; + if (!CanBuildTarget(EditorUserBuildSettings.activeBuildTarget, binaryType, out error)) + { + RuntimeUtils.DebugLogWarning(error); + + if (EditorWindow.HasOpenInstances()) + { + GUIContent message = + new GUIContent("FMOD detected issues with this platform!\nSee the Console for details."); + EditorWindow.GetWindow().ShowNotification(message, 10); + } + } + } + + // Adds all platforms to the settings asset, so they get stored in the same file as the main + // Settings object. + public void AddPlatformsToAsset() + { + RuntimeSettings.Platforms.ForEach(AddPlatformToAsset); + } + + private void AddPlatformToAsset(Platform platform) + { + if (!AssetDatabase.Contains(platform)) + { + platform.name = "FMODStudioSettingsPlatform"; + AssetDatabase.AddObjectToAsset(platform, RuntimeSettings); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs.meta b/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs.meta new file mode 100644 index 0000000..33884c4 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3c9e3e2137498d343a2e31906a12dec2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs b/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs new file mode 100644 index 0000000..4cbcb0c --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs @@ -0,0 +1,1884 @@ +#if UNITY_ADDRESSABLES_EXIST + // The Addressables package depends on the ScriptableBuildPipeline package + #define UNITY_SCRIPTABLEBUILDPIPELINE_EXIST +#endif + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; +using UnityEditor; +using UnityEditor.Build; +#if UNITY_SCRIPTABLEBUILDPIPELINE_EXIST +using UnityEditor.Build.Pipeline; +#endif +using UnityEditor.SceneManagement; +using System.IO; +using System.Text; +using System.Net.Sockets; + +namespace FMODUnity +{ + public class EditorUtils : MonoBehaviour + { + public const string BuildFolder = "Build"; + + private static FMOD.Studio.System system; + private static FMOD.SPEAKERMODE speakerMode; + private static string encryptionKey; + + private static List loadedPreviewBanks = new List(); + private static FMOD.Studio.EventDescription previewEventDesc; + private static FMOD.Studio.EventInstance previewEventInstance; + + private const int StudioScriptPort = 3663; + private static NetworkStream networkStream = null; + private static Socket socket = null; + private static IAsyncResult socketConnection = null; + + public static void CheckResult(FMOD.RESULT result) + { + if (result != FMOD.RESULT.OK) + { + RuntimeUtils.DebugLogError(string.Format("FMOD Studio: Encountered Error: {0} {1}", result, FMOD.Error.String(result))); + } + } + + public static void ValidateSource(out bool valid, out string reason) + { + valid = true; + reason = ""; + var settings = Settings.Instance; + if (settings.HasSourceProject) + { + if (string.IsNullOrEmpty(settings.SourceProjectPath)) + { + valid = false; + reason = "The FMOD Studio project path must be set to an .fspro file."; + return; + } + if (!File.Exists(settings.SourceProjectPath)) + { + valid = false; + reason = string.Format("The FMOD Studio project path '{0}' does not exist.", settings.SourceProjectPath); + return; + } + + string projectPath = settings.SourceProjectPath; + string projectFolder = Path.GetDirectoryName(projectPath); + string buildFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(projectFolder, BuildFolder)); + if (!Directory.Exists(buildFolder) || + Directory.GetDirectories(buildFolder).Length == 0 || + Directory.GetFiles(Directory.GetDirectories(buildFolder)[0], "*.bank", SearchOption.AllDirectories).Length == 0 + ) + { + valid = false; + reason = string.Format("The FMOD Studio project '{0}' does not contain any built banks. Please build your project in FMOD Studio.", settings.SourceProjectPath); + return; + } + } + else + { + if (String.IsNullOrEmpty(settings.SourceBankPath)) + { + valid = false; + reason = "The build path has not been set."; + return; + } + if (!Directory.Exists(settings.SourceBankPath)) + { + valid = false; + reason = string.Format("The build path '{0}' does not exist.", settings.SourceBankPath); + return; + } + + if (settings.HasPlatforms) + { + if (Directory.GetDirectories(settings.SourceBankPath).Length == 0) + { + valid = false; + reason = string.Format("Build path '{0}' does not contain any platform sub-directories. Please check that the build path is correct.", settings.SourceBankPath); + return; + } + } + else + { + if (Directory.GetFiles(settings.SourceBankPath, "*.strings.bank").Length == 0) + { + valid = false; + reason = string.Format("Build path '{0}' does not contain any built banks.", settings.SourceBankPath); + return; + } + } + } + } + + public static string[] GetBankPlatforms() + { + string buildFolder = Settings.Instance.SourceBankPath; + try + { + if (Directory.GetFiles(buildFolder, "*.bank").Length == 0) + { + string[] buildDirectories = Directory.GetDirectories(buildFolder); + string[] buildNames = new string[buildDirectories.Length]; + for (int i = 0; i < buildDirectories.Length; i++) + { + buildNames[i] = Path.GetFileNameWithoutExtension(buildDirectories[i]); + } + return buildNames; + } + } + catch + { + } + return new string[0]; + } + + public static string VersionString(uint version) + { + uint major = (version & 0x00FF0000) >> 16; + uint minor = (version & 0x0000FF00) >> 8; + uint patch = (version & 0x000000FF); + + return string.Format("{0:X1}.{1:X2}.{2:X2}", major, minor, patch); + } + + public static string DurationString(float seconds) + { + float minutes = seconds / 60; + float hours = minutes / 60; + + if (hours >= 1) + { + return Pluralize(Mathf.FloorToInt(hours), "hour", "hours"); + } + else if (minutes >= 1) + { + return Pluralize(Mathf.FloorToInt(minutes), "minute", "minutes"); + } + else if (seconds >= 1) + { + return Pluralize(Mathf.FloorToInt(seconds), "second", "seconds"); + } + else + { + return "a moment"; + } + } + + public static string SeriesString(string separator, string finalSeparator, IEnumerable elements) + { + if (!elements.Any()) + { + return string.Empty; + } + else if (!elements.Skip(1).Any()) + { + return elements.First(); + } + else + { + return string.Join(separator, elements.Take(elements.Count() - 1)) + finalSeparator + elements.Last(); + } + } + + public static string Pluralize(int count, string singular, string plural) + { + return string.Format("{0} {1}", count, (count == 1) ? singular : plural); + } + + public static Texture2D LoadImage(string filename) + { + Texture2D texture = EditorGUIUtility.Load($"{RuntimeUtils.PluginBasePath}/images/{filename}") as Texture2D; + + if (texture == null) + { + texture = EditorGUIUtility.Load($"Assets/Editor Default Resources/FMOD/{filename}") as Texture2D; + } + + return texture; + } + + public static string GameObjectPath(Component component, GameObject root = null) + { + Transform transform = component.transform; + + StringBuilder objectPath = new StringBuilder(); + + while(transform != null && transform.gameObject != root) + { + if (objectPath.Length > 0) + { + objectPath.Insert(0, "/"); + } + + objectPath.Insert(0, transform.name); + + transform = transform.parent; + } + + return objectPath.ToString(); + } + + public static bool HasAttribute(MemberInfo member) + where T : Attribute + { + Attribute[] attributes = Attribute.GetCustomAttributes(member, typeof(Attribute), true); + + return attributes.Any(a => typeof(T).IsAssignableFrom(a.GetType())); + } + + public static bool AssetExists(string path) + { + string fullPath = $"{Environment.CurrentDirectory}/{path}"; + + // We check that the file or directory exists as well because recently deleted assets remain in the database + return !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(path)) + && (File.Exists(fullPath) || Directory.Exists(fullPath)); + } + + public static void EnsureFolderExists(string folderPath) + { + if (!AssetDatabase.IsValidFolder(folderPath)) + { + string parentFolder = GetParentFolder(folderPath); + + EnsureFolderExists(parentFolder); + + string folderName = Path.GetFileName(folderPath); + + AssetDatabase.CreateFolder(parentFolder, folderName); + } + } + + // Path.GetDirectoryName replaces '/' with '\\' in some scripting runtime versions, + // so we have to roll our own. + public static string GetParentFolder(string assetPath) + { + int endIndex = assetPath.LastIndexOf('/'); + + return (endIndex > 0) ? assetPath.Substring(0, endIndex) : string.Empty; + } + + public static void DrawLegacyEvent(SerializedProperty property, string migrationTarget) + { + // Display the legacy event field if it is not empty + if (!string.IsNullOrEmpty(property.stringValue)) + { + EditorGUILayout.PropertyField(property, new GUIContent("Legacy Event")); + + using (new EditorGUI.IndentLevelScope()) + { + GUIContent content = new GUIContent( + string.Format("Will be migrated to {0}", migrationTarget), + EditorGUIUtility.IconContent("console.infoicon.sml").image); + GUIStyle style = new GUIStyle(GUI.skin.label) { richText = true }; + + Rect rect = EditorGUILayout.GetControlRect(false, style.CalcSize(content).y); + rect = EditorGUI.IndentedRect(rect); + + GUI.Label(rect, content, style); + } + } + } + + // Gets a control rect, draws a help button at the end of the line, + // and returns a rect describing the remaining space. + public static Rect DrawHelpButtonLayout(Func createContent) + { + Vector2 helpSize = GetHelpButtonSize(); + + Rect rect = EditorGUILayout.GetControlRect(true, helpSize.y); + + return DrawHelpButton(rect, createContent); + } + + public static Rect DrawHelpButton(Rect rect, Func createContent) + { + GUIContent content; + GUIStyle style; + GetHelpButtonData(out content, out style); + + Vector2 helpSize = style.CalcSize(content); + + Rect helpRect = rect; + helpRect.xMin = helpRect.xMax - helpSize.x; + + if (GUI.Button(helpRect, content, style)) + { + PopupWindow.Show(helpRect, createContent()); + } + + Rect remainderRect = rect; + remainderRect.xMax = helpRect.xMin; + + return remainderRect; + } + + public static float DrawParameterValueLayout(float value, EditorParamRef paramRef) + { + if (paramRef.Type == ParameterType.Labeled) + { + return EditorGUILayout.Popup((int)value, paramRef.Labels); + } + else if (paramRef.Type == ParameterType.Discrete) + { + return EditorGUILayout.IntSlider((int)value, (int)paramRef.Min, (int)paramRef.Max); + } + else + { + return EditorGUILayout.Slider(value, paramRef.Min, paramRef.Max); + } + } + + public static Vector2 GetHelpButtonSize() + { + GUIContent content; + GUIStyle style; + GetHelpButtonData(out content, out style); + + return style.CalcSize(content); + } + + private static void GetHelpButtonData(out GUIContent content, out GUIStyle style) + { + content = EditorGUIUtility.IconContent("_Help"); + style = GUI.skin.label; + } + +#if !FMOD_STORE_UPLOAD + [InitializeOnLoadMethod] +#endif + private static void Startup() + { + EditorApplication.update += Update; + AssemblyReloadEvents.beforeAssemblyReload += HandleBeforeAssemblyReload; + EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; + EditorApplication.pauseStateChanged += HandleOnPausedModeChanged; + + if (Application.isBatchMode) + { + BuildStatusWatcher.Startup(); + } + else + { + EditorApplication.update += CallStartupMethodsWhenReady; + } + } + + private static void HandleBeforeAssemblyReload() + { + DestroySystem(); + } + + private static void HandleOnPausedModeChanged(PauseState state) + { + if (RuntimeManager.IsInitialized && RuntimeManager.HaveMasterBanksLoaded) + { + RuntimeManager.GetBus("bus:/").setPaused(EditorApplication.isPaused); + RuntimeManager.StudioSystem.update(); + } + } + + private static void HandleOnPlayModeChanged(PlayModeStateChange state) + { + // Entering Play Mode will cause scripts to reload, losing all state + // This is the last chance to clean up FMOD and avoid a leak. + if (state == PlayModeStateChange.ExitingEditMode) + { + DestroySystem(); + } + } + + private static void Update() + { + // Update the editor system + if (system.isValid()) + { + CheckResult(system.update()); + + if (speakerMode != Settings.Instance.PlayInEditorPlatform.SpeakerMode) + { + RecreateSystem(); + } + + if (encryptionKey != Settings.Instance.EncryptionKey) + { + RecreateSystem(); + } + } + + for (int i = 0; i < previewEventInstances.Count; i++) + { + var instance = previewEventInstances[i]; + if (instance.isValid()) + { + FMOD.Studio.PLAYBACK_STATE state; + instance.getPlaybackState(out state); + if (state == FMOD.Studio.PLAYBACK_STATE.STOPPED) + { + PreviewStop(instance); + i--; + } + } + } + } + + private static void CallStartupMethodsWhenReady() + { + if (EditorApplication.isUpdating) + { + // Some startup code accesses Settings.Instance; this can obliterate settings if + // the asset database is being updated, so wait until the update is finished. + return; + } + + EditorApplication.update -= CallStartupMethodsWhenReady; + + // Explicitly initialize Settings so that both it and EditorSettings will work. + Settings.Initialize(); + Settings.EditorSettings.CheckActiveBuildTarget(); + + CheckBaseFolderGUID(); + CheckMacLibraries(); + + Legacy.CleanTemporaryChanges(); + CleanObsoleteFiles(); + +#if UNITY_TIMELINE_EXIST + // Register timeline event receivers. + FMODEventPlayableBehavior.Enter += (sender, args) => + { + FMODEventPlayableBehavior behavior = sender as FMODEventPlayableBehavior; + if (!string.IsNullOrEmpty(behavior.EventReference.Path)) + { + LoadPreviewBanks(); + EditorEventRef eventRef = EventManager.EventFromPath(behavior.EventReference.Path); + Dictionary paramValues = new Dictionary(); + foreach (EditorParamRef param in eventRef.Parameters) + { + paramValues.Add(param.Name, param.Default); + } + foreach (ParamRef param in behavior.Parameters) + { + paramValues[param.Name] = param.Value; + } + + args.eventInstance = PreviewEvent(eventRef, paramValues, behavior.CurrentVolume, behavior.ClipStartTime); + } + }; + + FMODEventPlayableBehavior.Exit += (sender, args) => + { + FMODEventPlayableBehavior behavior = sender as FMODEventPlayableBehavior; + if (behavior.StopType != STOP_MODE.None) + { + FMOD.Studio.STOP_MODE stopType = behavior.StopType == STOP_MODE.Immediate ? FMOD.Studio.STOP_MODE.IMMEDIATE : FMOD.Studio.STOP_MODE.ALLOWFADEOUT; + PreviewStop(args.eventInstance, stopType); + } + }; + + FMODEventPlayableBehavior.GraphStop += (sender, args) => + { + PreviewStop(args.eventInstance); + }; + + FMODEventPlayable.OnCreatePlayable += (sender, args) => + { + FMODEventPlayable playable = sender as FMODEventPlayable; + if (playable.Parameters.Length > 0 || playable.Template.ParameterLinks.Count > 0) + { + LoadPreviewBanks(); + FMOD.Studio.EventDescription eventDescription; + system.getEventByID(playable.EventReference.Guid, out eventDescription); + playable.LinkParameters(eventDescription); + } + }; +#endif + + BuildStatusWatcher.Startup(); + BankRefresher.Startup(); + BoltIntegration.Startup(); + EventManager.Startup(); + SetupWizardWindow.Startup(); + } + + private static void RecreateSystem() + { + StopAllPreviews(); + DestroySystem(); + CreateSystem(); + } + + private static void DestroySystem() + { + if (system.isValid()) + { + RuntimeUtils.DebugLog("FMOD Studio: Destroying editor system instance"); + UnloadPreviewBanks(); + system.release(); + system.clearHandle(); + } + } + + private static void CreateSystem() + { + RuntimeUtils.DebugLog("FMOD Studio: Creating editor system instance"); + RuntimeUtils.EnforceLibraryOrder(); + + FMOD.RESULT result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod_editor.log"); + if (result != FMOD.RESULT.OK) + { + RuntimeUtils.DebugLogWarning("FMOD Studio: Cannot open fmod_editor.log. Logging will be disabled for importing and previewing"); + } + + CheckResult(FMOD.Studio.System.create(out system)); + + FMOD.System lowlevel; + CheckResult(system.getCoreSystem(out lowlevel)); + + // Use play-in-editor speaker mode for event browser preview and metering + speakerMode = Settings.Instance.PlayInEditorPlatform.SpeakerMode; + CheckResult(lowlevel.setSoftwareFormat(0, speakerMode, 0)); + + encryptionKey = Settings.Instance.EncryptionKey; + if (!string.IsNullOrEmpty(encryptionKey)) + { + FMOD.Studio.ADVANCEDSETTINGS studioAdvancedSettings = new FMOD.Studio.ADVANCEDSETTINGS(); + CheckResult(system.setAdvancedSettings(studioAdvancedSettings, encryptionKey)); + } + + CheckResult(system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero)); + + FMOD.ChannelGroup master; + CheckResult(lowlevel.getMasterChannelGroup(out master)); + FMOD.DSP masterHead; + CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead)); + CheckResult(masterHead.setMeteringEnabled(false, true)); + } + + public static void UpdateParamsOnEmitter(SerializedObject serializedObject, string path) + { + if (string.IsNullOrEmpty(path) || EventManager.EventFromPath(path) == null) + { + return; + } + + var eventRef = EventManager.EventFromPath(path); + serializedObject.ApplyModifiedProperties(); + if (serializedObject.isEditingMultipleObjects) + { + foreach (var obj in serializedObject.targetObjects) + { + UpdateParamsOnEmitter(obj, eventRef); + } + } + else + { + UpdateParamsOnEmitter(serializedObject.targetObject, eventRef); + } + serializedObject.Update(); + } + + private static void UpdateParamsOnEmitter(UnityEngine.Object obj, EditorEventRef eventRef) + { + var emitter = obj as StudioEventEmitter; + if (emitter == null) + { + // Custom game object + return; + } + + for (int i = 0; i < emitter.Params.Length; i++) + { + if (!eventRef.LocalParameters.Exists((x) => x.Name == emitter.Params[i].Name)) + { + int end = emitter.Params.Length - 1; + emitter.Params[i] = emitter.Params[end]; + Array.Resize(ref emitter.Params, end); + i--; + } + } + + emitter.OverrideAttenuation = false; + emitter.OverrideMinDistance = eventRef.MinDistance; + emitter.OverrideMaxDistance = eventRef.MaxDistance; + } + + public static FMOD.Studio.System System + { + get + { + if (!system.isValid()) + { + CreateSystem(); + } + return system; + } + } + + [MenuItem("FMOD/Help/Getting Started", priority = 2)] + private static void OnlineGettingStarted() + { + OpenOnlineDocumentation("unity", "user-guide"); + } + + [MenuItem("FMOD/Help/Integration Manual", priority = 3)] + public static void OnlineManual() + { + OpenOnlineDocumentation("unity"); + } + + [MenuItem("FMOD/Help/API Manual", priority = 4)] + private static void OnlineAPIDocs() + { + OpenOnlineDocumentation("api"); + } + + [MenuItem("FMOD/Help/Support Forum", priority = 16)] + private static void OnlineQA() + { + Application.OpenURL("https://qa.fmod.com/"); + } + + [MenuItem("FMOD/Help/Revision History", priority = 5)] + private static void OnlineRevisions() + { + OpenOnlineDocumentation("api", "welcome-revision-history"); + } + + public static void OpenOnlineDocumentation(string section, string page = null, string anchor = null) + { + const string Prefix = "https://fmod.com/docs/"; + string version = string.Format("{0:X}.{1:X}", FMOD.VERSION.number >> 16, (FMOD.VERSION.number >> 8) & 0xFF); + string url; + + if (!string.IsNullOrEmpty(page)) + { + if (!string.IsNullOrEmpty(anchor)) + { + url = string.Format("{0}/{1}/{2}/{3}.html#{4}", Prefix, version, section, page, anchor); + } + else + { + url = string.Format("{0}/{1}/{2}/{3}.html", Prefix, version, section, page); + } + } + else + { + url = string.Format("{0}/{1}/{2}", Prefix, version, section); + } + + Application.OpenURL(url); + } + + [MenuItem("FMOD/About Integration", priority = 7)] + public static void About() + { + FMOD.System lowlevel; + CheckResult(System.getCoreSystem(out lowlevel)); + + uint version; + CheckResult(lowlevel.getVersion(out version)); + + string text = string.Format( + "Version: {0}\n\nCopyright \u00A9 Firelight Technologies Pty, Ltd. 2014-2024 \n\n" + + "See LICENSE.TXT for additional license information.", + VersionString(version)); + + EditorUtility.DisplayDialog("FMOD Studio Unity Integration", text, "OK"); + } + + private static List previewEventInstances = new List(); + + public static bool PreviewBanksLoaded + { + get { return loadedPreviewBanks.Count > 0; } + } + + public static void LoadPreviewBanks() + { + if (PreviewBanksLoaded) + { + return; + } + + foreach (var bank in EventManager.Banks) + { + FMOD.Studio.Bank previewBank; + FMOD.RESULT result = System.loadBankFile(bank.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out previewBank); + if (result != FMOD.RESULT.ERR_EVENT_ALREADY_LOADED) // ignore error when a bank is already loaded, e.g. localized banks. + { + CheckResult(result); + } + loadedPreviewBanks.Add(previewBank); + } + } + + public static void UnloadPreviewBanks() + { + if (!PreviewBanksLoaded) + { + return; + } + + loadedPreviewBanks.ForEach(x => { x.unload(); x.clearHandle(); }); + loadedPreviewBanks.Clear(); + } + + public static FMOD.Studio.EventInstance PreviewEvent(EditorEventRef eventRef, Dictionary previewParamValues, float volume = 1, float startTime = 0.0f) + { + FMOD.Studio.EventDescription eventDescription; + FMOD.Studio.EventInstance eventInstance; + + CheckResult(System.getEventByID(eventRef.Guid, out eventDescription)); + CheckResult(eventDescription.createInstance(out eventInstance)); + + foreach (EditorParamRef param in eventRef.Parameters) + { + FMOD.Studio.PARAMETER_DESCRIPTION paramDesc; + if (param.IsGlobal) + { + CheckResult(System.getParameterDescriptionByName(param.Name, out paramDesc)); + } + else + { + CheckResult(eventDescription.getParameterDescriptionByName(param.Name, out paramDesc)); + } + + float value = previewParamValues.ContainsKey(param.Name) ? previewParamValues[param.Name] : param.Default; + param.ID = paramDesc.id; + + if (param.IsGlobal) + { + CheckResult(System.setParameterByID(param.ID, value)); + } + else + { + CheckResult(eventInstance.setParameterByID(param.ID, value)); + } + } + + CheckResult(eventInstance.setVolume(volume)); + CheckResult(eventInstance.setTimelinePosition((int)(startTime * 1000.0f))); + CheckResult(eventInstance.start()); + + previewEventInstances.Add(eventInstance); + + return eventInstance; + } + + public static void PreviewPause(FMOD.Studio.EventInstance eventInstance) + { + if (eventInstance.isValid() && previewEventInstances.Contains(eventInstance)) + { + bool paused; + CheckResult(eventInstance.getPaused(out paused)); + CheckResult(eventInstance.setPaused(!paused)); + } + } + + public static void PreviewStop(FMOD.Studio.EventInstance eventInstance, FMOD.Studio.STOP_MODE stopMode = FMOD.Studio.STOP_MODE.IMMEDIATE) + { + if (previewEventInstances.Contains(eventInstance)) + { + previewEventInstances.Remove(eventInstance); + if (eventInstance.isValid()) + { + eventInstance.stop(stopMode); + eventInstance.release(); + eventInstance.clearHandle(); + } + } + } + + public static void StopAllPreviews() + { + foreach (FMOD.Studio.EventInstance eventInstance in previewEventInstances) + { + PreviewStop(eventInstance); + } + } + + public static float[] GetMetering() + { + FMOD.System lowlevel; + CheckResult(System.getCoreSystem(out lowlevel)); + FMOD.ChannelGroup master; + CheckResult(lowlevel.getMasterChannelGroup(out master)); + FMOD.DSP masterHead; + CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead)); + + FMOD.DSP_METERING_INFO outputMetering; + CheckResult(masterHead.getMeteringInfo(IntPtr.Zero, out outputMetering)); + + FMOD.SPEAKERMODE mode; + int rate, raw; + lowlevel.getSoftwareFormat(out rate, out mode, out raw); + int channels; + lowlevel.getSpeakerModeChannels(mode, out channels); + + float[] data = new float[channels]; + if (outputMetering.numchannels > 0) + { + Array.Copy(outputMetering.rmslevel, data, channels); + } + return data; + } + + private static NetworkStream ScriptStream + { + get + { + if (networkStream == null) + { + try + { + if (socket == null) + { + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + } + + if (!socket.Connected) + { + socketConnection = socket.BeginConnect("127.0.0.1", StudioScriptPort, null, null); + socketConnection.AsyncWaitHandle.WaitOne(); + socket.EndConnect(socketConnection); + socketConnection = null; + } + + networkStream = new NetworkStream(socket); + + byte[] headerBytes = new byte[128]; + int read = ScriptStream.Read(headerBytes, 0, 128); + string header = Encoding.UTF8.GetString(headerBytes, 0, read - 1); + if (header.StartsWith("log():")) + { + RuntimeUtils.DebugLog("FMOD Studio: Script Client returned " + header.Substring(6)); + } + } + catch (Exception e) + { + RuntimeUtils.DebugLog("FMOD Studio: Script Client failed to connect - Check FMOD Studio is running"); + + socketConnection = null; + socket = null; + networkStream = null; + + throw e; + } + } + return networkStream; + } + } + + private static void AsyncConnectCallback(IAsyncResult result) + { + try + { + socket.EndConnect(result); + } + catch (Exception) + { + } + finally + { + socketConnection = null; + } + } + + public static bool IsConnectedToStudio() + { + try + { + if (socket != null && socket.Connected) + { + if (SendScriptCommand("true")) + { + return true; + } + } + + if (socketConnection == null) + { + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socketConnection = socket.BeginConnect("127.0.0.1", StudioScriptPort, AsyncConnectCallback, null); + } + + return false; + + } + catch(Exception e) + { + RuntimeUtils.DebugLogException(e); + return false; + } + } + + public static bool SendScriptCommand(string command) + { + byte[] commandBytes = Encoding.UTF8.GetBytes(command); + try + { + ScriptStream.Write(commandBytes, 0, commandBytes.Length); + byte[] commandReturnBytes = new byte[128]; + int read = ScriptStream.Read(commandReturnBytes, 0, 128); + string result = Encoding.UTF8.GetString(commandReturnBytes, 0, read - 1); + return (result.Contains("true")); + } + catch (Exception) + { + if (networkStream != null) + { + networkStream.Close(); + networkStream = null; + } + return false; + } + } + + + public static string GetScriptOutput(string command) + { + byte[] commandBytes = Encoding.UTF8.GetBytes(command); + try + { + ScriptStream.Write(commandBytes, 0, commandBytes.Length); + byte[] commandReturnBytes = new byte[2048]; + int read = ScriptStream.Read(commandReturnBytes, 0, commandReturnBytes.Length); + string result = Encoding.UTF8.GetString(commandReturnBytes, 0, read - 1); + if (result.StartsWith("out():")) + { + return result.Substring(6).Trim(); + } + return null; + } + catch (Exception) + { + networkStream.Close(); + networkStream = null; + return null; + } + } + + private static string GetMasterBank() + { + GetScriptOutput(string.Format("masterBankFolder = studio.project.workspace.masterBankFolder;")); + string bankCountString = GetScriptOutput(string.Format("masterBankFolder.items.length;")); + int bankCount = int.Parse(bankCountString); + for (int i = 0; i < bankCount; i++) + { + string isMaster = GetScriptOutput(string.Format("masterBankFolder.items[{1}].isOfExactType(\"MasterBank\");", i)); + if (isMaster == "true") + { + string guid = GetScriptOutput(string.Format("masterBankFolder.items[{1}].id;", i)); + return guid; + } + } + return ""; + } + + private static bool CheckForNameConflict(string folderGuid, string eventName) + { + const string checkForNameConflictFunc = + @"function(folderGuid, eventName) { + var nameConflict = false; + studio.project.lookup(folderGuid).items.forEach(function(val) { + nameConflict |= val.name == eventName; + }); + return nameConflict; + }"; + + string conflictBool = GetScriptOutput(string.Format("({0})(\"{1}\", \"{2}\")", checkForNameConflictFunc, folderGuid, eventName)); + return conflictBool == "1"; + } + + public static string CreateStudioEvent(string eventPath, string eventName) + { + var folders = eventPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + string folderGuid = GetScriptOutput("studio.project.workspace.masterEventFolder.id;"); + + const string getFolderGuidFunc = + @"function(parentGuid, folderName) { + folderGuid = """"; + studio.project.lookup(parentGuid).items.forEach(function(val) { + folderGuid = val.isOfType(""EventFolder"") && val.name == folderName ? val.id : folderGuid; + }); + if (folderGuid == """") + { + var newFolder = studio.project.create(""EventFolder""); + newFolder.name = folderName; + newFolder.folder = studio.project.lookup(parentGuid); + folderGuid = newFolder.id; + } + return folderGuid; + }"; + + for (int i = 0; i < folders.Length; i++) + { + string parentGuid = folderGuid; + folderGuid = GetScriptOutput(string.Format("({0})(\"{1}\", \"{2}\")", getFolderGuidFunc, parentGuid, folders[i])); + } + + if (CheckForNameConflict(folderGuid, eventName)) + { + EditorUtility.DisplayDialog("Name Conflict", string.Format("The event {0} already exists under {1}", eventName, eventPath), "OK"); + return null; + } + + const string createEventFunc = + @"function(eventName, folderGuid) { + event = studio.project.create(""Event""); + event.note = ""Placeholder created via Unity""; + event.name = eventName; + event.folder = studio.project.lookup(folderGuid); + + track = studio.project.create(""GroupTrack""); + track.mixerGroup.output = event.mixer.masterBus; + track.mixerGroup.name = ""Audio 1""; + event.relationships.groupTracks.add(track); + + tag = studio.project.create(""Tag""); + tag.name = ""placeholder""; + tag.folder = studio.project.workspace.masterTagFolder; + event.relationships.tags.add(tag); + + return event.id; + }"; + + string eventGuid = GetScriptOutput(string.Format("({0})(\"{1}\", \"{2}\")", createEventFunc, eventName, folderGuid)); + return eventGuid; + } + + // The FMOD base folder needs to have a known GUID so that we can find it + // if it has been moved, and so that platform specific integration packages can + // be installed correctly. + // + // However, old FMOD packages didn't specify a GUID for the base folder, meaning Unity + // would generate a new one. If this is the case, we need to patch the metadata with + // the correct GUID. + private static void CheckBaseFolderGUID() + { + if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(RuntimeUtils.BaseFolderGUID))) + { + string folderPath = RuntimeUtils.PluginBasePathDefault; + + if (!Directory.Exists(folderPath)) + { + Debug.LogErrorFormat("FMOD: Couldn't find base folder by GUID ({0}) or path ({1})", + RuntimeUtils.BaseFolderGUID, RuntimeUtils.PluginBasePathDefault); + return; + } + + const string DialogTitle = "Update FMOD Folder Metadata"; + + bool update = EditorUtility.DisplayDialog(DialogTitle, + $"The metadata for the {folderPath} folder needs to be updated" + + " so that FMOD can locate required files.\n\n" + + "After this change you may move the FMOD folder to any location within your project.", + "Update Metadata", "Ignore"); + + while (update) + { + string error = ReplaceMetaFileGUID(folderPath, RuntimeUtils.BaseFolderGUID); + + if (error == null) + { + return; + } + + update = EditorUtility.DisplayDialog(DialogTitle, + $"Error updating metadata for {folderPath}:\n\n{error}\n\nDo you want to try again?", + "Try Again", "Ignore"); + } + } + } + + private static string ReplaceMetaFileGUID(string assetPath, string newGUID) + { + try + { + string filePath = $"{assetPath}.meta"; + + if (!AssetDatabase.MakeEditable(filePath)) + { + return $"Failed to open {filePath} for editing"; + } + + string[] lines = File.ReadAllLines(filePath); + + const string GuidPrefix = "guid:"; + bool guidReplaced = false; + + using (StreamWriter stream = File.CreateText(filePath)) + { + foreach (string line in lines) + { + if (!guidReplaced && line.StartsWith(GuidPrefix)) + { + guidReplaced = true; + stream.WriteLine($"{GuidPrefix} {newGUID}"); + } + else + { + stream.WriteLine(line); + } + } + } + + if (!guidReplaced) + { + return $"Couldn't find a line starting with '{GuidPrefix}' in {filePath}"; + } + + Debug.LogFormat("FMOD: Updated the GUID for {0} to {1}", assetPath, newGUID); + + AssetDatabase.ImportAsset(assetPath); + + return null; + } + catch (Exception e) + { + Debug.LogWarningFormat("FMOD: Failed to update the GUID for {0}: {1}", assetPath, e.Message); + + return e.Message; + } + } + + private static void CheckMacLibraries() + { + Platform platformMac = EditorSettings.Instance.GetPlatform(BuildTarget.StandaloneOSX); + + IEnumerable allLibraries = platformMac.GetBuildTargets() + .SelectMany(t => platformMac.GetBinaryAssetPaths(t, Platform.BinaryType.All)) + .Distinct(); + + List librariesToRepair = allLibraries.Where(path => { + string infoPlistPath = $"{path}/Contents/Info.plist"; + + if (File.Exists(infoPlistPath)) + { + string contents = File.ReadAllText(infoPlistPath); + + return contents.Contains("\r\n"); + } + + return false; + }) + .ToList(); + + if (!librariesToRepair.Any()) + { + return; + } + + librariesToRepair.Sort(); + + const string DialogTitle = "Repair FMOD Libraries"; + + bool repair = EditorUtility.DisplayDialog(DialogTitle, + "The following FMOD libraries contain incorrect line endings, and need to be repaired:\n\n" + + $"{string.Join("\n", librariesToRepair)}\n\n" + + "Do you want to repair them now?", "Repair", "Ignore"); + + while (repair) + { + try + { + RepairMacLibraries(librariesToRepair); + repair = false; + } + catch (Exception e) + { + repair = EditorUtility.DisplayDialog(DialogTitle, + $"Error repairing FMOD libraries:\n\n{e.Message}\n\nDo you want to try again?", + "Try Again", "Ignore"); + } + } + } + + private static void RepairMacLibraries(IEnumerable paths) + { + foreach (string path in paths) + { + string infoPlistPath = $"{path}/Contents/Info.plist"; + + if (!AssetDatabase.MakeEditable(infoPlistPath)) + { + throw new Exception($"Failed to open {infoPlistPath} for editing"); + } + + string contents = File.ReadAllText(infoPlistPath); + contents = contents.Replace("\r\n", "\n"); + + File.WriteAllText(infoPlistPath, contents); + + Debug.LogFormat("FMOD: Replaced CRLF line endings with LF in {0}", infoPlistPath); + } + } + + private static void CleanObsoleteFiles() + { + if (Environment.GetCommandLineArgs().Any(a => a == "-exportPackage")) + { + // Don't delete anything or it won't be included in the package + return; + } + if (EditorApplication.isPlayingOrWillChangePlaymode) + { + // Messing with the asset database while entering play mode causes a NullReferenceException + return; + } + + string obsoleteFolder = $"{RuntimeUtils.PluginBasePath}/obsolete"; + + if (AssetDatabase.IsValidFolder(obsoleteFolder)) + { + EditorApplication.LockReloadAssemblies(); + + string[] guids = AssetDatabase.FindAssets(string.Empty, new string[] { obsoleteFolder }); + foreach (string guid in guids) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + if (AssetDatabase.DeleteAsset(path)) + { + RuntimeUtils.DebugLogFormat("FMOD: Removed obsolete file {0}", path); + } + } + if(AssetDatabase.MoveAssetToTrash(obsoleteFolder)) + { + RuntimeUtils.DebugLogFormat("FMOD: Removed obsolete folder {0}", obsoleteFolder); + } + AssetDatabase.Refresh(); + EditorApplication.UnlockReloadAssemblies(); + } + } + + public static string WritableAssetPath(string cacheAssetName) + { + if (RuntimeUtils.PluginBasePath.StartsWith("Assets/")) + { + return $"{RuntimeUtils.PluginBasePath}/Cache/Editor/{cacheAssetName}.asset"; + } + else + { + return $"Assets/Plugins/FMOD/Cache/Editor/{cacheAssetName}.asset"; + } + } + } + + public class StagingSystem + { + private static string PlatformsFolder => $"{RuntimeUtils.PluginBasePath}/platforms"; + private static string StagingFolder => $"{RuntimeUtils.PluginBasePath}/staging"; + private const string AnyCPU = "AnyCPU"; + + private static readonly LibInfo[] LibrariesToUpdate = { + new LibInfo() {cpu = "x86", os = "Windows", lib = "fmodstudioL.dll", platform = "win", buildTarget = BuildTarget.StandaloneWindows}, + new LibInfo() {cpu = "x86_64", os = "Windows", lib = "fmodstudioL.dll", platform = "win", buildTarget = BuildTarget.StandaloneWindows64}, + new LibInfo() {cpu = "x86_64", os = "Linux", lib = "libfmodstudioL.so", platform = "linux", buildTarget = BuildTarget.StandaloneLinux64}, + new LibInfo() {cpu = AnyCPU, os = "OSX", lib = "fmodstudioL.bundle", platform = "mac", buildTarget = BuildTarget.StandaloneOSX}, + }; + + public static bool SourceLibsExist + { + get + { + return LibrariesToUpdate.Any((info) => + { + string sourcePath = GetSourcePath(info); + + if (sourcePath != null) + { + return AssetImporter.GetAtPath(sourcePath) as PluginImporter != null; + } + else + { + return false; + } + }); + } + } + + private struct LibInfo + { + public string cpu; + public string os; + public string lib; + public string platform; + public BuildTarget buildTarget; + }; + + private static string GetTargetPath(LibInfo libInfo) + { + foreach (Platform.FileLayout layout in Platform.OldFileLayouts) + { + string path = GetTargetPath(libInfo, layout); + + if (EditorUtils.AssetExists(path)) + { + return path; + } + } + + return null; + } + + private static string GetTargetPath(LibInfo libInfo, Platform.FileLayout layout) + { + switch (layout) + { + case Platform.FileLayout.Release_1_10: + return $"Assets/Plugins/{CPUAndLibPath(libInfo)}"; + case Platform.FileLayout.Release_2_0: + return $"Assets/Plugins/FMOD/lib/{libInfo.platform}/{CPUAndLibPath(libInfo)}"; + case Platform.FileLayout.Release_2_1: + case Platform.FileLayout.Release_2_2: + return $"{PlatformsFolder}/{libInfo.platform}/lib/{CPUAndLibPath(libInfo)}"; + default: + throw new ArgumentException("Unrecognised file layout: " + layout); + } + } + + private static string CPUAndLibPath(LibInfo libInfo) + { + return (libInfo.cpu == AnyCPU) ? libInfo.lib : $"{libInfo.cpu}/{libInfo.lib}"; + } + + private static string GetSourcePath(LibInfo libInfo) + { + return $"{StagingFolder}/{libInfo.platform}/lib/{CPUAndLibPath(libInfo)}"; + } + + public class UpdateStep + { + internal Settings.SharedLibraryUpdateStages Stage; + public string Name; + public string Description; + public string Details; + public Action Execute; + + public void CacheDetails() + { + Details = GetDetails(); + } + + private Func GetDetails; + + internal static UpdateStep Create(Settings.SharedLibraryUpdateStages stage, string name, string description, + Func details, Action execute) + { + return new UpdateStep() { + Stage = stage, + Name = name, + Description = description, + GetDetails = details, + Execute = execute, + }; + } + } + + public static readonly UpdateStep[] UpdateSteps = { + UpdateStep.Create( + stage: Settings.SharedLibraryUpdateStages.DisableExistingLibraries, + name: "Disable Existing Native Libraries", + description: "Disable the existing FMOD native libraries so that Unity will not load them " + + "at startup time.", + details: () => { + IEnumerable importers = + LibrariesToUpdate.Select(GetPluginImporter).Where(p => p != null); + + if (!importers.Any()) + { + return string.Empty; + } + + IEnumerable paths = importers.Select(p => $"\n* {p.assetPath}"); + + return $"This will disable these native libraries:{string.Join(string.Empty, paths)}"; + }, + execute: () => { + foreach (LibInfo libInfo in LibrariesToUpdate) + { + PluginImporter pluginImporter = GetPluginImporter(libInfo); + if (pluginImporter != null && pluginImporter.GetCompatibleWithEditor()) + { + pluginImporter.SetCompatibleWithEditor(false); + pluginImporter.SetCompatibleWithAnyPlatform(false); + EditorUtility.SetDirty(pluginImporter); + pluginImporter.SaveAndReimport(); + } + } + + Settings.Instance.SharedLibraryUpdateStage = Settings.SharedLibraryUpdateStages.RestartUnity; + Settings.Instance.SharedLibraryTimeSinceStart = EditorApplication.timeSinceStartup; + EditorUtility.SetDirty(Settings.Instance); + } + ), + + UpdateStep.Create( + stage: Settings.SharedLibraryUpdateStages.RestartUnity, + name: "Restart Unity", + description: "Restart Unity so that it releases its lock on the existing FMOD native libraries.", + details: () => { + return "This will restart Unity. You will be prompted to save your work if you have unsaved " + + "scene modifications."; + }, + execute: () => { + if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) + { + EditorApplication.OpenProject(Environment.CurrentDirectory); + } + } + ), + + UpdateStep.Create( + stage: Settings.SharedLibraryUpdateStages.CopyNewLibraries, + name: "Copy New Native Libraries", + description: "Copy the new FMOD native libraries to the correct location and enable them.", + details: () => { + List actions = new List(); + + foreach (LibInfo libInfo in LibrariesToUpdate) + { + string sourcePath = GetSourcePath(libInfo); + string targetPath = GetTargetPath(libInfo); + + if (EditorUtils.AssetExists(sourcePath)) + { + if (targetPath != null) + { + actions.Add($"Delete {targetPath}"); + } + + targetPath = GetTargetPath(libInfo, Platform.FileLayout.Latest); + + actions.Add($"Copy {sourcePath} to {targetPath}"); + } + + if (targetPath != null) + { + actions.Add($"Enable {targetPath}"); + } + } + + actions.Add($"Remove {StagingFolder}"); + + return $"This will do the following:\n* {string.Join("\n* ", actions)}"; + }, + execute: () => { + bool allCopiesSucceeded = true; + + foreach (LibInfo libInfo in LibrariesToUpdate) + { + string sourcePath = GetSourcePath(libInfo); + string targetPath = GetTargetPath(libInfo); + + if (EditorUtils.AssetExists(sourcePath)) + { + if (targetPath != null) + { + if (!AssetDatabase.DeleteAsset(targetPath)) + { + RuntimeUtils.DebugLogError(string.Format("FMOD: Could not delete {0}", targetPath)); + } + } + + targetPath = GetTargetPath(libInfo, Platform.FileLayout.Latest); + + EditorUtils.EnsureFolderExists(EditorUtils.GetParentFolder(targetPath)); + + if (!AssetDatabase.CopyAsset(sourcePath, targetPath)) + { + RuntimeUtils.DebugLogError(string.Format("FMOD: Could not copy {0} to {1}", sourcePath, targetPath)); + allCopiesSucceeded = false; + } + } + + PluginImporter pluginImporter = AssetImporter.GetAtPath(targetPath) as PluginImporter; + + if (pluginImporter != null) + { + pluginImporter.ClearSettings(); + pluginImporter.SetCompatibleWithEditor(true); + pluginImporter.SetCompatibleWithAnyPlatform(false); + pluginImporter.SetCompatibleWithPlatform(libInfo.buildTarget, true); + pluginImporter.SetEditorData("CPU", libInfo.cpu); + pluginImporter.SetEditorData("OS", libInfo.os); + EditorUtility.SetDirty(pluginImporter); + pluginImporter.SaveAndReimport(); + } + } + + if (allCopiesSucceeded) + { + if (AssetDatabase.MoveAssetToTrash(StagingFolder)) + { + RuntimeUtils.DebugLogFormat("FMOD: Removed staging folder {0}", StagingFolder); + } + else + { + RuntimeUtils.DebugLogError(string.Format("FMOD: Could not remove staging folder {0}", StagingFolder)); + } + } + + ResetUpdateStage(); + + // This is so that Unity finds the new libraries + EditorUtility.RequestScriptReload(); + } + ), + }; + + private static PluginImporter GetPluginImporter(LibInfo libInfo) + { + string targetPath = GetTargetPath(libInfo); + + if (targetPath != null) + { + return AssetImporter.GetAtPath(targetPath) as PluginImporter; + } + else + { + return null; + } + } + + private static UpdateStep FindUpdateStep(Settings.SharedLibraryUpdateStages stage) + { + return UpdateSteps.FirstOrDefault(s => s.Stage == stage); + } + + private static void ResetUpdateStage() + { + if (Settings.Instance.SharedLibraryUpdateStage != Settings.SharedLibraryUpdateStages.Start || + Settings.Instance.SharedLibraryTimeSinceStart != 0) + { + Settings.Instance.SharedLibraryUpdateStage = Settings.SharedLibraryUpdateStages.Start; + Settings.Instance.SharedLibraryTimeSinceStart = 0; + EditorUtility.SetDirty(Settings.Instance); + } + } + + public static UpdateStep Startup() + { + if (!AssetDatabase.IsValidFolder(StagingFolder)) + { + ResetUpdateStage(); + return null; + } + + if (Settings.Instance.SharedLibraryUpdateStage == Settings.SharedLibraryUpdateStages.Start) + { + bool targetLibsExist = LibrariesToUpdate.Any(info => GetPluginImporter(info) != null); + + if (targetLibsExist) + { + Settings.Instance.SharedLibraryUpdateStage = Settings.SharedLibraryUpdateStages.DisableExistingLibraries; + EditorUtility.SetDirty(Settings.Instance); + } + else + { + FindUpdateStep(Settings.SharedLibraryUpdateStages.CopyNewLibraries).Execute(); + + ResetUpdateStage(); + return null; + } + } + + if (Settings.Instance.SharedLibraryUpdateStage == Settings.SharedLibraryUpdateStages.RestartUnity + && EditorApplication.timeSinceStartup < Settings.Instance.SharedLibraryTimeSinceStart) + { + // Unity has been restarted + Settings.Instance.SharedLibraryUpdateStage = Settings.SharedLibraryUpdateStages.CopyNewLibraries; + EditorUtility.SetDirty(Settings.Instance); + } + + return GetNextUpdateStep(); + } + + public static UpdateStep GetNextUpdateStep() + { + UpdateStep step = FindUpdateStep(Settings.Instance.SharedLibraryUpdateStage); + + if (step != null) + { + step.CacheDetails(); + } + + return step; + } + } + + public abstract class HelpContent : PopupWindowContent + { + private GUIContent icon; + + protected abstract void Prepare(); + protected abstract Vector2 GetContentSize(); + protected abstract void DrawContent(); + + public override void OnOpen() + { + icon = EditorGUIUtility.IconContent("console.infoicon"); + + Prepare(); + } + + public override Vector2 GetWindowSize() + { + Vector2 contentSize = GetContentSize(); + + Vector2 iconSize = GUI.skin.label.CalcSize(icon); + + return new Vector2(contentSize.x + iconSize.x, + Math.Max(contentSize.y, iconSize.y) + EditorGUIUtility.standardVerticalSpacing); + } + + public override void OnGUI(Rect rect) + { + using (new GUILayout.HorizontalScope()) + { + using (new GUILayout.VerticalScope()) + { + GUILayout.Label(icon); + } + + using (new GUILayout.VerticalScope()) + { + DrawContent(); + } + } + } + } + + public class SimpleHelp : HelpContent + { + private GUIContent text; + private GUIStyle style; + private float textWidth; + + public SimpleHelp(string text, float textWidth = 300) + { + this.text = new GUIContent(text); + this.textWidth = textWidth; + } + + protected override void Prepare() + { + style = new GUIStyle(GUI.skin.label) { + richText = true, + wordWrap = true, + alignment = TextAnchor.MiddleLeft, + }; + } + + protected override Vector2 GetContentSize() + { + float textHeight = style.CalcHeight(text, textWidth) + style.margin.bottom; + + return new Vector2(textWidth, textHeight); + } + + protected override void DrawContent() + { + GUILayout.Label(text, style); + } + } + + public class BuildStatusWatcher + { + public static Action OnBuildStarted; + public static Action OnBuildEnded; + + private static bool buildInProgress = false; + + private static void SetBuildInProgress(bool inProgress) + { + if (inProgress != buildInProgress) + { + buildInProgress = inProgress; + + if (buildInProgress) + { + EditorApplication.update += PollBuildStatus; + + if (OnBuildStarted != null) + { + OnBuildStarted(); + } + } + else + { + EditorApplication.update -= PollBuildStatus; + + if (OnBuildEnded != null) + { + OnBuildEnded(); + } + } + } + } + + private static void PollBuildStatus() + { + SetBuildInProgress(BuildPipeline.isBuildingPlayer); + } + + private class BuildProcessor : IPreprocessBuildWithReport, IPostprocessBuildWithReport + { + public int callbackOrder { get { return 0; } } + + public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report) + { + SetBuildInProgress(true); + } + + public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report) + { + SetBuildInProgress(false); + } + } + + public static void Startup() + { +#if UNITY_SCRIPTABLEBUILDPIPELINE_EXIST + BuildCallbacks callbacks = ContentPipeline.BuildCallbacks; + + callbacks.PostDependencyCallback += (parameters, dependencyData) => { + SetBuildInProgress(true); + return ReturnCode.Success; + }; + + callbacks.PostWritingCallback += (parameters, dependencyData, writeData, results) => { + SetBuildInProgress(false); + return ReturnCode.Success; + }; +#endif + } + } + + public static class SerializedPropertyExtensions + { + public static bool ArrayContains(this SerializedProperty array, Func predicate) + { + return FindArrayIndex(array, predicate) >= 0; + } + + public static bool ArrayContains(this SerializedProperty array, string subPropertyName, + Func predicate) + { + return FindArrayIndex(array, subPropertyName, predicate) >= 0; + } + + public static int FindArrayIndex(this SerializedProperty array, Func predicate) + { + for (int i = 0; i < array.arraySize; ++i) + { + SerializedProperty current = array.GetArrayElementAtIndex(i); + + if (predicate(current)) + { + return i; + } + } + + return -1; + } + + public static int FindArrayIndex(this SerializedProperty array, string subPropertyName, + Func predicate) + { + for (int i = 0; i < array.arraySize; ++i) + { + SerializedProperty current = array.GetArrayElementAtIndex(i); + SerializedProperty subProperty = current.FindPropertyRelative(subPropertyName); + + if (predicate(subProperty)) + { + return i; + } + } + + return -1; + } + + public static void ArrayAdd(this SerializedProperty array, Action initialize) + { + array.InsertArrayElementAtIndex(array.arraySize); + initialize(array.GetArrayElementAtIndex(array.arraySize - 1)); + } + + public static void ArrayClear(this SerializedProperty array) + { + while (array.arraySize > 0) + { + array.DeleteArrayElementAtIndex(array.arraySize - 1); + } + } + + private static FMOD.GUID GetGuid(this SerializedProperty property) + { + return new FMOD.GUID() { + Data1 = property.FindPropertyRelative("Data1").intValue, + Data2 = property.FindPropertyRelative("Data2").intValue, + Data3 = property.FindPropertyRelative("Data3").intValue, + Data4 = property.FindPropertyRelative("Data4").intValue, + }; + } + + public static void SetGuid(this SerializedProperty property, FMOD.GUID guid) + { + property.FindPropertyRelative("Data1").intValue = guid.Data1; + property.FindPropertyRelative("Data2").intValue = guid.Data2; + property.FindPropertyRelative("Data3").intValue = guid.Data3; + property.FindPropertyRelative("Data4").intValue = guid.Data4; + } + + public static void SetEventReference(this SerializedProperty property, FMOD.GUID guid, string path) + { + SerializedProperty guidProperty = property.FindPropertyRelative("Guid"); + guidProperty.SetGuid(guid); + + SerializedProperty pathProperty = property.FindPropertyRelative("Path"); + pathProperty.stringValue = path; + } + + public static EventReference GetEventReference(this SerializedProperty property) + { + SerializedProperty pathProperty = property.FindPropertyRelative("Path"); + SerializedProperty guidProperty = property.FindPropertyRelative("Guid"); + + return new EventReference() { + Path = pathProperty.stringValue, + Guid = guidProperty.GetGuid(), + }; + } + } + + public class NoIndentScope : IDisposable + { + private int oldIndentLevel; + + public NoIndentScope() + { + oldIndentLevel = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + } + + public void Dispose() + { + EditorGUI.indentLevel = oldIndentLevel; + } + } + + public class NaturalComparer : IComparer + { + public int Compare(string a, string b) + { + return EditorUtility.NaturalCompare(a, b); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs.meta b/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs.meta new file mode 100644 index 0000000..9463687 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EditorUtils.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2bb4068641d1f71478f95a9b73533f51 +timeCreated: 1432608272 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs b/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs new file mode 100644 index 0000000..5972e66 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs @@ -0,0 +1,1772 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; +using System.IO; + +namespace FMODUnity +{ + public class EventBrowser : EditorWindow, ISerializationCallbackReceiver + { + [SerializeField] + private bool isStandaloneWindow; + + [NonSerialized] + private float nextRepaintTime; + + [NonSerialized] + private float[] cachedMetering; + + private const float RepaintInterval = 1 / 30.0f; + + private Texture2D borderIcon; + private GUIStyle borderStyle; + + [NonSerialized] + private TreeView treeView; + + [NonSerialized] + private SearchField searchField; + + [SerializeField] + private PreviewArea previewArea = new PreviewArea(); + + [SerializeField] + private TreeView.State treeViewState; + + [NonSerialized] + private DateTime LastKnownCacheTime; + + private SerializedProperty outputProperty; + + public static FMOD.Studio.EventInstance PreviewEventInstance { get; private set; } + + [MenuItem("FMOD/Event Browser", priority = 2)] + public static void ShowWindow() + { + EventBrowser eventBrowser = GetWindow("FMOD Events"); + eventBrowser.minSize = new Vector2(380, 600); + + eventBrowser.BeginStandaloneWindow(); + + EditorUtils.LoadPreviewBanks(); + } + + public static bool IsOpen + { + get; private set; + } + + public void OnBeforeSerialize() + { + treeViewState = treeView.state; + } + + public void OnAfterDeserialize() + { + } + + private void Update() + { + bool forceRepaint = false; + + float[] currentMetering = EditorUtils.GetMetering(); + if (cachedMetering == null || !cachedMetering.SequenceEqual(currentMetering)) + { + cachedMetering = currentMetering; + forceRepaint = true; + } + + if (LastKnownCacheTime != EventManager.CacheTime) + { + ReadEventCache(); + forceRepaint = true; + } + + if (forceRepaint || (previewArea != null && previewArea.forceRepaint && nextRepaintTime < Time.realtimeSinceStartup)) + { + Repaint(); + nextRepaintTime = Time.time + RepaintInterval; + } + } + + private void ReadEventCache() + { + LastKnownCacheTime = EventManager.CacheTime; + treeView.Reload(); + } + + private class TreeView : UnityEditor.IMGUI.Controls.TreeView + { + private static readonly Texture2D folderOpenIcon = EditorUtils.LoadImage("FolderIconOpen.png"); + private static readonly Texture2D folderClosedIcon = EditorUtils.LoadImage("FolderIconClosed.png"); + private static readonly Texture2D eventIcon = EditorUtils.LoadImage("EventIcon.png"); + private static readonly Texture2D snapshotIcon = EditorUtils.LoadImage("SnapshotIcon.png"); + private static readonly Texture2D bankIcon = EditorUtils.LoadImage("BankIcon.png"); + private static readonly Texture2D continuousParameterIcon = EditorUtils.LoadImage("ContinuousParameterIcon.png"); + private static readonly Texture2D discreteParameterIcon = EditorUtils.LoadImage("DiscreteParameterIcon.png"); + private static readonly Texture2D labeledParameterIcon = EditorUtils.LoadImage("LabeledParameterIcon.png"); + + private Dictionary itemIDs = new Dictionary(); + + private const string EventPrefix = "event:/"; + private const string SnapshotPrefix = "snapshot:/"; + private const string BankPrefix = "bank:/"; + private const string ParameterPrefix = "parameter:/"; + + bool expandNextFolderSet = false; + string nextFramedItemPath; + private string[] searchStringSplit; + + IList noSearchExpandState; + + float oldBaseIndent; + + public TreeView(State state) : base(state.baseState) + { + noSearchExpandState = state.noSearchExpandState; + SelectedObject = state.selectedObject; + TypeFilter = state.typeFilter; + DragEnabled = state.dragEnabled; + + for (int i = 0; i < state.itemPaths.Count; ++i) + { + itemIDs.Add(state.itemPaths[i], state.itemIDs[i]); + } + } + + public void JumpToEvent(string path) + { + JumpToItem(path); + } + + public void JumpToBank(string name) + { + JumpToItem(BankPrefix + name); + } + + private void JumpToItem(string path) + { + nextFramedItemPath = path; + Reload(); + + int itemID; + if (itemIDs.TryGetValue(path, out itemID)) + { + SetSelection(new List { itemID }, + TreeViewSelectionOptions.RevealAndFrame | TreeViewSelectionOptions.FireSelectionChanged); + } + else + { + SetSelection(new List()); + } + } + + private class LeafItem : TreeViewItem + { + public LeafItem(int id, int depth, ScriptableObject data) + : base(id, depth) + { + Data = data; + } + + public ScriptableObject Data; + } + + private class FolderItem : TreeViewItem + { + public FolderItem(int id, int depth, string displayName) + : base(id, depth, displayName) + { + } + } + + private FolderItem CreateFolderItem(string name, string path, bool hasChildren, bool forceExpanded, + TreeViewItem parent) + { + FolderItem item = new FolderItem(AffirmItemID("folder:" + path), 0, name); + + bool expanded; + + if (!hasChildren) + { + expanded = false; + } + else if (forceExpanded || expandNextFolderSet + || (nextFramedItemPath != null && nextFramedItemPath.StartsWith(path))) + { + SetExpanded(item.id, true); + expanded = true; + } + else + { + expanded = IsExpanded(item.id); + } + + if (expanded) + { + item.icon = folderOpenIcon; + } + else + { + item.icon = folderClosedIcon; + + if (hasChildren) + { + item.children = CreateChildListForCollapsedParent(); + } + } + + parent.AddChild(item); + + return item; + } + + protected override TreeViewItem BuildRoot() + { + return new TreeViewItem(-1, -1); + } + + private int AffirmItemID(string path) + { + int id; + + if (!itemIDs.TryGetValue(path, out id)) + { + id = itemIDs.Count; + itemIDs.Add(path, id); + } + + return id; + } + + public TypeFilter TypeFilter { get; set; } + public bool DragEnabled { get; set; } + + protected override IList BuildRows(TreeViewItem root) + { + if (hasSearch) + { + searchStringSplit = searchString.Split(' '); + } + + if (rootItem.children != null) + { + rootItem.children.Clear(); + } + + if ((TypeFilter & TypeFilter.Event) != 0) + { + CreateSubTree("Events", EventPrefix, + EventManager.Events.Where(e => e.Path.StartsWith(EventPrefix)), e => e.Path); + + CreateSubTree("Snapshots", SnapshotPrefix, + EventManager.Events.Where(e => e.Path.StartsWith(SnapshotPrefix)), s => s.Path); + } + + if ((TypeFilter & TypeFilter.Bank) != 0) + { + CreateSubTree("Banks", BankPrefix, EventManager.Banks, b => b.StudioPath); + } + + if ((TypeFilter & TypeFilter.Parameter) != 0) + { + CreateSubTree("Global Parameters", ParameterPrefix, + EventManager.Parameters, p => p.StudioPath); + } + + List rows = new List(); + + AddChildrenInOrder(rows, rootItem); + + SetupDepthsFromParentsAndChildren(rootItem); + + expandNextFolderSet = false; + nextFramedItemPath = null; + + return rows; + } + + private static NaturalComparer naturalComparer = new NaturalComparer(); + + private void CreateSubTree(string rootName, string rootPath, + IEnumerable sourceRecords, Func GetPath, + Func MakeUniquePath = null) + where T : ScriptableObject + { + var records = sourceRecords.Select(r => new { source = r, path = GetPath(r) }); + + if (hasSearch) + { + records = records.Where(r => { + foreach (var word in searchStringSplit) + { + if (word.Length > 0 && r.path.IndexOf(word, StringComparison.OrdinalIgnoreCase) < 0) + { + return false; + } + } + return true; + }); + } + + records = records.OrderBy(r => r.path, naturalComparer); + + TreeViewItem root = + CreateFolderItem(rootName, rootPath, records.Any(), TypeFilter != TypeFilter.All, rootItem); + + List currentFolderItems = new List(); + + foreach (var record in records) + { + string leafName; + TreeViewItem parent = CreateFolderItems(record.path, currentFolderItems, root, out leafName); + + if (parent != null) + { + string uniquePath; + + if (MakeUniquePath != null) + { + uniquePath = MakeUniquePath(record.path, record.source); + } + else + { + uniquePath = record.path; + } + + TreeViewItem leafItem = new LeafItem(AffirmItemID(uniquePath), 0, record.source); + leafItem.displayName = leafName; + leafItem.icon = IconForRecord(record.source); + + parent.AddChild(leafItem); + } + } + } + + private Texture2D IconForRecord(ScriptableObject record) + { + EditorEventRef eventRef = record as EditorEventRef; + if (eventRef != null) + { + if (eventRef.Path.StartsWith(SnapshotPrefix)) + { + return snapshotIcon; + } + else + { + return eventIcon; + } + } + + EditorBankRef bankRef = record as EditorBankRef; + if (bankRef != null) + { + return bankIcon; + } + + EditorParamRef paramRef = record as EditorParamRef; + if (paramRef != null) + { + switch(paramRef.Type) + { + case ParameterType.Continuous: + return continuousParameterIcon; + case ParameterType.Discrete: + return discreteParameterIcon; + case ParameterType.Labeled: + return labeledParameterIcon; + } + } + + return null; + } + + private TreeViewItem CreateFolderItems(string path, List currentFolderItems, + TreeViewItem root, out string leafName) + { + TreeViewItem parent = root; + + char separator = '/'; + + // Skip the type prefix at the start of the path + int elementStart = path.IndexOf(separator) + 1; + + for (int i = 0; ; ++i) + { + if (!IsExpanded(parent.id)) + { + leafName = null; + return null; + } + + int elementEnd = path.IndexOf(separator, elementStart); + + if (elementEnd < 0) + { + // No more folders; elementStart points to the event name + break; + } + + string folderName = path.Substring(elementStart, elementEnd - elementStart); + + if (i < currentFolderItems.Count && folderName != currentFolderItems[i].displayName) + { + currentFolderItems.RemoveRange(i, currentFolderItems.Count - i); + } + + if (i == currentFolderItems.Count) + { + FolderItem folderItem = + CreateFolderItem(folderName, path.Substring(0, elementEnd), true, false, parent); + + currentFolderItems.Add(folderItem); + } + + elementStart = elementEnd + 1; + parent = currentFolderItems[i]; + } + + leafName = path.Substring(elementStart); + return parent; + } + + private static void AddChildrenInOrder(List list, TreeViewItem item) + { + if (item.children != null) + { + foreach (TreeViewItem child in item.children.Where(child => child is FolderItem)) + { + list.Add(child); + + AddChildrenInOrder(list, child); + } + + foreach (TreeViewItem child in item.children.Where(child => !(child == null || child is FolderItem))) + { + list.Add(child); + } + } + } + + protected override bool CanMultiSelect(TreeViewItem item) + { + return false; + } + + protected override bool CanChangeExpandedState(TreeViewItem item) + { + return item.hasChildren; + } + + protected override bool CanStartDrag(CanStartDragArgs args) + { + if (DragEnabled && args.draggedItem is LeafItem) + { + return IsDraggable((args.draggedItem as LeafItem).Data); + } + else + { + return false; + } + } + + protected override void SetupDragAndDrop(SetupDragAndDropArgs args) + { + IList items = FindRows(args.draggedItemIDs); + + if (items[0] is LeafItem) + { + LeafItem item = items[0] as LeafItem; + + DragAndDrop.PrepareStartDrag(); + DragAndDrop.objectReferences = new UnityEngine.Object[] { Instantiate(item.Data) }; + + string title = string.Empty; + + if (item.Data is EditorEventRef) + { + title = "New FMOD Studio Emitter"; + } + else if (item.Data is EditorBankRef) + { + title = "New FMOD Studio Bank Loader"; + } + else if (item.Data is EditorParamRef) + { + title = "New FMOD Studio Global Parameter Trigger"; + } + + DragAndDrop.StartDrag(title); + } + } + + protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args) + { + return DragAndDropVisualMode.None; + } + + protected override void SearchChanged(string newSearch) + { + if (!string.IsNullOrEmpty(newSearch.Trim())) + { + expandNextFolderSet = true; + + if (noSearchExpandState == null) + { + // A new search is beginning + noSearchExpandState = GetExpanded(); + SetExpanded(new List()); + } + } + else + { + if (noSearchExpandState != null) + { + // A search is ending + SetExpanded(noSearchExpandState); + noSearchExpandState = null; + } + } + } + + public ScriptableObject SelectedObject { get; private set; } + public ScriptableObject DoubleClickedObject { get; private set; } + + protected override void SelectionChanged(IList selectedIDs) + { + SelectedObject = null; + + if (selectedIDs.Count > 0) + { + TreeViewItem item = FindItem(selectedIDs[0], rootItem); + + if (item is LeafItem) + { + SelectedObject = (item as LeafItem).Data; + } + } + } + + protected override void DoubleClickedItem(int id) + { + TreeViewItem item = FindItem(id, rootItem); + + if (item is LeafItem) + { + DoubleClickedObject = (item as LeafItem).Data; + } + } + + protected override void BeforeRowsGUI() + { + oldBaseIndent = baseIndent; + DoubleClickedObject = null; + } + + protected override void RowGUI(RowGUIArgs args) + { + if (hasSearch) + { + // Hack to undo TreeView flattening the hierarchy when searching + baseIndent = oldBaseIndent + args.item.depth * depthIndentWidth; + } + + base.RowGUI(args); + + TreeViewItem item = args.item; + + if (Event.current.type == EventType.MouseUp && item is FolderItem && item.hasChildren) + { + Rect rect = args.rowRect; + rect.xMin = GetContentIndent(item); + + if (rect.Contains(Event.current.mousePosition)) + { + SetExpanded(item.id, !IsExpanded(item.id)); + Event.current.Use(); + } + } + } + + protected override void AfterRowsGUI() + { + baseIndent = oldBaseIndent; + } + + [Serializable] + public class State + { + public TreeViewState baseState; + public List noSearchExpandState; + public ScriptableObject selectedObject; + public List itemPaths = new List(); + public List itemIDs = new List(); + public TypeFilter typeFilter = TypeFilter.All; + public bool dragEnabled = true; + + public State() : this(new TreeViewState()) + { + } + + public State(TreeViewState baseState) + { + this.baseState = baseState; + } + } + + new public State state + { + get + { + State result = new State(base.state); + + if (noSearchExpandState != null) + { + result.noSearchExpandState = new List(noSearchExpandState); + } + + result.selectedObject = SelectedObject; + + foreach (var entry in itemIDs) + { + result.itemPaths.Add(entry.Key); + result.itemIDs.Add(entry.Value); + } + + result.typeFilter = TypeFilter; + result.dragEnabled = true; + + return result; + } + } + } + + private void AffirmResources() + { + if (borderIcon == null) + { + borderIcon = EditorUtils.LoadImage("Border.png"); + + borderStyle = new GUIStyle(GUI.skin.box); + borderStyle.normal.background = borderIcon; + borderStyle.margin = new RectOffset(); + } + } + + private bool InChooserMode { get { return outputProperty != null; } } + + private void OnGUI() + { + AffirmResources(); + + if (InChooserMode) + { + GUILayout.BeginVertical(borderStyle, GUILayout.ExpandWidth(true)); + } + + treeView.searchString = searchField.OnGUI(treeView.searchString); + + Rect treeRect = GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); + treeRect.y += 2; + treeRect.height -= 2; + + treeView.OnGUI(treeRect); + + if (InChooserMode) + { + GUILayout.EndVertical(); + HandleChooserModeEvents(); + } + else + { + previewArea.treeView = treeView; + previewArea.OnGUI(position.width, cachedMetering != null ? cachedMetering : EditorUtils.GetMetering()); + } + } + + private void HandleChooserModeEvents() + { + if (Event.current.isKey) + { + KeyCode keyCode = Event.current.keyCode; + + if ((keyCode == KeyCode.Return || keyCode == KeyCode.KeypadEnter) && treeView.SelectedObject != null) + { + SetOutputProperty(treeView.SelectedObject); + Event.current.Use(); + Close(); + } + else if (keyCode == KeyCode.Escape) + { + Event.current.Use(); + Close(); + } + } + else if (treeView.DoubleClickedObject != null) + { + SetOutputProperty(treeView.DoubleClickedObject); + Close(); + } + } + + private void SetOutputProperty(ScriptableObject data) + { + if (data is EditorEventRef) + { + EditorEventRef eventRef = data as EditorEventRef; + + outputProperty.SetEventReference(eventRef.Guid, eventRef.Path); + + EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, eventRef.Path); + } + else if (data is EditorBankRef) + { + outputProperty.stringValue = (data as EditorBankRef).Name; + } + else if (data is EditorParamRef) + { + outputProperty.stringValue = (data as EditorParamRef).Name; + } + + outputProperty.serializedObject.ApplyModifiedProperties(); + } + + [Serializable] + private class PreviewArea + { + [NonSerialized] + public TreeView treeView; + + [NonSerialized] + private EditorEventRef currentEvent; + + [SerializeField] + private DetailsView detailsView = new DetailsView(); + + [SerializeField] + private TransportControls transportControls = new TransportControls(); + + [SerializeField] + private Event3DPreview event3DPreview = new Event3DPreview(); + + [SerializeField] + private PreviewMeters meters = new PreviewMeters(); + + [SerializeField] + private EventParameterControls parameterControls = new EventParameterControls(); + + private GUIStyle mainStyle; + + private bool isNarrow; + + public bool forceRepaint { get { return transportControls.forceRepaint; } } + + private void SetEvent(EditorEventRef eventRef) + { + if (eventRef != currentEvent) + { + currentEvent = eventRef; + + EditorUtils.PreviewStop(PreviewEventInstance); + transportControls.Reset(); + event3DPreview.Reset(); + parameterControls.Reset(); + } + } + + private void AffirmResources() + { + if (mainStyle == null) + { + mainStyle = new GUIStyle(GUI.skin.box); + mainStyle.margin = new RectOffset(); + } + } + + public void OnGUI(float width, float[] metering) + { + isNarrow = width < 600; + + AffirmResources(); + + ScriptableObject selectedObject = treeView.SelectedObject; + + if (selectedObject is EditorEventRef) + { + SetEvent(selectedObject as EditorEventRef); + } + else + { + SetEvent(null); + } + + if (selectedObject != null) + { + GUILayout.BeginVertical(mainStyle, GUILayout.ExpandWidth(true)); + + if (selectedObject is EditorEventRef) + { + EditorEventRef eventRef = selectedObject as EditorEventRef; + + if (eventRef.Path.StartsWith("event:")) + { + DrawEventPreview(eventRef, metering); + } + else if (eventRef.Path.StartsWith("snapshot:")) + { + detailsView.DrawSnapshot(eventRef); + } + } + else if (selectedObject is EditorBankRef) + { + detailsView.DrawBank(selectedObject as EditorBankRef); + } + else if (selectedObject is EditorParamRef) + { + detailsView.DrawParameter(selectedObject as EditorParamRef); + } + + GUILayout.EndVertical(); + } + } + + private void DrawSeparatorLine() + { + GUILayout.Box(GUIContent.none, GUILayout.Height(1), GUILayout.ExpandWidth(true)); + } + + private void DrawEventPreview(EditorEventRef eventRef, float[] metering) + { + detailsView.DrawEvent(eventRef, isNarrow); + + DrawSeparatorLine(); + + // Playback controls, 3D Preview and meters + EditorGUILayout.BeginHorizontal(GUILayout.Height(event3DPreview.Height)); + GUILayout.FlexibleSpace(); + + EditorGUILayout.BeginVertical(); + + if (!isNarrow) + { + GUILayout.FlexibleSpace(); + } + + transportControls.OnGUI(eventRef, parameterControls.ParameterValues); + + if (isNarrow) + { + EditorGUILayout.Separator(); + meters.OnGUI(true, metering); + } + else + { + GUILayout.FlexibleSpace(); + } + + EditorGUILayout.EndVertical(); + + event3DPreview.OnGUI(eventRef); + + if (!isNarrow) + { + meters.OnGUI(false, metering); + } + + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); + + DrawSeparatorLine(); + + parameterControls.OnGUI(eventRef); + } + } + + [Serializable] + private class DetailsView + { + private Texture copyIcon; + private GUIStyle textFieldNameStyle; + + private void AffirmResources() + { + if (copyIcon == null) + { + copyIcon = EditorUtils.LoadImage("CopyIcon.png"); + + textFieldNameStyle = new GUIStyle(EditorStyles.label); + textFieldNameStyle.fontStyle = FontStyle.Bold; + } + } + + public void DrawEvent(EditorEventRef selectedEvent, bool isNarrow) + { + AffirmResources(); + + DrawCopyableTextField("Full Path", selectedEvent.Path); + + DrawTextField("Banks", string.Join(", ", selectedEvent.Banks.Select(x => x.Name).ToArray())); + + EditorGUILayout.BeginHorizontal(); + DrawTextField("Panning", selectedEvent.Is3D ? "3D" : "2D"); + DrawTextField("Oneshot", selectedEvent.IsOneShot.ToString()); + + TimeSpan t = TimeSpan.FromMilliseconds(selectedEvent.Length); + DrawTextField("Length", selectedEvent.Length > 0 ? string.Format("{0:D2}:{1:D2}:{2:D3}", t.Minutes, t.Seconds, t.Milliseconds) : "N/A"); + + if (!isNarrow) DrawTextField("Streaming", selectedEvent.IsStream.ToString()); + EditorGUILayout.EndHorizontal(); + if (isNarrow) DrawTextField("Streaming", selectedEvent.IsStream.ToString()); + } + + public void DrawSnapshot(EditorEventRef eventRef) + { + AffirmResources(); + + DrawCopyableTextField("Full Path", eventRef.Path); + } + + public void DrawBank(EditorBankRef bank) + { + AffirmResources(); + + DrawCopyableTextField("Full Path", "bank:/" + bank.Name); + + string[] SizeSuffix = { "B", "KB", "MB", "GB" }; + + GUILayout.Label("Platform Bank Sizes", textFieldNameStyle); + + EditorGUI.indentLevel++; + + foreach (var sizeInfo in bank.FileSizes) + { + int order = 0; + long size = sizeInfo.Value; + + while (size >= 1024 && order + 1 < SizeSuffix.Length) + { + order++; + size /= 1024; + } + + EditorGUILayout.LabelField(sizeInfo.Name, string.Format("{0} {1}", size, SizeSuffix[order])); + } + + EditorGUI.indentLevel--; + } + + public void DrawParameter(EditorParamRef parameter) + { + AffirmResources(); + + DrawCopyableTextField("Name", parameter.Name); + DrawCopyableTextField("ID", + string.Format("{{ data1 = 0x{0:x8}, data2 = 0x{1:x8} }}", parameter.ID.data1, parameter.ID.data2)); + DrawTextField("Minimum", parameter.Min.ToString()); + DrawTextField("Maximum", parameter.Max.ToString()); + } + + private void DrawCopyableTextField(string name, string value) + { + EditorGUILayout.BeginHorizontal(); + DrawTextField(name, value); + if (GUILayout.Button(copyIcon, GUILayout.ExpandWidth(false))) + { + EditorGUIUtility.systemCopyBuffer = value; + } + EditorGUILayout.EndHorizontal(); + } + + private void DrawTextField(string name, string content) + { + EditorGUILayout.BeginHorizontal(); + + GUILayout.Label(name, textFieldNameStyle, GUILayout.Width(75)); + GUILayout.Label(content); + + EditorGUILayout.EndHorizontal(); + } + } + + [Serializable] + private class TransportControls + { + private Texture playOff; + private Texture playOn; + private Texture stopOff; + private Texture stopOn; + private Texture openIcon; + private GUIStyle buttonStyle; + + public bool forceRepaint { get; private set; } + + public void Reset() + { + forceRepaint = false; + } + + private void AffirmResources() + { + if (playOff == null) + { + playOff = EditorUtils.LoadImage("TransportPlayButtonOff.png"); + playOn = EditorUtils.LoadImage("TransportPlayButtonOn.png"); + stopOff = EditorUtils.LoadImage("TransportStopButtonOff.png"); + stopOn = EditorUtils.LoadImage("TransportStopButtonOn.png"); + openIcon = EditorUtils.LoadImage("transportOpen.png"); + + buttonStyle = new GUIStyle(); + buttonStyle.padding.left = 4; + buttonStyle.padding.top = 10; + } + } + + public void OnGUI(EditorEventRef selectedEvent, Dictionary parameterValues) + { + AffirmResources(); + + FMOD.Studio.PLAYBACK_STATE previewState = FMOD.Studio.PLAYBACK_STATE.STOPPED; + bool paused = false; + + if (PreviewEventInstance.isValid()) + { + PreviewEventInstance.getPlaybackState(out previewState); + PreviewEventInstance.getPaused(out paused); + } + + bool playing = previewState == FMOD.Studio.PLAYBACK_STATE.PLAYING; + bool stopped = previewState == FMOD.Studio.PLAYBACK_STATE.STOPPED; + + EditorGUILayout.BeginHorizontal(); + + if (GUILayout.Button(stopped || paused ? stopOn : stopOff, buttonStyle, GUILayout.ExpandWidth(false))) + { + forceRepaint = false; + + if (paused) + { + EditorUtils.PreviewStop(PreviewEventInstance); + PreviewEventInstance.release(); + PreviewEventInstance.clearHandle(); + } + if (playing) + { + EditorUtils.PreviewPause(PreviewEventInstance); + } + } + if (GUILayout.Button(playing ? playOn : playOff, buttonStyle, GUILayout.ExpandWidth(false))) + { + if (paused) + { + EditorUtils.PreviewPause(PreviewEventInstance); + } + else + { + if (PreviewEventInstance.isValid()) + { + EditorUtils.PreviewStop(PreviewEventInstance); + } + PreviewEventInstance = EditorUtils.PreviewEvent(selectedEvent, parameterValues); + } + + forceRepaint = true; + } + if (GUILayout.Button(new GUIContent(openIcon, "Show Event in FMOD Studio"), buttonStyle, GUILayout.ExpandWidth(false))) + { + string cmd = string.Format("studio.window.navigateTo(studio.project.lookup(\"{0}\"))", selectedEvent.Guid); + EditorUtils.SendScriptCommand(cmd); + } + + EditorGUILayout.EndHorizontal(); + } + } + + [Serializable] + private class Event3DPreview + { + private bool isDragging; + private Rect arenaRect; + + private Vector2 eventPosition; + private float eventDistance = 0; + private float eventOrientation = 0; + + private Texture arena; + private Texture emitter; + + public void Reset() + { + eventPosition = new Vector2(0, 0); + eventDistance = 0; + eventOrientation = 0; + } + + private void AffirmResources() + { + if (arena == null) + { + arena = EditorUtils.LoadImage("Preview.png"); + emitter = EditorUtils.LoadImage("PreviewEmitter.png"); + } + } + + public float Height + { + get + { + AffirmResources(); + return GUI.skin.label.CalcSize(new GUIContent(arena)).y; + } + } + + public void OnGUI(EditorEventRef selectedEvent) + { + AffirmResources(); + + var originalColour = GUI.color; + if (!selectedEvent.Is3D) + { + GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.1f); + } + + GUILayout.Label(arena, GUILayout.ExpandWidth(false)); + + if (Event.current.type == EventType.Repaint) + { + arenaRect = GUILayoutUtility.GetLastRect(); + } + + Vector2 center = arenaRect.center; + Rect rect2 = new Rect(center.x + eventPosition.x - 6, center.y + eventPosition.y - 6, 12, 12); + GUI.DrawTexture(rect2, emitter); + + GUI.color = originalColour; + + if (selectedEvent.Is3D) + { + bool useGUIEvent = false; + + switch (Event.current.type) + { + case EventType.MouseDown: + if (arenaRect.Contains(Event.current.mousePosition)) + { + isDragging = true; + useGUIEvent = true; + } + break; + case EventType.MouseUp: + if (isDragging) + { + isDragging = false; + useGUIEvent = true; + } + break; + case EventType.MouseDrag: + if (isDragging) + { + useGUIEvent = true; + } + break; + } + + if (useGUIEvent) + { + Vector2 newPosition = Event.current.mousePosition; + Vector2 delta = newPosition - center; + + float maximumDistance = (arena.width - emitter.width) / 2; + float distance = Math.Min(delta.magnitude, maximumDistance); + + delta.Normalize(); + eventPosition = delta * distance; + eventDistance = distance / maximumDistance * selectedEvent.MaxDistance; + + float angle = Mathf.Atan2(delta.y, delta.x); + eventOrientation = angle + Mathf.PI * 0.5f; + + Event.current.Use(); + } + } + + if (PreviewEventInstance.isValid()) + { + // Listener at origin + FMOD.ATTRIBUTES_3D pos = new FMOD.ATTRIBUTES_3D(); + pos.position.x = (float)Math.Sin(eventOrientation) * eventDistance; + pos.position.y = (float)Math.Cos(eventOrientation) * eventDistance; + pos.forward.x = 1.0f; + pos.up.z = 1.0f; + PreviewEventInstance.set3DAttributes(pos); + } + } + } + + [Serializable] + private class EventParameterControls + { + [NonSerialized] + private Dictionary parameterValues = new Dictionary(); + + [NonSerialized] + private Vector2 scrollPosition; + + [NonSerialized] + private bool showGlobalParameters; + + public Dictionary ParameterValues { get { return parameterValues; } } + + public void Reset() + { + parameterValues.Clear(); + } + + public void OnGUI(EditorEventRef selectedEvent) + { + scrollPosition = GUILayout.BeginScrollView(scrollPosition, + GUILayout.Height(EditorGUIUtility.singleLineHeight * 7f)); + + foreach (EditorParamRef paramRef in selectedEvent.LocalParameters) + { + if (!parameterValues.ContainsKey(paramRef.Name)) + { + parameterValues[paramRef.Name] = paramRef.Default; + } + + CreateParamRefSlider(paramRef); + } + + showGlobalParameters = selectedEvent.GlobalParameters.Count > 0 && + EditorGUI.Foldout(EditorGUILayout.GetControlRect(), showGlobalParameters, "Global Parameters"); + + foreach (EditorParamRef paramRef in selectedEvent.GlobalParameters) + { + if (!parameterValues.ContainsKey(paramRef.Name)) + { + parameterValues[paramRef.Name] = paramRef.Default; + } + + if (showGlobalParameters) + { + CreateParamRefSlider(paramRef, true); + } + } + + GUILayout.EndScrollView(); + } + + public void CreateParamRefSlider(EditorParamRef paramRef, bool isGlobal = false) + { + if (paramRef.Type == ParameterType.Labeled) + { + parameterValues[paramRef.Name] = EditorGUILayout.IntPopup( + paramRef.Name, (int)parameterValues[paramRef.Name], paramRef.Labels, null); + } + else if (paramRef.Type == ParameterType.Discrete) + { + parameterValues[paramRef.Name] = EditorGUILayout.IntSlider( + paramRef.Name, (int)parameterValues[paramRef.Name], (int)paramRef.Min, (int)paramRef.Max); + } + else + { + parameterValues[paramRef.Name] = EditorGUILayout.Slider( + paramRef.Name, parameterValues[paramRef.Name], paramRef.Min, paramRef.Max); + } + + if (isGlobal) + { + EditorUtils.System.setParameterByID(paramRef.ID, parameterValues[paramRef.Name]); + } + else + { + if (PreviewEventInstance.isValid()) + { + PreviewEventInstance.setParameterByID(paramRef.ID, parameterValues[paramRef.Name]); + } + } + } + } + + [Serializable] + private class PreviewMeters + { + private Texture meterOn; + private Texture meterOff; + + private void AffirmResources() + { + if (meterOn == null) + { + meterOn = EditorUtils.LoadImage("LevelMeter.png"); + meterOff = EditorUtils.LoadImage("LevelMeterOff.png"); + } + } + + public void OnGUI(bool minimized, float[] metering) + { + AffirmResources(); + + int meterHeight = minimized ? 86 : 128; + int meterWidth = (int)((128 / (float)meterOff.height) * meterOff.width); + + List meterPositions = meterPositionsForSpeakerMode(speakerModeForChannelCount(metering.Length), meterWidth, 2, 6); + + const int MeterCountMaximum = 16; + + int minimumWidth = meterWidth * MeterCountMaximum; + + Rect fullRect = GUILayoutUtility.GetRect(minimumWidth, meterHeight, + GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); + + float baseX = fullRect.x + (fullRect.width - (meterWidth * metering.Length)) / 2; + + for(int i = 0; i < metering.Length; i++) + { + Rect meterRect = new Rect(baseX + meterPositions[i], fullRect.y, meterWidth, fullRect.height); + + GUI.DrawTexture(meterRect, meterOff); + + float db = 20.0f * Mathf.Log10(metering[i] * Mathf.Sqrt(2.0f)); + db = Mathf.Clamp(db, -80.0f, 10.0f); + float visible = 0; + int[] segmentPixels = new int[] { 0, 18, 38, 60, 89, 130, 187, 244, 300 }; + float[] segmentDB = new float[] { -80.0f, -60.0f, -50.0f, -40.0f, -30.0f, -20.0f, -10.0f, 0, 10.0f }; + int segment = 1; + while (segmentDB[segment] < db) + { + segment++; + } + visible = segmentPixels[segment - 1] + ((db - segmentDB[segment - 1]) / (segmentDB[segment] - segmentDB[segment - 1])) * (segmentPixels[segment] - segmentPixels[segment - 1]); + + visible *= fullRect.height / (float)meterOff.height; + + Rect levelPosRect = new Rect(meterRect.x, fullRect.height - visible + meterRect.y, meterWidth, visible); + Rect levelUVRect = new Rect(0, 0, 1.0f, visible / fullRect.height); + GUI.DrawTextureWithTexCoords(levelPosRect, meterOn, levelUVRect); + } + } + + private FMOD.SPEAKERMODE speakerModeForChannelCount(int channelCount) + { + switch(channelCount) + { + case 1: + return FMOD.SPEAKERMODE.MONO; + case 4: + return FMOD.SPEAKERMODE.QUAD; + case 5: + return FMOD.SPEAKERMODE.SURROUND; + case 6: + return FMOD.SPEAKERMODE._5POINT1; + case 8: + return FMOD.SPEAKERMODE._7POINT1; + case 12: + return FMOD.SPEAKERMODE._7POINT1POINT4; + default: + return FMOD.SPEAKERMODE.STEREO; + } + } + + private List meterPositionsForSpeakerMode(FMOD.SPEAKERMODE mode, float meterWidth, float groupGap, float lfeGap) + { + List offsets = new List(); + + switch(mode) + { + case FMOD.SPEAKERMODE.MONO: // M + offsets.Add(0); + break; + + case FMOD.SPEAKERMODE.STEREO: // L R + offsets.Add(0); + offsets.Add(meterWidth); + break; + + case FMOD.SPEAKERMODE.QUAD: + switch(Settings.Instance.MeterChannelOrdering) + { + case MeterChannelOrderingType.Standard: + case MeterChannelOrderingType.SeparateLFE: // L R | LS RS + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // LS + offsets.Add(meterWidth*3 + groupGap); // RS + break; + case MeterChannelOrderingType.Positional: // LS | L R | RS + offsets.Add(meterWidth*1 + groupGap); // L + offsets.Add(meterWidth*2 + groupGap); // R + offsets.Add(0); // LS + offsets.Add(meterWidth*3 + groupGap*2); // RS + break; + } + break; + + case FMOD.SPEAKERMODE.SURROUND: + switch(Settings.Instance.MeterChannelOrdering) + { + case MeterChannelOrderingType.Standard: + case MeterChannelOrderingType.SeparateLFE: // L R | C | LS RS + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*3 + groupGap*2); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + break; + case MeterChannelOrderingType.Positional: // LS | L C R | RS + offsets.Add(meterWidth*1 + groupGap); // L + offsets.Add(meterWidth*3 + groupGap); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(0); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + break; + } + break; + + case FMOD.SPEAKERMODE._5POINT1: + switch(Settings.Instance.MeterChannelOrdering) + { + case MeterChannelOrderingType.Standard: // L R | C | LFE | LS RS + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*3 + groupGap*2); // LFE + offsets.Add(meterWidth*4 + groupGap*3); // LS + offsets.Add(meterWidth*5 + groupGap*3); // RS + break; + case MeterChannelOrderingType.SeparateLFE: // L R | C | LS RS || LFE + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*5 + groupGap*2 + lfeGap); // LFE + offsets.Add(meterWidth*3 + groupGap*2); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + break; + case MeterChannelOrderingType.Positional: // LS | L C R | RS || LFE + offsets.Add(meterWidth*1 + groupGap); // L + offsets.Add(meterWidth*3 + groupGap); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*5 + groupGap*2 + lfeGap); // LFE + offsets.Add(0); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + break; + } + break; + + case FMOD.SPEAKERMODE._7POINT1: + switch(Settings.Instance.MeterChannelOrdering) + { + case MeterChannelOrderingType.Standard: // L R | C | LFE | LS RS | LSR RSR + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*3 + groupGap*2); // LFE + offsets.Add(meterWidth*4 + groupGap*3); // LS + offsets.Add(meterWidth*5 + groupGap*3); // RS + offsets.Add(meterWidth*6 + groupGap*4); // LSR + offsets.Add(meterWidth*7 + groupGap*4); // RSR + break; + case MeterChannelOrderingType.SeparateLFE: // L R | C | LS RS | LSR RSR || LFE + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*7 + groupGap*3 + lfeGap); // LFE + offsets.Add(meterWidth*3 + groupGap*2); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + offsets.Add(meterWidth*5 + groupGap*3); // LSR + offsets.Add(meterWidth*6 + groupGap*3); // RSR + break; + case MeterChannelOrderingType.Positional: // LSR LS | L C R | RS RSR || LFE + offsets.Add(meterWidth*2 + groupGap); // L + offsets.Add(meterWidth*4 + groupGap); // R + offsets.Add(meterWidth*3 + groupGap); // C + offsets.Add(meterWidth*7 + groupGap*2 + lfeGap); // LFE + offsets.Add(meterWidth*1); // LS + offsets.Add(meterWidth*5 + groupGap*2); // RS + offsets.Add(0); // LSR + offsets.Add(meterWidth*6 + groupGap*2); // RSR + break; + } + break; + + case FMOD.SPEAKERMODE._7POINT1POINT4: + switch(Settings.Instance.MeterChannelOrdering) + { + case MeterChannelOrderingType.Standard: // L R | C | LFE | LS RS | LSR RSR | TFL TFR TBL TBR + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*3 + groupGap*2); // LFE + offsets.Add(meterWidth*4 + groupGap*3); // LS + offsets.Add(meterWidth*5 + groupGap*3); // RS + offsets.Add(meterWidth*6 + groupGap*4); // LSR + offsets.Add(meterWidth*7 + groupGap*4); // RSR + offsets.Add(meterWidth*8 + groupGap*5); // TFL + offsets.Add(meterWidth*9 + groupGap*5); // TFR + offsets.Add(meterWidth*10 + groupGap*5); // TBL + offsets.Add(meterWidth*11 + groupGap*5); // TBR + break; + case MeterChannelOrderingType.SeparateLFE: // L R | C | LS RS | LSR RSR | TFL TFR TBL TBR || LFE + offsets.Add(0); // L + offsets.Add(meterWidth*1); // R + offsets.Add(meterWidth*2 + groupGap); // C + offsets.Add(meterWidth*11 + groupGap*4 + lfeGap); // LFE + offsets.Add(meterWidth*3 + groupGap*2); // LS + offsets.Add(meterWidth*4 + groupGap*2); // RS + offsets.Add(meterWidth*5 + groupGap*3); // LSR + offsets.Add(meterWidth*6 + groupGap*3); // RSR + offsets.Add(meterWidth*7 + groupGap*4); // TFL + offsets.Add(meterWidth*8 + groupGap*4); // TFR + offsets.Add(meterWidth*9 + groupGap*4); // TBL + offsets.Add(meterWidth*10 + groupGap*4); // TBR + break; + case MeterChannelOrderingType.Positional: // LSR LS | L C R | RS RSR | TBL TFL TFR TBR || LFE + offsets.Add(meterWidth*2 + groupGap); // L + offsets.Add(meterWidth*4 + groupGap); // R + offsets.Add(meterWidth*3 + groupGap); // C + offsets.Add(meterWidth*11 + groupGap*3 + lfeGap); // LFE + offsets.Add(meterWidth*1); // LS + offsets.Add(meterWidth*5 + groupGap*2); // RS + offsets.Add(0); // LSR + offsets.Add(meterWidth*6 + groupGap*2); // RSR + offsets.Add(meterWidth*8 + groupGap*3); // TFL + offsets.Add(meterWidth*9 + groupGap*3); // TFR + offsets.Add(meterWidth*7 + groupGap*3); // TBL + offsets.Add(meterWidth*10 + groupGap*3); // TBR + break; + } + break; + } + + return offsets; + } + } + + [Flags] + private enum TypeFilter + { + Event = 1, + Bank = 2, + Parameter = 4, + All = Event | Bank | Parameter, + } + + public void ChooseEvent(SerializedProperty property) + { + BeginInspectorPopup(property, TypeFilter.Event); + + SerializedProperty pathProperty = property.FindPropertyRelative("Path"); + + if (!string.IsNullOrEmpty(pathProperty.stringValue)) + { + treeView.JumpToEvent(pathProperty.stringValue); + } + } + + public void ChooseBank(SerializedProperty property) + { + BeginInspectorPopup(property, TypeFilter.Bank); + + if (!string.IsNullOrEmpty(property.stringValue)) + { + treeView.JumpToBank(property.stringValue); + } + } + + public void ChooseParameter(SerializedProperty property) + { + BeginInspectorPopup(property, TypeFilter.Parameter); + } + + public void FrameEvent(string path) + { + treeView.JumpToEvent(path); + } + + private void BeginInspectorPopup(SerializedProperty property, TypeFilter typeFilter) + { + treeView.TypeFilter = typeFilter; + outputProperty = property; + searchField.SetFocus(); + treeView.DragEnabled = false; + ReadEventCache(); + } + + private void BeginStandaloneWindow() + { + treeView.TypeFilter = TypeFilter.All; + outputProperty = null; + searchField.SetFocus(); + treeView.DragEnabled = true; + isStandaloneWindow = true; + } + + public void OnEnable() + { + if (treeViewState == null) + { + treeViewState = new TreeView.State(); + } + + searchField = new SearchField(); + treeView = new TreeView(treeViewState); + + ReadEventCache(); + + searchField.downOrUpArrowKeyPressed += treeView.SetFocus; + + SceneView.duringSceneGui += SceneUpdate; + + EditorApplication.hierarchyWindowItemOnGUI += HierarchyUpdate; + + if (isStandaloneWindow) + { + EditorUtils.LoadPreviewBanks(); + } + + IsOpen = true; + } + + public void OnDestroy() + { + if (PreviewEventInstance.isValid()) + { + EditorUtils.PreviewStop(PreviewEventInstance); + PreviewEventInstance.clearHandle(); + } + + if (isStandaloneWindow) + { + EditorUtils.UnloadPreviewBanks(); + } + + IsOpen = false; + } + + private static bool IsDraggable(UnityEngine.Object data) + { + return data is EditorEventRef || data is EditorBankRef || data is EditorParamRef; + } + + public static bool IsDroppable(UnityEngine.Object[] data) + { + return data.Length > 0 && IsDraggable(data[0]); + } + + // This is an event handler on the hierachy view to handle dragging our objects from the browser + private void HierarchyUpdate(int instance, Rect rect) + { + if (Event.current.type == EventType.DragPerform && rect.Contains(Event.current.mousePosition)) + { + if (IsDroppable(DragAndDrop.objectReferences)) + { + UnityEngine.Object data = DragAndDrop.objectReferences[0]; + + GameObject target = EditorUtility.InstanceIDToObject(instance) as GameObject; + + if (data is EditorEventRef) + { + Undo.SetCurrentGroupName("Add Studio Event Emitter"); + + StudioEventEmitter emitter = Undo.AddComponent(target); + + EditorEventRef eventRef = data as EditorEventRef; + emitter.EventReference.Path = eventRef.Path; + emitter.EventReference.Guid = eventRef.Guid; + } + else if (data is EditorBankRef) + { + Undo.SetCurrentGroupName("Add Studio Bank Loader"); + + StudioBankLoader loader = Undo.AddComponent(target); + loader.Banks = new List(); + loader.Banks.Add((data as EditorBankRef).Name); + } + else // data is EditorParamRef + { + Undo.SetCurrentGroupName("Add Studio Global Parameter Trigger"); + + StudioGlobalParameterTrigger trigger = Undo.AddComponent(target); + trigger.Parameter = (data as EditorParamRef).Name; + } + + Selection.activeObject = target; + + Event.current.Use(); + } + } + } + + // This is an event handler on the scene view to handle dragging our objects from the browser + // and creating new gameobjects + private void SceneUpdate(SceneView sceneView) + { + if (Event.current.type == EventType.DragPerform && IsDroppable(DragAndDrop.objectReferences)) + { + UnityEngine.Object data = DragAndDrop.objectReferences[0]; + GameObject newObject; + + if (data is EditorEventRef) + { + EditorEventRef eventRef = data as EditorEventRef; + + string path = eventRef.Path; + + string name = path.Substring(path.LastIndexOf("/") + 1); + newObject = new GameObject(name + " Emitter"); + + StudioEventEmitter emitter = newObject.AddComponent(); + emitter.EventReference.Path = path; + emitter.EventReference.Guid = eventRef.Guid; + + Undo.RegisterCreatedObjectUndo(newObject, "Create Studio Event Emitter"); + } + else if (data is EditorBankRef) + { + newObject = new GameObject("Studio Bank Loader"); + + StudioBankLoader loader = newObject.AddComponent(); + loader.Banks = new List(); + loader.Banks.Add((data as EditorBankRef).Name); + + Undo.RegisterCreatedObjectUndo(newObject, "Create Studio Bank Loader"); + } + else // data is EditorParamRef + { + string name = (data as EditorParamRef).Name; + + newObject = new GameObject(name + " Trigger"); + + StudioGlobalParameterTrigger trigger = newObject.AddComponent(); + trigger.Parameter = name; + + Undo.RegisterCreatedObjectUndo(newObject, "Create Studio Global Parameter Trigger"); + } + + Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); + object hit = HandleUtility.RaySnap(ray); + + if (hit != null) + { + newObject.transform.position = ((RaycastHit)hit).point; + } + else + { + newObject.transform.position = ray.origin + ray.direction * 10.0f; + } + + Selection.activeObject = newObject; + Event.current.Use(); + } + else if (Event.current.type == EventType.DragUpdated && IsDroppable(DragAndDrop.objectReferences)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Move; + DragAndDrop.AcceptDrag(); + Event.current.Use(); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs.meta b/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs.meta new file mode 100644 index 0000000..d79c574 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventBrowser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5332ad2baabb58844975479e906001c8 +timeCreated: 1432613753 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EventCache.cs b/Assets/Plugins/FMOD/src/Editor/EventCache.cs new file mode 100644 index 0000000..79e6c14 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventCache.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace FMODUnity +{ + public class EventCache : ScriptableObject + { + [SerializeField] + public List EditorBanks; + [SerializeField] + public List EditorEvents; + [SerializeField] + public List EditorParameters; + [SerializeField] + public List MasterBanks; + [SerializeField] + public List StringsBanks; + [SerializeField] + private Int64 cacheTime; + [SerializeField] + public int cacheVersion; + + public DateTime CacheTime + { + get { return new DateTime(cacheTime); } + set { cacheTime = value.Ticks; } + } + + public EventCache() + { + EditorBanks = new List(); + EditorEvents = new List(); + EditorParameters = new List(); + MasterBanks = new List(); + StringsBanks = new List(); + cacheTime = 0; + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EventCache.cs.meta b/Assets/Plugins/FMOD/src/Editor/EventCache.cs.meta new file mode 100644 index 0000000..f1c0245 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventCache.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d32cf7c32a3ed8347bac48ef5ed56d82 +timeCreated: 1432775088 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EventManager.cs b/Assets/Plugins/FMOD/src/Editor/EventManager.cs new file mode 100644 index 0000000..d8d8c57 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventManager.cs @@ -0,0 +1,1364 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor.Build; +using System.Reflection; +using UnityEditor.Build.Reporting; +using UnityEngine.SceneManagement; + +namespace FMODUnity +{ + [InitializeOnLoad] + public class EventManager : MonoBehaviour + { + private const string FMODLabel = "FMOD"; + + private const string AssetsFolderName = "Assets"; + + private const string CacheAssetName = "FMODStudioCache"; + public static string CacheAssetFullName = EditorUtils.WritableAssetPath(CacheAssetName); + private static EventCache eventCache; + + private const string StringBankExtension = "strings.bank"; + private const string BankExtension = "bank"; + +#if UNITY_EDITOR + [MenuItem("FMOD/Refresh Banks", priority = 1)] + public static void RefreshBanks() + { + string result = UpdateCache(); + + if (eventCache != null) + { + OnCacheChange(); + if (Settings.Instance.ImportType == ImportType.AssetBundle) + { + UpdateBankStubAssets(EditorUserBuildSettings.activeBuildTarget); + } + } + + BankRefresher.HandleBankRefresh(result); + } +#endif + + private static void ClearCache() + { + eventCache.CacheTime = DateTime.MinValue; + eventCache.EditorBanks.Clear(); + eventCache.EditorEvents.Clear(); + eventCache.EditorParameters.Clear(); + eventCache.StringsBanks.Clear(); + eventCache.MasterBanks.Clear(); + if (Settings.Instance && Settings.Instance.BanksToLoad != null) + Settings.Instance.BanksToLoad.Clear(); + } + + private static void AffirmEventCache() + { + if (eventCache == null) + { + UpdateCache(); + } + } + + private static string UpdateCache() + { + if (eventCache == null) + { + eventCache = AssetDatabase.LoadAssetAtPath(CacheAssetFullName, typeof(EventCache)) as EventCache; + + // If new libraries need to be staged, or the staging process is in progress, clear the cache and exit. + if (StagingSystem.SourceLibsExist) + { + if (eventCache != null) + { + ClearCache(); + } + return null; + } + + if (eventCache == null || eventCache.cacheVersion != FMOD.VERSION.number) + { + RuntimeUtils.DebugLog("FMOD: Event cache is missing or in an old format; creating a new instance."); + + eventCache = ScriptableObject.CreateInstance(); + eventCache.cacheVersion = FMOD.VERSION.number; + + Directory.CreateDirectory(Path.GetDirectoryName(CacheAssetFullName)); + AssetDatabase.CreateAsset(eventCache, CacheAssetFullName); + } + } + + var settings = Settings.Instance; + var editorSettings = EditorSettings.Instance; + + if (string.IsNullOrEmpty(settings.SourceBankPath)) + { + ClearCache(); + return null; + } + + string defaultBankFolder = null; + + if (!settings.HasPlatforms) + { + defaultBankFolder = settings.SourceBankPath; + } + else + { + Platform platform = editorSettings.CurrentEditorPlatform; + + if (platform == settings.DefaultPlatform) + { + platform = settings.PlayInEditorPlatform; + } + + defaultBankFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(settings.SourceBankPath, platform.BuildDirectory)); + } + + string[] bankPlatforms = EditorUtils.GetBankPlatforms(); + string[] bankFolders = new string[bankPlatforms.Length]; + for (int i = 0; i < bankPlatforms.Length; i++) + { + bankFolders[i] = RuntimeUtils.GetCommonPlatformPath(Path.Combine(settings.SourceBankPath, bankPlatforms[i])); + } + + // Get all banks and set cache time to most recent write time + List bankFileNames = new List(Directory.GetFiles(defaultBankFolder, "*.bank", SearchOption.AllDirectories)); + DateTime lastWriteTime = bankFileNames.Max(fileName => File.GetLastWriteTime(fileName)); + + // Exit early if cache is up to date + if (lastWriteTime == eventCache.CacheTime) + { + return null; + } + + eventCache.CacheTime = lastWriteTime; + + // Remove string banks from list + bankFileNames.RemoveAll(x => x.Contains(".strings")); + + List stringBanks = new List(0); + try + { + var files = Directory.GetFiles(defaultBankFolder, "*." + StringBankExtension, SearchOption.AllDirectories); + stringBanks = new List(files); + } + catch + { + } + + // Strip out OSX resource-fork files that appear on FAT32 + stringBanks.RemoveAll((x) => Path.GetFileName(x).StartsWith("._")); + + if (stringBanks.Count == 0) + { + ClearCache(); + return string.Format("Directory {0} doesn't contain any banks.\nBuild the banks in Studio or check the path in the settings.", defaultBankFolder); + } + + // Stop editor preview so no stale data being held + EditorUtils.StopAllPreviews(); + + bool reloadPreviewBanks = EditorUtils.PreviewBanksLoaded; + if (reloadPreviewBanks) + { + EditorUtils.UnloadPreviewBanks(); + } + + List reducedStringBanksList = new List(); + HashSet stringBankGuids = new HashSet(); + + foreach (string stringBankPath in stringBanks) + { + FMOD.Studio.Bank stringBank; + EditorUtils.CheckResult(EditorUtils.System.loadBankFile(stringBankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out stringBank)); + + if (!stringBank.isValid()) + { + return string.Format("{0} is not a valid bank.", stringBankPath); + } + else + { + // Unload the strings bank + stringBank.unload(); + } + + FMOD.GUID stringBankGuid; + EditorUtils.CheckResult(stringBank.getID(out stringBankGuid)); + + if (!stringBankGuids.Add(stringBankGuid)) + { + // If we encounter multiple string banks with the same GUID then only use the first. This handles the scenario where + // a Studio project is cloned and extended for DLC with a new master bank name. + continue; + } + + reducedStringBanksList.Add(stringBankPath); + } + + stringBanks = reducedStringBanksList; + + // Reload the strings banks + List loadedStringsBanks = new List(); + + bool eventRenameOccurred = false; + + try + { + AssetDatabase.StartAssetEditing(); + + eventCache.EditorBanks.ForEach((x) => x.Exists = false); + HashSet masterBankFileNames = new HashSet(); + + foreach (string stringBankPath in stringBanks) + { + FMOD.Studio.Bank stringBank; + EditorUtils.CheckResult(EditorUtils.System.loadBankFile(stringBankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out stringBank)); + + if (!stringBank.isValid()) + { + ClearCache(); + return string.Format("{0} is not a valid bank.", stringBankPath); + } + + loadedStringsBanks.Add(stringBank); + + FileInfo stringBankFileInfo = new FileInfo(stringBankPath); + + string masterBankFileName = Path.GetFileName(stringBankPath).Replace(StringBankExtension, BankExtension); + masterBankFileNames.Add(masterBankFileName); + + EditorBankRef stringsBankRef = eventCache.StringsBanks.Find(x => RuntimeUtils.GetCommonPlatformPath(stringBankPath) == x.Path); + + if (stringsBankRef == null) + { + stringsBankRef = ScriptableObject.CreateInstance(); + stringsBankRef.FileSizes = new List(); + AssetDatabase.AddObjectToAsset(stringsBankRef, eventCache); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(stringsBankRef)); + eventCache.EditorBanks.Add(stringsBankRef); + eventCache.StringsBanks.Add(stringsBankRef); + } + + stringsBankRef.SetPath(stringBankPath, defaultBankFolder); + string studioPath; + stringBank.getPath(out studioPath); + stringsBankRef.SetStudioPath(studioPath); + stringsBankRef.LastModified = stringBankFileInfo.LastWriteTime; + stringsBankRef.Exists = true; + stringsBankRef.FileSizes.Clear(); + + if (Settings.Instance.HasPlatforms) + { + for (int i = 0; i < bankPlatforms.Length; i++) + { + stringsBankRef.FileSizes.Add(new EditorBankRef.NameValuePair(bankPlatforms[i], stringBankFileInfo.Length)); + } + } + else + { + stringsBankRef.FileSizes.Add(new EditorBankRef.NameValuePair("", stringBankFileInfo.Length)); + } + } + + eventCache.EditorParameters.ForEach((x) => x.Exists = false); + + foreach (string bankFileName in bankFileNames) + { + EditorBankRef bankRef = eventCache.EditorBanks.Find((x) => RuntimeUtils.GetCommonPlatformPath(bankFileName) == x.Path); + + // New bank we've never seen before + if (bankRef == null) + { + bankRef = ScriptableObject.CreateInstance(); + AssetDatabase.AddObjectToAsset(bankRef, eventCache); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(bankRef)); + + bankRef.SetPath(bankFileName, defaultBankFolder); + bankRef.LastModified = DateTime.MinValue; + bankRef.FileSizes = new List(); + + eventCache.EditorBanks.Add(bankRef); + } + + bankRef.Exists = true; + + FileInfo bankFileInfo = new FileInfo(bankFileName); + + // Update events from this bank if it has been modified, + // or it is a master bank (so that we get any global parameters) + if (bankRef.LastModified != bankFileInfo.LastWriteTime + || masterBankFileNames.Contains(Path.GetFileName(bankFileName))) + { + bankRef.LastModified = bankFileInfo.LastWriteTime; + UpdateCacheBank(bankRef, ref eventRenameOccurred); + } + + // Update file sizes + bankRef.FileSizes.Clear(); + if (Settings.Instance.HasPlatforms) + { + for (int i = 0; i < bankPlatforms.Length; i++) + { + string platformBankPath = RuntimeUtils.GetCommonPlatformPath(bankFolders[i] + bankFileName.Replace(defaultBankFolder, "")); + var fileInfo = new FileInfo(platformBankPath); + if (fileInfo.Exists) + { + bankRef.FileSizes.Add(new EditorBankRef.NameValuePair(bankPlatforms[i], fileInfo.Length)); + } + } + } + else + { + string platformBankPath = RuntimeUtils.GetCommonPlatformPath(Path.Combine(Settings.Instance.SourceBankPath, bankFileName)); + var fileInfo = new FileInfo(platformBankPath); + if (fileInfo.Exists) + { + bankRef.FileSizes.Add(new EditorBankRef.NameValuePair("", fileInfo.Length)); + } + } + + if (masterBankFileNames.Contains(bankFileInfo.Name)) + { + if (!eventCache.MasterBanks.Exists(x => RuntimeUtils.GetCommonPlatformPath(bankFileName) == x.Path)) + { + eventCache.MasterBanks.Add(bankRef); + } + } + } + + // Remove any stale entries from bank, event and parameter lists + eventCache.EditorBanks.FindAll((bankRef) => !bankRef.Exists).ForEach((bankRef) => + { + eventCache.EditorEvents.ForEach((eventRef) => eventRef.Banks.Remove(bankRef)); + DestroyImmediate(bankRef, true); + }); + eventCache.EditorBanks.RemoveAll((x) => x == null); + eventCache.MasterBanks.RemoveAll((x) => x == null); + eventCache.StringsBanks.RemoveAll((x) => x == null); + + eventCache.EditorEvents.FindAll((eventRef) => eventRef.Banks.Count == 0).ForEach((eventRef) => + { + eventRef.Parameters.ForEach((paramRef) => DestroyImmediate(paramRef, true)); + DestroyImmediate(eventRef, true); + }); + eventCache.EditorEvents.RemoveAll((x) => x == null); + + eventCache.EditorParameters.FindAll((paramRef) => !paramRef.Exists).ForEach((paramRef) => + { + DestroyImmediate(paramRef, true); + }); + eventCache.EditorParameters.RemoveAll((x) => x == null); + + AssetDatabase.SaveAssets(); + } + finally + { + // Unload the strings banks + loadedStringsBanks.ForEach(x => x.unload()); + AssetDatabase.StopAssetEditing(); + + if (reloadPreviewBanks) + { + EditorUtils.LoadPreviewBanks(); + } + + RuntimeUtils.DebugLog("FMOD: Cache updated."); + } + + if (eventRenameOccurred) + { + EditorApplication.delayCall += ShowEventsRenamedDialog; + } + + return null; + } + + private static void ShowEventsRenamedDialog() + { + bool runUpdater = EditorUtility.DisplayDialog("Events Renamed", + string.Format("Some events have been renamed in FMOD Studio. Do you want to run {0} " + + "to find and update any references to them?", EventReferenceUpdater.MenuPath), "Yes", "No"); + + if (runUpdater) + { + EventReferenceUpdater.ShowWindow(); + } + } + + private static void UpdateCacheBank(EditorBankRef bankRef, ref bool renameOccurred) + { + // Clear out any cached events from this bank + eventCache.EditorEvents.ForEach((x) => x.Banks.Remove(bankRef)); + + FMOD.Studio.Bank bank; + FMOD.RESULT loadResult = EditorUtils.System.loadBankFile(bankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank); + + if (loadResult == FMOD.RESULT.OK) + { + // Get studio path + string studioPath; + bank.getPath(out studioPath); + bankRef.SetStudioPath(studioPath); + + // Iterate all events in the bank and cache them + FMOD.Studio.EventDescription[] eventList; + var result = bank.getEventList(out eventList); + if (result == FMOD.RESULT.OK) + { + foreach (var eventDesc in eventList) + { + string path; + result = eventDesc.getPath(out path); + + FMOD.GUID guid; + eventDesc.getID(out guid); + + EditorEventRef eventRef = eventCache.EditorEvents.Find((x) => x.Path == path); + if (eventRef == null) + { + eventRef = ScriptableObject.CreateInstance(); + AssetDatabase.AddObjectToAsset(eventRef, eventCache); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(eventRef)); + eventRef.Banks = new List(); + eventCache.EditorEvents.Add(eventRef); + eventRef.Parameters = new List(); + + if (!renameOccurred) + { + EditorEventRef eventRefByGuid = eventCache.EditorEvents.Find((x) => x.Guid == guid); + + if (eventRefByGuid != null) + { + renameOccurred = true; + } + } + } + else if (eventRef.Guid != guid) + { + renameOccurred = true; + } + + eventRef.Banks.Add(bankRef); + eventRef.Guid = guid; + eventRef.Path = eventRef.name = path; + eventDesc.is3D(out eventRef.Is3D); + eventDesc.isOneshot(out eventRef.IsOneShot); + eventDesc.isStream(out eventRef.IsStream); + eventDesc.getMinMaxDistance(out eventRef.MinDistance, out eventRef.MaxDistance); + eventDesc.getLength(out eventRef.Length); + int paramCount = 0; + eventDesc.getParameterDescriptionCount(out paramCount); + eventRef.Parameters.ForEach((x) => x.Exists = false); + for (int paramIndex = 0; paramIndex < paramCount; paramIndex++) + { + FMOD.Studio.PARAMETER_DESCRIPTION param; + eventDesc.getParameterDescriptionByIndex(paramIndex, out param); + // Skip if readonly and not global + if ((param.flags & FMOD.Studio.PARAMETER_FLAGS.READONLY) != 0 && (param.flags & FMOD.Studio.PARAMETER_FLAGS.GLOBAL) == 0) + { + continue; + } + EditorParamRef paramRef = eventRef.Parameters.Find((x) => x.ID.Equals(param.id)); + if (paramRef == null) + { + paramRef = ScriptableObject.CreateInstance(); + AssetDatabase.AddObjectToAsset(paramRef, eventCache); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(paramRef)); + eventRef.Parameters.Add(paramRef); + } + + InitializeParamRef(paramRef, param, (labelIndex) => { + string label; + eventDesc.getParameterLabelByIndex(paramIndex, labelIndex, out label); + return label; + }); + + paramRef.name = "parameter:/" + Path.GetFileName(path) + "/" + paramRef.Name; + paramRef.Exists = true; + } + eventRef.Parameters.FindAll((x) => !x.Exists).ForEach((x) => DestroyImmediate(x, true)); + eventRef.Parameters.RemoveAll((x) => x == null); + } + } + + // Update global parameter list for each bank + FMOD.Studio.PARAMETER_DESCRIPTION[] parameterDescriptions; + result = EditorUtils.System.getParameterDescriptionList(out parameterDescriptions); + if (result == FMOD.RESULT.OK) + { + for (int i = 0; i < parameterDescriptions.Length; i++) + { + FMOD.Studio.PARAMETER_DESCRIPTION param = parameterDescriptions[i]; + if ((param.flags & FMOD.Studio.PARAMETER_FLAGS.GLOBAL) == FMOD.Studio.PARAMETER_FLAGS.GLOBAL) + { + EditorParamRef paramRef = eventCache.EditorParameters.Find((x) => x.ID.Equals(param.id)); + if (paramRef == null) + { + paramRef = ScriptableObject.CreateInstance(); + AssetDatabase.AddObjectToAsset(paramRef, eventCache); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(paramRef)); + eventCache.EditorParameters.Add(paramRef); + } + + InitializeParamRef(paramRef, param, (index) => { + string label; + EditorUtils.System.getParameterLabelByID(param.id, index, out label); + return label; + }); + + paramRef.name = "parameter:/" + param.name; + EditorUtils.System.lookupPath(param.guid, out paramRef.StudioPath); + paramRef.Exists = true; + } + } + } + bank.unload(); + } + else + { + RuntimeUtils.DebugLogError(string.Format("FMOD Studio: Unable to load {0}: {1}", bankRef.Name, FMOD.Error.String(loadResult))); + eventCache.CacheTime = DateTime.MinValue; + } + } + + private static void InitializeParamRef(EditorParamRef paramRef, FMOD.Studio.PARAMETER_DESCRIPTION description, + Func getLabel) + { + paramRef.Name = description.name; + paramRef.Min = description.minimum; + paramRef.Max = description.maximum; + paramRef.Default = description.defaultvalue; + paramRef.ID = description.id; + paramRef.IsGlobal = (description.flags & FMOD.Studio.PARAMETER_FLAGS.GLOBAL) != 0; + + if ((description.flags & FMOD.Studio.PARAMETER_FLAGS.LABELED) != 0) + { + paramRef.Type = ParameterType.Labeled; + paramRef.Labels = GetParameterLabels(description, getLabel); + } + else if ((description.flags & FMOD.Studio.PARAMETER_FLAGS.DISCRETE) != 0) + { + paramRef.Type = ParameterType.Discrete; + } + else + { + paramRef.Type = ParameterType.Continuous; + } + } + + private static string[] GetParameterLabels(FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription, + Func getLabel) + { + string[] labels = new string[(int)parameterDescription.maximum + 1]; + + for (int i = 0; i <= parameterDescription.maximum; ++i) + { + labels[i] = getLabel(i); + } + + return labels; + } + + static EventManager() + { + BuildStatusWatcher.OnBuildStarted += () => { + BuildTargetChanged(); + CopyToStreamingAssets(EditorUserBuildSettings.activeBuildTarget); + }; + BuildStatusWatcher.OnBuildEnded += () => { + UpdateBankStubAssets(EditorUserBuildSettings.activeBuildTarget); + }; + } + + public static void Startup() + { + EventReference.GuidLookupDelegate = (path) => { + EditorEventRef editorEventRef = EventFromPath(path); + + return (editorEventRef != null) ? editorEventRef.Guid : new FMOD.GUID(); + }; + + // Avoid throwing exceptions so we don't stop other startup code from running + try + { + RefreshBanks(); + } + catch (Exception e) + { + RuntimeUtils.DebugLogException(e); + } + } + + public static void ValidateEventReferences(Scene scene) + { + foreach (GameObject gameObject in scene.GetRootGameObjects()) + { + MonoBehaviour[] behaviours = gameObject.GetComponentsInChildren(true); + + foreach (MonoBehaviour behaviour in behaviours) + { + if (behaviour != null) + { + if (behaviour is StudioEventEmitter) + { + ValidateEventEmitter(behaviour as StudioEventEmitter, scene); + } + else + { + ValidateEventReferenceFields(behaviour, scene); + } + } + } + } + } + + private static readonly string UpdaterInstructions = + string.Format("Please run {0} to resolve this issue.", EventReferenceUpdater.MenuPath); + + private static void ValidateEventEmitter(StudioEventEmitter emitter, Scene scene) + { +#pragma warning disable 0618 // Suppress a warning about using the obsolete StudioEventEmitter.Event field + if (!string.IsNullOrEmpty(emitter.Event)) +#pragma warning restore 0618 + { + RuntimeUtils.DebugLogWarningFormat("FMOD: A Studio Event Emitter in scene '{0}' on GameObject '{1}' is using the " + + "obsolete Event field. {2}", + scene.name, EditorUtils.GameObjectPath(emitter), UpdaterInstructions); + } + + bool changed; + if (!ValidateEventReference(ref emitter.EventReference, emitter, scene, out changed)) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: A Studio Event Emitter in scene '{0}' on GameObject '{1}' has an invalid event reference: {2}", + scene.name, EditorUtils.GameObjectPath(emitter), emitter.EventReference); + } + } + + private static void ValidateEventReferenceFields(MonoBehaviour behaviour, Scene scene) + { + Type type = behaviour.GetType(); + + FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + foreach (FieldInfo field in fields) + { +#pragma warning disable 0618 // Suppress a warning about using the obsolete EventRefAttribute class + if (EditorUtils.HasAttribute(field)) +#pragma warning restore 0618 + { + RuntimeUtils.DebugLogWarningFormat("FMOD: A component of type {0} in scene '{1}' on GameObject '{2}' has an " + + "obsolete [EventRef] attribute on field {3}. {4}", + type.Name, scene.name, EditorUtils.GameObjectPath(behaviour), field.Name, + UpdaterInstructions); + } + else if (field.FieldType == typeof(EventReference)) + { + EventReference eventReference = (EventReference)field.GetValue(behaviour); + + bool changed; + if (!ValidateEventReference(ref eventReference, behaviour, scene, out changed)) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: A component of type {0} in scene '{1}' on GameObject '{2}' has an " + + "invalid event reference in field '{3}': {4}", + type.Name, scene.name, EditorUtils.GameObjectPath(behaviour), field.Name, eventReference); + } + + if (changed) + { + field.SetValue(behaviour, eventReference); + } + } + } + } + + // Returns true if eventReference is valid, sets changed if eventReference was changed + private static bool ValidateEventReference(ref EventReference eventReference, + Component parent, Scene scene, out bool changed) + { + changed = false; + + if (eventReference.IsNull) + { + return true; + } + + EditorEventRef editorEventRef; + + EventLinkage eventLinkage = GetEventLinkage(eventReference); + + if (eventLinkage == EventLinkage.GUID) + { + editorEventRef = EventFromGUID(eventReference.Guid); + + if (editorEventRef == null) + { + return false; + } + + if (eventReference.Path != editorEventRef.Path) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: EventReference path '{0}' doesn't match GUID {1} on object '{2}' in scene '{3}'. {4}", + eventReference.Path, eventReference.Guid, EditorUtils.GameObjectPath(parent), scene.name, + UpdaterInstructions); + } + + return true; + } + else if (eventLinkage == EventLinkage.Path) + { + editorEventRef = EventFromPath(eventReference.Path); + + if (editorEventRef == null) + { + return false; + } + + if (eventReference.Guid != editorEventRef.Guid) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: Changing EventReference GUID to {0} to match path '{1}' on object '{2}' in scene '{3}'. {4}", + editorEventRef.Guid, eventReference.Path, EditorUtils.GameObjectPath(parent), scene.name, + UpdaterInstructions); + + eventReference.Guid = editorEventRef.Guid; + EditorUtility.SetDirty(parent); + + changed = true; + } + + return true; + } + else + { + throw new NotSupportedException("Unrecognized EventLinkage: " + eventLinkage); + } + } + + public static void CopyToStreamingAssets(BuildTarget buildTarget) + { + if (Settings.Instance.ImportType == ImportType.AssetBundle && BuildPipeline.isBuildingPlayer) + { + return; + } + + if (string.IsNullOrEmpty(Settings.Instance.SourceBankPath)) + return; + + Platform platform = EditorSettings.Instance.GetPlatform(buildTarget); + + if (platform == Settings.Instance.DefaultPlatform) + { + RuntimeUtils.DebugLogWarningFormat("FMOD Studio: copy banks for platform {0} : Unsupported platform", buildTarget); + return; + } + + string bankTargetFolder = + Settings.Instance.ImportType == ImportType.StreamingAssets + ? Settings.Instance.TargetPath + : Application.dataPath + (string.IsNullOrEmpty(Settings.Instance.TargetAssetPath) ? "" : '/' + Settings.Instance.TargetAssetPath); + bankTargetFolder = RuntimeUtils.GetCommonPlatformPath(bankTargetFolder); + Directory.CreateDirectory(bankTargetFolder); + + string bankTargetExtension = + Settings.Instance.ImportType == ImportType.StreamingAssets + ? ".bank" + : ".bytes"; + + string bankSourceFolder = + Settings.Instance.HasPlatforms + ? Settings.Instance.SourceBankPath + '/' + platform.BuildDirectory + : Settings.Instance.SourceBankPath; + bankSourceFolder = RuntimeUtils.GetCommonPlatformPath(bankSourceFolder); + + if (Path.GetFullPath(bankTargetFolder).TrimEnd('/').ToUpperInvariant() == + Path.GetFullPath(bankSourceFolder).TrimEnd('/').ToUpperInvariant()) + { + return; + } + + bool madeChanges = false; + + try + { + // Clean out any stale .bank files + string[] existingBankFiles = + Directory.GetFiles(bankTargetFolder, "*" + bankTargetExtension, SearchOption.AllDirectories); + + foreach (string bankFilePath in existingBankFiles) + { + string bankName = EditorBankRef.CalculateName(bankFilePath, bankTargetFolder); + + if (!eventCache.EditorBanks.Exists(x => x.Name == bankName)) + { + string assetPath = bankFilePath.Replace(Application.dataPath, AssetsFolderName); + + if (AssetHasLabel(assetPath, FMODLabel)) + { + AssetDatabase.MoveAssetToTrash(assetPath); + madeChanges = true; + } + } + } + + // Copy over any files that don't match timestamp or size or don't exist + AssetDatabase.StartAssetEditing(); + foreach (var bankRef in eventCache.EditorBanks) + { + string sourcePath = bankSourceFolder + "/" + bankRef.Name + ".bank"; + string targetPathRelative = bankRef.Name + bankTargetExtension; + string targetPathFull = bankTargetFolder + "/" + targetPathRelative; + + FileInfo sourceInfo = new FileInfo(sourcePath); + FileInfo targetInfo = new FileInfo(targetPathFull); + + if (!targetInfo.Exists || + sourceInfo.Length != targetInfo.Length || + sourceInfo.LastWriteTime != targetInfo.LastWriteTime) + { + if (targetInfo.Exists) + { + targetInfo.IsReadOnly = false; + } + else + { + EnsureFoldersExist(targetPathRelative, bankTargetFolder); + } + + File.Copy(sourcePath, targetPathFull, true); + targetInfo = new FileInfo(targetPathFull); + targetInfo.IsReadOnly = false; + targetInfo.LastWriteTime = sourceInfo.LastWriteTime; + + madeChanges = true; + + string assetString = targetPathFull.Replace(Application.dataPath, "Assets"); + AssetDatabase.ImportAsset(assetString); + UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetString); + AssetDatabase.SetLabels(obj, new string[] { FMODLabel }); + } + } + + RemoveEmptyFMODFolders(bankTargetFolder); + } + catch (Exception exception) + { + RuntimeUtils.DebugLogErrorFormat("FMOD Studio: copy banks for platform {0} : copying banks from {1} to {2}", + platform.DisplayName, bankSourceFolder, bankTargetFolder); + RuntimeUtils.DebugLogException(exception); + return; + } + finally + { + AssetDatabase.StopAssetEditing(); + } + + if (madeChanges) + { + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + RuntimeUtils.DebugLogFormat("FMOD Studio: copy banks for platform {0} : copying banks from {1} to {2} succeeded", + platform.DisplayName, bankSourceFolder, bankTargetFolder); + } + } + + public static void UpdateBankStubAssets(BuildTarget buildTarget) + { + if (Settings.Instance.ImportType != ImportType.AssetBundle + || string.IsNullOrEmpty(Settings.Instance.SourceBankPath)) + { + return; + } + + Platform platform = EditorSettings.Instance.GetPlatform(buildTarget); + + if (platform == Settings.Instance.DefaultPlatform) + { + Debug.LogWarningFormat("FMOD: Updating bank stubs: Unsupported platform {0}", buildTarget); + return; + } + + string bankTargetFolder = Application.dataPath; + + if (!string.IsNullOrEmpty(Settings.Instance.TargetAssetPath)) + { + bankTargetFolder += "/" + Settings.Instance.TargetAssetPath; + } + + bankTargetFolder = RuntimeUtils.GetCommonPlatformPath(bankTargetFolder); + + string bankSourceFolder = Settings.Instance.SourceBankPath; + + if (Settings.Instance.HasPlatforms) + { + bankSourceFolder += "/" + platform.BuildDirectory; + } + + bankSourceFolder = RuntimeUtils.GetCommonPlatformPath(bankSourceFolder); + + if (Path.GetFullPath(bankTargetFolder).TrimEnd('/').ToUpperInvariant() == + Path.GetFullPath(bankSourceFolder).TrimEnd('/').ToUpperInvariant()) + { + return; + } + + bool madeChanges = false; + + Directory.CreateDirectory(bankTargetFolder); + + try + { + const string BankAssetExtension = ".bytes"; + + // Clean out any stale stubs + string[] existingBankFiles = + Directory.GetFiles(bankTargetFolder, "*" + BankAssetExtension, SearchOption.AllDirectories); + + foreach (string bankFilePath in existingBankFiles) + { + string bankName = EditorBankRef.CalculateName(bankFilePath, bankTargetFolder); + + if (!eventCache.EditorBanks.Exists(x => x.Name == bankName)) + { + string assetPath = bankFilePath.Replace(Application.dataPath, AssetsFolderName); + + if (AssetHasLabel(assetPath, FMODLabel)) + { + AssetDatabase.MoveAssetToTrash(assetPath); + madeChanges = true; + } + } + } + + // Create any stubs that don't exist, and ensure any that do exist have the correct data + AssetDatabase.StartAssetEditing(); + foreach (var bankRef in eventCache.EditorBanks) + { + string sourcePath = bankSourceFolder + "/" + bankRef.Name + ".bank"; + string targetPathRelative = bankRef.Name + BankAssetExtension; + string targetPathFull = bankTargetFolder + "/" + targetPathRelative; + + EnsureFoldersExist(targetPathRelative, bankTargetFolder); + + FileInfo targetInfo = new FileInfo(targetPathFull); + + string stubData = RuntimeManager.BankStubPrefix + bankRef.Name; + + // Minimise asset database refreshing by only writing the stub if necessary + bool writeStub; + + if (targetInfo.Exists && targetInfo.Length == stubData.Length) + { + using (StreamReader reader = targetInfo.OpenText()) + { + string contents = reader.ReadToEnd(); + writeStub = (contents != stubData); + } + } + else + { + writeStub = true; + } + + if (writeStub) + { + // Create or update the stub + using (StreamWriter writer = targetInfo.CreateText()) + { + writer.Write(stubData); + } + + madeChanges = true; + + if (!targetInfo.Exists) + { + string assetPath = targetPathFull.Replace(Application.dataPath, "Assets"); + AssetDatabase.ImportAsset(assetPath); + + UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath); + AssetDatabase.SetLabels(obj, new string[] { FMODLabel }); + } + } + } + RemoveEmptyFMODFolders(bankTargetFolder); + } + catch (Exception exception) + { + Debug.LogErrorFormat("FMOD: Updating bank stubs in {0} to match {1}", + bankTargetFolder, bankSourceFolder); + Debug.LogException(exception); + return; + } + finally + { + AssetDatabase.StopAssetEditing(); + } + + if (madeChanges) + { + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + Debug.LogFormat("FMOD: Updated bank stubs in {0} to match {1}", bankTargetFolder, bankSourceFolder); + } + } + + private static void EnsureFoldersExist(string filePath, string basePath) + { + string dataPath = Application.dataPath + "/"; + + if (!basePath.StartsWith(dataPath)) + { + throw new ArgumentException( + string.Format("Base path {0} is not within the Assets folder", basePath), "basePath"); + } + + int lastSlash = filePath.LastIndexOf('/'); + + if (lastSlash == -1) + { + // No folders + return; + } + + string assetString = filePath.Substring(0, lastSlash); + + string[] folders = assetString.Split('/'); + string parentFolder = "Assets/" + basePath.Substring(dataPath.Length); + + for (int i = 0; i < folders.Length; ++i) + { + string folderPath = parentFolder + "/" + folders[i]; + + if (!AssetDatabase.IsValidFolder(folderPath)) + { + AssetDatabase.CreateFolder(parentFolder, folders[i]); + + var folder = AssetDatabase.LoadAssetAtPath(folderPath); + AssetDatabase.SetLabels(folder, new string[] { FMODLabel }); + } + + parentFolder = folderPath; + } + } + + private static void BuildTargetChanged() + { + RefreshBanks(); + #if UNITY_ANDROID + Settings.Instance.AndroidUseOBB = PlayerSettings.Android.useAPKExpansionFiles; + #endif + } + + private static void OnCacheChange() + { + List masterBanks = new List(); + List banks = new List(); + + var settings = Settings.Instance; + bool hasChanged = false; + + foreach (EditorBankRef bankRef in eventCache.MasterBanks) + { + masterBanks.Add(bankRef.Name); + } + + if (!CompareLists(masterBanks, settings.MasterBanks)) + { + settings.MasterBanks.Clear(); + settings.MasterBanks.AddRange(masterBanks); + hasChanged = true; + } + + foreach (var bankRef in eventCache.EditorBanks) + { + if (!eventCache.MasterBanks.Contains(bankRef) && + !eventCache.StringsBanks.Contains(bankRef)) + { + banks.Add(bankRef.Name); + } + } + banks.Sort((a, b) => string.Compare(a, b, StringComparison.CurrentCultureIgnoreCase)); + + if (!CompareLists(banks, settings.Banks)) + { + settings.Banks.Clear(); + settings.Banks.AddRange(banks); + hasChanged = true; + } + + if (hasChanged) + { + EditorUtility.SetDirty(settings); + } + } + + public static DateTime CacheTime + { + get + { + if (eventCache != null) + { + return eventCache.CacheTime; + } + else + { + return DateTime.MinValue; + } + } + } + + public static List Events + { + get + { + AffirmEventCache(); + return eventCache.EditorEvents; + } + } + + public static List Banks + { + get + { + AffirmEventCache(); + return eventCache.EditorBanks; + } + } + + public static List Parameters + { + get + { + AffirmEventCache(); + return eventCache.EditorParameters; + } + } + + public static List MasterBanks + { + get + { + AffirmEventCache(); + return eventCache.MasterBanks; + } + } + + public static bool IsLoaded + { + get + { + return Settings.Instance.SourceBankPath != null; + } + } + + public static bool IsValid + { + get + { + AffirmEventCache(); + return eventCache.CacheTime != DateTime.MinValue; + } + } + + public static bool IsInitialized + { + get + { + return eventCache != null; + } + } + + public static EventLinkage GetEventLinkage(EventReference eventReference) + { + if (Settings.Instance.EventLinkage == EventLinkage.Path) + { + if (string.IsNullOrEmpty(eventReference.Path) && !eventReference.Guid.IsNull) + { + return EventLinkage.GUID; + } + else + { + return EventLinkage.Path; + } + } + else // Assume EventLinkage.GUID + { + if (eventReference.Guid.IsNull && !string.IsNullOrEmpty(eventReference.Path)) + { + return EventLinkage.Path; + } + else + { + return EventLinkage.GUID; + } + } + } + + public static EditorEventRef EventFromPath(string pathOrGuid) + { + EditorEventRef eventRef; + if (pathOrGuid.StartsWith("{")) + { + eventRef = EventFromGUID(FMOD.GUID.Parse(pathOrGuid)); + } + else + { + eventRef = EventFromString(pathOrGuid); + } + return eventRef; + } + + public static EditorEventRef EventFromString(string path) + { + AffirmEventCache(); + return eventCache.EditorEvents.Find((x) => x.Path.Equals(path, StringComparison.CurrentCultureIgnoreCase)); + } + + public static EditorEventRef EventFromGUID(FMOD.GUID guid) + { + AffirmEventCache(); + return eventCache.EditorEvents.Find((x) => x.Guid == guid); + } + + public static EditorParamRef ParamFromPath(string name) + { + AffirmEventCache(); + return eventCache.EditorParameters.Find((x) => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)); + } + + public class ActiveBuildTargetListener : IActiveBuildTargetChanged + { + public int callbackOrder{ get { return 0; } } + public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget) + { + BuildTargetChanged(); + } + } + + public class PreprocessScene : IProcessSceneWithReport + { + public int callbackOrder { get { return 0; } } + + public void OnProcessScene(Scene scene, BuildReport report) + { + if (report == null) return; + + ValidateEventReferences(scene); + } + } + + private static bool CompareLists(List tempBanks, List banks) + { + if (tempBanks.Count != banks.Count) + return false; + + for (int i = 0; i < tempBanks.Count; i++) + { + if (tempBanks[i] != banks[i]) + return false; + } + return true; + } + + private static bool AssetHasLabel(string assetPath, string label) + { + UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath(assetPath); + string[] labels = AssetDatabase.GetLabels(asset); + + return labels.Contains(label); + } + + public static void RemoveBanks(string basePath) + { + if (!Directory.Exists(basePath)) + { + return; + } + + string[] filePaths = Directory.GetFiles(basePath, "*", SearchOption.AllDirectories); + + foreach (string filePath in filePaths) + { + if (!filePath.EndsWith(".meta")) + { + string assetPath = filePath.Replace(Application.dataPath, AssetsFolderName); + + if (AssetHasLabel(assetPath, FMODLabel)) + { + AssetDatabase.MoveAssetToTrash(assetPath); + } + } + } + + RemoveEmptyFMODFolders(basePath); + + if (Directory.GetFileSystemEntries(basePath).Length == 0) + { + string baseFolder = basePath.Replace(Application.dataPath, AssetsFolderName); + AssetDatabase.MoveAssetToTrash(baseFolder); + } + } + + public static void MoveBanks(string from, string to) + { + if (!Directory.Exists(from)) + { + return; + } + + if (!Directory.Exists(to)) + { + Directory.CreateDirectory(to); + } + + string[] oldBankFiles = Directory.GetFiles(from); + + foreach (var oldBankFileName in oldBankFiles) + { + if (oldBankFileName.EndsWith(".meta")) + continue; + string assetString = oldBankFileName.Replace(Application.dataPath, "Assets"); + AssetDatabase.ImportAsset(assetString); + UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetString); + string[] labels = AssetDatabase.GetLabels(obj); + foreach (string label in labels) + { + if (label.Equals("FMOD")) + { + AssetDatabase.MoveAsset(assetString, to); + break; + } + } + } + if (Directory.GetFiles(Path.GetDirectoryName(oldBankFiles[0])).Length == 0) + { + Directory.Delete(Path.GetDirectoryName(oldBankFiles[0])); + } + } + + public static void RemoveEmptyFMODFolders(string basePath) + { + string[] folderPaths = Directory.GetDirectories(basePath, "*", SearchOption.AllDirectories); + + // Process longest paths first so parent folders are cleared out when we get to them + Array.Sort(folderPaths, (a, b) => b.Length.CompareTo(a.Length)); + + foreach (string folderPath in folderPaths) + { + string assetPath = folderPath.Replace(Application.dataPath, AssetsFolderName); + + if (AssetHasLabel(assetPath, FMODLabel) && Directory.GetFileSystemEntries(folderPath).Length == 0) + { + AssetDatabase.MoveAssetToTrash(assetPath); + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EventManager.cs.meta b/Assets/Plugins/FMOD/src/Editor/EventManager.cs.meta new file mode 100644 index 0000000..7739bf7 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1fc38201a5edb994c874a4a61e96053b +timeCreated: 1432600216 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs b/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs new file mode 100644 index 0000000..fd475b9 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs @@ -0,0 +1,512 @@ +using System; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEditor; + +namespace FMODUnity +{ + [CustomPropertyDrawer(typeof(EventReference))] + public class EventReferenceDrawer : PropertyDrawer + { + private static readonly Texture RepairIcon = EditorUtils.LoadImage("Wrench.png"); + private static readonly Texture WarningIcon = EditorUtils.LoadImage("NotFound.png"); + private static readonly GUIContent NotFoundWarning = new GUIContent("Event Not Found", WarningIcon); + + private static GUIStyle buttonStyle; + + private static Vector2 WarningSize() + { + return GUI.skin.label.CalcSize(NotFoundWarning); + } + + private static float GetBaseHeight() + { + return GUI.skin.textField.CalcSize(GUIContent.none).y; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + if (buttonStyle == null) + { + buttonStyle = new GUIStyle(GUI.skin.button); + buttonStyle.padding.top = 1; + buttonStyle.padding.bottom = 1; + } + + Texture browseIcon = EditorUtils.LoadImage("SearchIconBlack.png"); + Texture openIcon = EditorUtils.LoadImage("BrowserIcon.png"); + Texture addIcon = EditorUtils.LoadImage("AddIcon.png"); + Texture copyIcon = EditorUtils.LoadImage("CopyIcon.png"); + + using (new EditorGUI.PropertyScope(position, label, property)) + { + HandleDragEvents(position, property); + + EventReference eventReference = property.GetEventReference(); + EditorEventRef editorEventRef = GetEditorEventRef(eventReference); + + float baseHeight = GetBaseHeight(); + + Rect headerRect = position; + headerRect.width = EditorGUIUtility.labelWidth; + headerRect.height = baseHeight; + + property.isExpanded = EditorGUI.Foldout(headerRect, property.isExpanded, label, true); + + Rect addRect = new Rect(position.xMax - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight); + Rect openRect = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight); + Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight); + Rect pathRect = position; + pathRect.xMin = headerRect.xMax; + pathRect.xMax = searchRect.x - 3; + pathRect.height = baseHeight; + + SerializedProperty pathProperty = GetPathProperty(property); + + using (var scope = new EditorGUI.ChangeCheckScope()) + { + EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none); + + if (scope.changed) + { + SetEvent(property, pathProperty.stringValue); + } + } + + if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle)) + { + var eventBrowser = ScriptableObject.CreateInstance(); + + eventBrowser.ChooseEvent(property); + var windowRect = position; + windowRect.xMin = pathRect.xMin; + windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); + windowRect.height = openRect.height + 1; + windowRect.width = Mathf.Max(windowRect.width, 300f); + eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400)); + + } + if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle)) + { + var addDropdown = EditorWindow.CreateInstance(); + + addDropdown.SelectEvent(property); + var windowRect = position; + windowRect.xMin = pathRect.xMin; + windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); + windowRect.height = openRect.height + 1; + windowRect.width = Mathf.Max(windowRect.width, 300f); + addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500)); + + } + if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle)) + { + EventBrowser.ShowWindow(); + EventBrowser eventBrowser = EditorWindow.GetWindow(); + eventBrowser.FrameEvent(pathProperty.stringValue); + } + + if (editorEventRef != null) + { + float labelY = headerRect.y + baseHeight; + + MismatchInfo mismatch = GetMismatch(eventReference, editorEventRef); + + if (mismatch != null) + { + Rect warningRect = pathRect; + warningRect.xMax = position.xMax; + warningRect.y = labelY; + warningRect.height = WarningSize().y; + + DrawMismatchUI(warningRect, openRect.x, openRect.width, mismatch, property); + + labelY = warningRect.yMax; + } + + if (property.isExpanded) + { + using (new EditorGUI.IndentLevelScope()) + { + Rect labelRect = EditorGUI.IndentedRect(headerRect); + labelRect.y = labelY; + + Rect valueRect = labelRect; + valueRect.xMin = labelRect.xMax; + valueRect.xMax = position.xMax - copyIcon.width - 7; + + GUI.Label(labelRect, new GUIContent("GUID")); + GUI.Label(valueRect, eventReference.Guid.ToString()); + + Rect copyRect = valueRect; + copyRect.xMin = valueRect.xMax; + copyRect.xMax = position.xMax; + + if (GUI.Button(copyRect, new GUIContent(copyIcon, "Copy To Clipboard"))) + { + EditorGUIUtility.systemCopyBuffer = eventReference.Guid.ToString(); + } + + valueRect.xMax = position.xMax; + + labelRect.y += baseHeight; + valueRect.y += baseHeight; + + GUI.Label(labelRect, new GUIContent("Banks")); + GUI.Label(valueRect, string.Join(", ", editorEventRef.Banks.Select(x => x.Name).ToArray())); + labelRect.y += baseHeight; + valueRect.y += baseHeight; + + GUI.Label(labelRect, new GUIContent("Panning")); + GUI.Label(valueRect, editorEventRef.Is3D ? "3D" : "2D"); + labelRect.y += baseHeight; + valueRect.y += baseHeight; + + GUI.Label(labelRect, new GUIContent("Stream")); + GUI.Label(valueRect, editorEventRef.IsStream.ToString()); + labelRect.y += baseHeight; + valueRect.y += baseHeight; + + GUI.Label(labelRect, new GUIContent("Oneshot")); + GUI.Label(valueRect, editorEventRef.IsOneShot.ToString()); + labelRect.y += baseHeight; + valueRect.y += baseHeight; + } + } + } + else + { + EditorEventRef renamedEvent = GetRenamedEventRef(eventReference); + + if (renamedEvent != null) + { + MismatchInfo mismatch = new MismatchInfo() { + Message = string.Format("Moved to {0}", renamedEvent.Path), + HelpText = string.Format( + "This event has been moved in FMOD Studio.\n" + + "You can click the repair button to update the path to the new location, or run " + + "the {0} command to scan your project for similar issues and fix them all.", + EventReferenceUpdater.MenuPath), + RepairTooltip = string.Format("Repair: set path to {0}", renamedEvent.Path), + RepairAction = (p) => { + p.FindPropertyRelative("Path").stringValue = renamedEvent.Path; + }, + }; + + using (new EditorGUI.IndentLevelScope()) + { + Rect mismatchRect = pathRect; + + mismatchRect.xMin = position.xMin; + mismatchRect.xMax = position.xMax; + mismatchRect.y += baseHeight; + mismatchRect.height = baseHeight; + + mismatchRect = EditorGUI.IndentedRect(mismatchRect); + + DrawMismatchUI(mismatchRect, openRect.x, openRect.width, mismatch, property); + } + } + else + { + Rect labelRect = pathRect; + labelRect.xMax = position.xMax; + labelRect.y += baseHeight; + labelRect.height = WarningSize().y; + + GUI.Label(labelRect, NotFoundWarning); + } + } + } + } + + private static void HandleDragEvents(Rect position, SerializedProperty property) + { + Event e = Event.current; + + if (e.type == EventType.DragPerform && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef)) + { + EditorEventRef eventRef = DragAndDrop.objectReferences[0] as EditorEventRef; + + property.SetEventReference(eventRef.Guid, eventRef.Path); + + GUI.changed = true; + e.Use(); + } + } + + if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Move; + DragAndDrop.AcceptDrag(); + e.Use(); + } + } + } + + private class MismatchInfo + { + public string Message; + public string HelpText; + public string RepairTooltip; + public Action RepairAction; + } + + private static void DrawMismatchUI(Rect rect, float repairButtonX, float repairButtonWidth, + MismatchInfo mismatch, SerializedProperty property) + { + rect = EditorUtils.DrawHelpButton(rect, () => new SimpleHelp(mismatch.HelpText, 400)); + + Rect repairRect = new Rect(repairButtonX, rect.y, repairButtonWidth, GetBaseHeight()); + + if (GUI.Button(repairRect, new GUIContent(RepairIcon, mismatch.RepairTooltip), buttonStyle)) + { + mismatch.RepairAction(property); + } + + Rect labelRect = rect; + labelRect.xMax = repairRect.xMin; + + GUI.Label(labelRect, new GUIContent(mismatch.Message, WarningIcon)); + } + + private static MismatchInfo GetMismatch(EventReference eventReference, EditorEventRef editorEventRef) + { + if (EventManager.GetEventLinkage(eventReference) == EventLinkage.Path) + { + if (eventReference.Guid != editorEventRef.Guid) + { + return new MismatchInfo() { + Message = "GUID doesn't match path", + HelpText = string.Format( + "The GUID on this EventReference doesn't match the path.\n" + + "You can click the repair button to update the GUID to match the path, or run the " + + "{0} command to scan your project for similar issues and fix them all.", + EventReferenceUpdater.MenuPath), + RepairTooltip = string.Format("Repair: set GUID to {0}", editorEventRef.Guid), + RepairAction = (property) => { + property.FindPropertyRelative("Guid").SetGuid(editorEventRef.Guid); + }, + }; + } + } + else // EventLinkage.GUID + { + if (eventReference.Path != editorEventRef.Path) + { + return new MismatchInfo() { + Message = "Path doesn't match GUID", + HelpText = string.Format( + "The path on this EventReference doesn't match the GUID.\n" + + "You can click the repair button to update the path to match the GUID, or run the " + + "{0} command to scan your project for similar issues and fix them all.", + EventReferenceUpdater.MenuPath), + RepairTooltip = string.Format("Repair: set path to '{0}'", editorEventRef.Path), + RepairAction = (property) => { + property.FindPropertyRelative("Path").stringValue = editorEventRef.Path; + }, + }; + } + } + + return null; + } + + private static void SetEvent(SerializedProperty property, string path) + { + EditorEventRef eventRef = EventManager.EventFromPath(path); + + if (eventRef != null) + { + property.SetEventReference(eventRef.Guid, eventRef.Path); + } + else + { + property.SetEventReference(new FMOD.GUID(), path); + } + } + + private static SerializedProperty GetGuidProperty(SerializedProperty property) + { + return property.FindPropertyRelative("Guid"); + } + + private static SerializedProperty GetPathProperty(SerializedProperty property) + { + return property.FindPropertyRelative("Path"); + } + + private static EditorEventRef GetEditorEventRef(EventReference eventReference) + { + if (EventManager.GetEventLinkage(eventReference) == EventLinkage.Path) + { + return EventManager.EventFromPath(eventReference.Path); + } + else // Assume EventLinkage.GUID + { + return EventManager.EventFromGUID(eventReference.Guid); + } + } + + private static EditorEventRef GetRenamedEventRef(EventReference eventReference) + { + if (Settings.Instance.EventLinkage == EventLinkage.Path && !eventReference.Guid.IsNull) + { + EditorEventRef editorEventRef = EventManager.EventFromGUID(eventReference.Guid); + + if (editorEventRef != null && editorEventRef.Path != eventReference.Path) + { + return editorEventRef; + } + } + + return null; + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + float baseHeight = GetBaseHeight(); + + EventReference eventReference = property.GetEventReference(); + EditorEventRef editorEventRef = GetEditorEventRef(eventReference); + + if (editorEventRef == null) + { + return baseHeight + WarningSize().y; + } + else + { + float height; + + if (property.isExpanded) + { + height = baseHeight * 6; // 5 lines of info + } + else + { + height = baseHeight; + } + + if (GetMismatch(eventReference, editorEventRef) != null) + { + height += WarningSize().y; + } + + return height; + } + } + } + +#pragma warning disable 0618 // Suppress the warning about using the obsolete EventRefAttribute class + [CustomPropertyDrawer(typeof(EventRefAttribute))] +#pragma warning restore 0618 + public class LegacyEventRefDrawer : PropertyDrawer + { + private GUIStyle RichTextStyle; + + private const string HelpText = + "This field has the [EventRef] attribute, which is obsolete.\n" + + "To resolve this issue:\n" + + "* Add a field of type EventReference to this class\n" + + "* Set the MigrateTo property on the [EventRef] attribute: " + + "[EventRef(MigrateTo=\"\")]\n" + + "* Run the " + EventReferenceUpdater.MenuPath + " command to " + + "automatically migrate values from this field to the EventReference field"; + + private static readonly Texture InfoIcon = EditorGUIUtility.IconContent("console.infoicon.sml").image; + private static readonly Texture WarningIcon = EditorUtils.LoadImage("NotFound.png"); + + private void AffirmStyles() + { + if (RichTextStyle == null) + { + RichTextStyle = new GUIStyle(GUI.skin.label) { richText = true }; + } + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + AffirmStyles(); + + label = EditorGUI.BeginProperty(position, label, property); + + Rect pathRect = position; + pathRect.height = EditorGUIUtility.singleLineHeight; + + pathRect = EditorGUI.PrefixLabel(pathRect, label); + EditorGUI.PropertyField(pathRect, property, GUIContent.none); + + using (new EditorGUI.IndentLevelScope()) + { + GUIContent content = StatusContent(property); + + Rect infoRect = EditorGUI.IndentedRect(position); + infoRect.y = pathRect.yMax; + infoRect.height = StatusSize(content).y; + + infoRect = EditorUtils.DrawHelpButton(infoRect, () => new SimpleHelp(HelpText, 400)); + + GUI.Label(infoRect, content, RichTextStyle); + } + + EditorGUI.EndProperty(); + } + + private GUIContent StatusContent(SerializedProperty property) + { +#pragma warning disable 0618 // Suppress the warning about using the obsolete EventRefAttribute class + string migrationTarget = (attribute as EventRefAttribute).MigrateTo; +#pragma warning restore 0618 + + if (string.IsNullOrEmpty(migrationTarget)) + { + return new GUIContent("[EventRef] is obsolete - use the EventReference type instead.", + WarningIcon); + + } + else + { + int parentPathLength = property.propertyPath.LastIndexOf('.'); + + if (parentPathLength >= 0) + { + migrationTarget = string.Format("{0}.{1}", property.propertyPath.Remove(parentPathLength), migrationTarget); + } + + SerializedProperty targetProperty = property.serializedObject.FindProperty(migrationTarget); + + if (targetProperty != null) + { + return new GUIContent(string.Format("Will be migrated to {0}", targetProperty.displayName), + InfoIcon); + } + else + { + return new GUIContent(string.Format("Migration target {0} is missing", migrationTarget), + WarningIcon); + } + } + } + + private Vector2 StatusSize(GUIContent content) + { + AffirmStyles(); + + return Vector2.Max(RichTextStyle.CalcSize(content), EditorUtils.GetHelpButtonSize()); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return EditorGUIUtility.singleLineHeight + StatusSize(StatusContent(property)).y; + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs.meta b/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs.meta new file mode 100644 index 0000000..7db087d --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventRefDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 29a86a77bf7568e499243d9b47b7e88e +timeCreated: 1432696197 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs b/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs new file mode 100644 index 0000000..0ee4fc9 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs @@ -0,0 +1,2445 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEditor.Experimental.SceneManagement; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace FMODUnity +{ + public class EventReferenceUpdater : EditorWindow + { + public const string MenuPath = "FMOD/Update Event References"; + + private const string SearchButtonText = "Scan"; + + private const int EventReferenceTransitionVersion = 0x00020200; + + private const BindingFlags DefaultBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + + private static readonly string HelpText = + string.Format("Click {0} to search your project for obsolete event references.", SearchButtonText); + + private readonly string[] SearchFolders = { + "Assets", + }; + + private SceneSetup[] sceneSetup; + + private IEnumerator processingState; + + private SearchProgress prefabProgress; + private SearchProgress sceneProgress; + private SearchProgress scriptableObjectProgress; + + [SerializeField] + private List assets = new List(); + + [SerializeField] + private List components = new List(); + + [SerializeField] + private List tasks = new List(); + + private int executableTaskCount = 0; + + private TreeViewState taskViewState = new TreeViewState(); + + private TaskView taskView; + + [NonSerialized] + private GUIContent status = GUIContent.none; + + [NonSerialized] + private Task selectedTask; + + [NonSerialized] + private Vector2 manualDescriptionScrollPosition; + + [NonSerialized] + private static GUIContent AssetContent = new GUIContent("Asset"); + private static GUIContent ComponentTypeContent = new GUIContent("Component Type"); + private static GUIContent GameObjectContent = new GUIContent("Game Object"); + + private string ExecuteButtonText() + { + return string.Format("Execute {0} Selected Tasks", executableTaskCount); + } + + [MenuItem(MenuPath)] + public static void ShowWindow() + { + EventReferenceUpdater updater = GetWindow("FMOD Event Reference Updater"); + updater.minSize = new Vector2(800, 600); + + updater.SetStatus(HelpText); + + updater.Show(); + } + + public static bool IsUpToDate() + { + return Settings.Instance.LastEventReferenceScanVersion >= EventReferenceTransitionVersion; + } + + private void BeginSearching() + { + if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) + { + tasks.Clear(); + executableTaskCount = 0; + taskView.SetSelection(new List(), TreeViewSelectionOptions.FireSelectionChanged); + taskView.Reload(); + + processingState = SearchProject(); + } + } + + private void StopProcessing(bool isComplete) + { + processingState = null; + + if (isComplete) + { + if (tasks.Count == 0) + { + SetStatus("No required tasks found. Event references are up to date."); + Settings.Instance.LastEventReferenceScanVersion = FMOD.VERSION.number; + EditorUtility.SetDirty(Settings.Instance); + + SetupWizardWindow.SetUpdateTaskComplete(SetupWizardWindow.UpdateTaskType.UpdateEventReferences); + } + else if (tasks.All(x => x.HasExecuted)) + { + SetStatus("Finished executing tasks. New tasks may now be required. Please re-scan your project."); + } + else + { + SetStatus("Finished scanning. Please execute the tasks above."); + } + } + else + { + SetStatus("Cancelled."); + } + } + + private void BeginExecuting() + { + Task[] enabledTasks = tasks.Where(t => t.CanExecute()).ToArray(); + + if (enabledTasks.Length == 0) + { + return; + } + + Asset[] affectedAssets = enabledTasks.Select(t => assets[t.AssetIndex]).Distinct().ToArray(); + + int prefabCount = affectedAssets.Count(a => IsPrefab(a.Type)); + int sceneCount = affectedAssets.Count(a => a.Type == AssetType.Scene); + + string warningText = string.Format( + "Executing these {0} tasks will change {1} prefabs and {2} scenes on disk.\n\n" + + "Please ensure you have committed any outstanding changes to source control before continuing!", + enabledTasks.Length, prefabCount, sceneCount); + + if (!EditorUtility.DisplayDialog("Confirm Bulk Changes", warningText, ExecuteButtonText(), "Cancel")) + { + return; + } + + if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) + { + processingState = ExecuteTasks(enabledTasks); + } + } + + private void Cancel() + { + if (IsProcessing) + { + StopProcessing(false); + } + else + { + Close(); + } + } + + private bool IsProcessing { get { return processingState != null; } } + + private struct SearchProgress + { + private int maximum; + private int current; + + public float Fraction() + { + return (maximum > 0) ? (current / (float)maximum) : 1; + } + + public void Increment() + { + if (current < maximum) + { + ++current; + } + } + + public SearchProgress(int total) + { + this.maximum = total; + this.current = 0; + } + } + + private IEnumerator SearchProject() + { + string[] prefabGuids = AssetDatabase.FindAssets("t:GameObject", SearchFolders); + string[] sceneGuids = AssetDatabase.FindAssets("t:Scene", SearchFolders); + string[] scriptableObjectGuids = + AssetDatabase.FindAssets("t:ScriptableObject", SearchFolders).Distinct().ToArray(); + + prefabProgress = new SearchProgress(prefabGuids.Length); + sceneProgress = new SearchProgress(sceneGuids.Length); + scriptableObjectProgress = new SearchProgress(scriptableObjectGuids.Length); + + return SearchPrefabs(prefabGuids) + .Concat(SearchScriptableObjects(scriptableObjectGuids)) + .Concat(SearchScenes(sceneGuids)) + .GetEnumerator(); + } + + private IEnumerable SearchPrefabs(string[] guids) + { + foreach (string guid in guids) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + + yield return string.Format("Searching {0}", path); + + GameObject prefab = AssetDatabase.LoadAssetAtPath(path); + + int assetIndex = -1; + + foreach (Task task in SearchGameObject(prefab, prefab)) + { + if (assetIndex < 0) + { + assetIndex = AddAsset(GetAssetType(prefab), path); + } + + task.AssetIndex = assetIndex; + + AddTask(task); + } + + prefabProgress.Increment(); + } + } + + private IEnumerable SearchScriptableObjects(string[] guids) + { + foreach (string guid in guids) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + + yield return string.Format("Searching {0}", path); + + IEnumerable scriptableObjects = + AssetDatabase.LoadAllAssetsAtPath(path).OfType(); + + int assetIndex = -1; + + foreach (ScriptableObject scriptableObject in scriptableObjects) + { + int componentIndex = -1; + + foreach (Task task in GetUpdateTasks(scriptableObject)) + { + if (assetIndex < 0) + { + assetIndex = AddAsset(AssetType.ScriptableObject, path); + } + + if (componentIndex < 0) + { + componentIndex = AddComponent(scriptableObject); + } + + task.AssetIndex = assetIndex; + task.ComponentIndex = componentIndex; + + AddTask(task); + } + } + + scriptableObjectProgress.Increment(); + } + } + + private IEnumerable SearchScenes(string[] guids) + { + sceneSetup = EditorSceneManager.GetSceneManagerSetup(); + + foreach (string guid in guids) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + + yield return string.Format("Searching {0}", path); + + Scene scene = SceneManager.GetSceneByPath(path); + + if (!scene.IsValid()) + { + scene = EditorSceneManager.OpenScene(path, OpenSceneMode.Single); + } + + int assetIndex = -1; + + foreach (GameObject gameObject in scene.GetRootGameObjects()) + { + foreach (Task task in SearchGameObject(gameObject, null)) + { + if (assetIndex < 0) + { + assetIndex = AddAsset(AssetType.Scene, path); + } + + task.AssetIndex = assetIndex; + + AddTask(task); + } + } + + sceneProgress.Increment(); + } + + if (sceneSetup.Length > 0) + { + EditorSceneManager.RestoreSceneManagerSetup(sceneSetup); + } + } + + private IEnumerable SearchGameObject(GameObject gameObject, GameObject root) + { + MonoBehaviour[] behaviours = gameObject.GetComponentsInChildren(true); + + foreach (MonoBehaviour behaviour in behaviours) + { + int componentIndex = -1; + + foreach (Task task in GetUpdateTasks(behaviour)) + { + if (componentIndex < 0) + { + componentIndex = AddComponent(behaviour, root); + } + + task.ComponentIndex = componentIndex; + + yield return task; + } + } + } + + private static IEnumerable GetUpdateTasks(UnityEngine.Object target) + { + if (target == null) + { + return Enumerable.Empty(); + } + else if (target is StudioEventEmitter) + { + return GetEmitterUpdateTasks(target as StudioEventEmitter); + } +#if UNITY_TIMELINE_EXIST + else if (target is FMODEventPlayable) + { + return GetPlayableUpdateTasks(target as FMODEventPlayable); + } +#endif + else + { + return GetGenericUpdateTasks(target); + } + } + + private static IEnumerable GetEmitterUpdateTasks(StudioEventEmitter emitter) + { + bool hasOwnEvent = true; + bool hasOwnEventReference = true; + + if (PrefabUtility.IsPartOfPrefabInstance(emitter)) + { + StudioEventEmitter sourceEmitter = PrefabUtility.GetCorrespondingObjectFromSource(emitter); + PropertyModification[] modifications = PrefabUtility.GetPropertyModifications(emitter); + + if (modifications != null) // GetPropertyModifications returns null if the prefab instance is disconnected + { + hasOwnEvent = modifications.Any( + m => m.target == sourceEmitter && m.propertyPath == "Event"); + + hasOwnEventReference = modifications.Any( + m => m.target == sourceEmitter && m.propertyPath.StartsWith("EventReference")); + } + } + + if (hasOwnEventReference) + { + Task updateTask = GetUpdateEventReferenceTask(emitter.EventReference, "EventReference"); + if (updateTask != null) + { + yield return updateTask; + } + + if (hasOwnEvent) + { +#pragma warning disable 0618 // Suppress warnings about using the obsolete StudioEventEmitter.Event field + if (!string.IsNullOrEmpty(emitter.Event)) +#pragma warning restore 0618 + { + if (emitter.EventReference.IsNull) + { + yield return Task.MoveEventToEventReference(emitter); + } + else + { + yield return Task.ClearEvent(emitter); + } + } + } + } + else if (hasOwnEvent) + { + yield return Task.MoveEventOverrideToEventReference(emitter); + } + } + + private static Task GetUpdateEventReferenceTask(EventReference eventReference, string fieldName, + string subObjectPath = null) + { + if (eventReference.IsNull) + { + return null; + } + + if (Settings.Instance.EventLinkage == EventLinkage.GUID) + { + EditorEventRef editorEventRef = EventManager.EventFromGUID(eventReference.Guid); + + if (editorEventRef == null) + { + return null; + } + + if (eventReference.Path != editorEventRef.Path) + { + return Task.UpdateEventReferencePath(subObjectPath, fieldName, eventReference.Path, + editorEventRef.Path, eventReference.Guid); + } + } + else if (Settings.Instance.EventLinkage == EventLinkage.Path) + { + EditorEventRef editorEventRef = EventManager.EventFromPath(eventReference.Path); + + if (editorEventRef != null) + { + if (eventReference.Guid != editorEventRef.Guid) + { + return Task.UpdateEventReferenceGuid(subObjectPath, fieldName, eventReference.Guid, + editorEventRef.Guid, eventReference.Path); + } + } + else if (!eventReference.Guid.IsNull) + { + editorEventRef = EventManager.EventFromGUID(eventReference.Guid); + + if (editorEventRef != null) + { + return Task.UpdateEventReferencePath(subObjectPath, fieldName, eventReference.Path, + editorEventRef.Path, eventReference.Guid); + } + } + } + else + { + throw new NotSupportedException("Unrecognized EventLinkage: " + Settings.Instance.EventLinkage); + } + + return null; + } + +#if UNITY_TIMELINE_EXIST + private static IEnumerable GetPlayableUpdateTasks(FMODEventPlayable playable) + { + Task updateTask = GetUpdateEventReferenceTask(playable.EventReference, "EventReference"); + if (updateTask != null) + { + yield return updateTask; + } + +#pragma warning disable 0618 // Suppress warnings about using the obsolete FMODEventPlayable.eventName field + if (!string.IsNullOrEmpty(playable.eventName)) +#pragma warning restore 0618 + { + if (playable.EventReference.IsNull) + { + yield return Task.MoveEventNameToEventReference(playable); + } + else + { + yield return Task.ClearEventName(playable); + } + } + } +#endif + +#pragma warning disable 0618 // Suppress a warning about using the obsolete EventRefAttribute class + private static bool IsEventRef(FieldInfo field) + { + return field.FieldType == typeof(string) && EditorUtils.HasAttribute(field); + } +#pragma warning restore 0618 + + private static T GetCustomAttribute(FieldInfo field) + where T : Attribute + { + return Attribute.GetCustomAttribute(field, typeof(T)) as T; + } + + private static readonly Assembly SystemAssembly = typeof(object).Assembly; + + private static IEnumerable GetGenericUpdateTasks(object target, string subObjectPath = null, IEnumerable parents = null) + { + Type targetType = target.GetType(); + FieldInfo[] fields = targetType.GetFields(DefaultBindingFlags); + + List oldFields = new List(); + List newFields = new List(); + List subObjectFields = new List(); + + foreach (FieldInfo f in fields) + { + if (IsEventRef(f)) + { + oldFields.Add(f); + } + else if (f.FieldType == typeof(EventReference)) + { + newFields.Add(f); + } + else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(f.FieldType)) + { + subObjectFields.Add(f); + } + else if (f.FieldType.Assembly != SystemAssembly && !f.FieldType.IsEnum) + { + subObjectFields.Add(f); + } + } + + int initialOldFieldCount = oldFields.Count; + + // Remove empty [EventRef] fields + for (int i = 0; i < oldFields.Count; ) + { + FieldInfo oldField = oldFields[i]; + + if (string.IsNullOrEmpty(oldField.GetValue(target) as string)) + { + oldFields.RemoveAt(i); + + yield return Task.RemoveEmptyEventRefField(subObjectPath, oldField.Name, targetType.Name); + } + else + { + ++i; + } + } + + // Handle conflicts where multiple [EventRef] fields have the same migration target +#pragma warning disable 0618 // Suppress a warning about using the obsolete EventRefAttribute class + IGrouping[] conflictingGroups = oldFields + .GroupBy(f => GetCustomAttribute(f).MigrateTo) + .Where(g => !string.IsNullOrEmpty(g.Key) && g.Count() > 1) + .ToArray(); +#pragma warning restore 0618 + + foreach (IGrouping group in conflictingGroups) + { + foreach (FieldInfo field in group) + { + oldFields.Remove(field); + } + + yield return Task.FixMigrationTargetConflict(subObjectPath, targetType.Name, group.Select(f => f.Name)); + } + + // Handle [EventRef] fields with MigrateTo set +#pragma warning disable 0618 // Suppress a warning about using the obsolete EventRefAttribute class + for (int i = 0; i < oldFields.Count; ) + { + FieldInfo oldField = oldFields[i]; + + EventRefAttribute attribute = GetCustomAttribute(oldField); + + if (!string.IsNullOrEmpty(attribute.MigrateTo)) + { + oldFields.RemoveAt(i); + + string oldValue = oldField.GetValue(target) as string; + + FieldInfo newField = newFields.FirstOrDefault(f => f.Name == attribute.MigrateTo); + + if (newField != null) + { + EventReference newValue = (EventReference)newField.GetValue(target); + + if (newValue.IsNull) + { + yield return Task.MoveEventRefFieldToEventReferenceField(subObjectPath, oldValue, + oldField.Name, newField.Name); + } + else + { + yield return Task.RemoveEventRefField(subObjectPath, oldValue, oldField.Name, targetType.Name); + } + } + else + { + yield return Task.AddMigrationTarget(subObjectPath, oldValue, oldField.Name, targetType.Name, + attribute.MigrateTo); + } + } + else + { + ++i; + } + } +#pragma warning restore 0618 + + // Auto-migrate if there is a single old field that hasn't been handled already, + // and there is a single new field + if (initialOldFieldCount == 1 && oldFields.Count == 1 && newFields.Count == 1) + { + FieldInfo oldField = oldFields[0]; + + string oldValue = oldField.GetValue(target) as string; + + FieldInfo newField = newFields[0]; + + EventReference newValue = (EventReference)newField.GetValue(target); + + if (newValue.IsNull) + { + yield return Task.MoveEventRefFieldToEventReferenceField(subObjectPath, oldValue, + oldField.Name, newField.Name); + } + else + { + yield return Task.RemoveEventRefField(subObjectPath, oldValue, oldField.Name, targetType.Name); + } + + oldFields.RemoveAt(0); + } + + // Handle old fields with no migration target + foreach (FieldInfo oldField in oldFields) + { + yield return Task.AddMigrationTarget(subObjectPath, oldField.GetValue(target) as string, oldField.Name, + targetType.Name); + } + + // Check new fields for GUID/path mismatches + foreach (FieldInfo newField in newFields) + { + EventReference eventReference = (EventReference)newField.GetValue(target); + + Task updateTask = GetUpdateEventReferenceTask(eventReference, newField.Name, subObjectPath); + if (updateTask != null) + { + yield return updateTask; + } + } + + // Check sub-object fields + if (subObjectFields.Any()) + { + if (parents == null) + { + parents = Enumerable.Empty(); + } + + parents = parents.Append(target); + + foreach (FieldInfo subObjectField in subObjectFields) + { + object value = subObjectField.GetValue(target); + + if (value != null && !parents.Contains(value)) + { + if (value is System.Collections.IEnumerable) + { + int index = 0; + foreach (object item in value as System.Collections.IEnumerable) + { + foreach (Task t in GetGenericUpdateTasks(item, FieldPath(subObjectPath, subObjectField.Name, index), parents)) + { + yield return t; + } + index++; + } + } + else + { + foreach (Task t in GetGenericUpdateTasks(value, FieldPath(subObjectPath, subObjectField.Name), parents)) + { + yield return t; + } + } + } + } + } + } + + private IEnumerator ExecuteTasks(Task[] tasks) + { + sceneSetup = EditorSceneManager.GetSceneManagerSetup(); + + foreach (Task task in tasks) + { + yield return string.Format("Executing: {0}", task); + + ExecuteTask(task, SavePolicy.AutoSave); + } + + EditorSceneManager.SaveOpenScenes(); + UpdateExecutableTaskCount(); + + if (sceneSetup.Length > 0) + { + EditorSceneManager.RestoreSceneManagerSetup(sceneSetup); + } + } + + private enum AssetType + { + Scene, + Prefab, + PrefabModel, + PrefabVariant, + ScriptableObject, + } + + private static bool IsPrefab(AssetType type) + { + return type == AssetType.Prefab + || type == AssetType.PrefabModel + || type == AssetType.PrefabVariant; + } + + private static AssetType GetAssetType(GameObject gameObject) + { + PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(gameObject); + + if (prefabType == PrefabAssetType.Model) + { + return AssetType.PrefabModel; + } + else if (prefabType == PrefabAssetType.Variant) + { + return AssetType.PrefabVariant; + } + else + { + return AssetType.Prefab; + } + } + + private enum EnableState + { + Enabled, + Disabled, + Mixed, + } + + [Serializable] + private class Asset + { + public AssetType Type; + public string Path; + public EnableState EnableState; + } + + [Serializable] + private class Component + { + public GlobalObjectId GameObjectID; + public string Type; + public string Path; + public string ScriptPath; + } + + [Serializable] + private class Task + { + public bool Enabled = true; + public int AssetIndex; // index into the assets list + public int ComponentIndex; // index into the components list + + private Type type; + private string[] Data; + + private const string EmitterEventField = "Event"; + private const string EmitterEventReferenceField = "EventReference"; + private const string PlayableEventNameField = "eventName"; + private const string PlayableEventReferenceField = "eventReference"; + + private delegate string DescriptionDelegate(string[] data); + private delegate string ManualInstructionsDelegate(string[] data, Component component); + private delegate bool IsValidDelegate(string[] data, UnityEngine.Object target); + private delegate void ExecuteDelegate(string[] data, UnityEngine.Object target); + + private static readonly Delegates[] Implementations; + + private enum Type + { + EmitterClearEvent, + EmitterMoveEventToEventReference, + EmitterMoveEventOverrideToEventReference, + PlayableClearEventName, + PlayableMoveEventNameToEventReference, + GenericRemoveEventRefField, + GenericRemoveEmptyEventRefField, + GenericMoveEventRefFieldToEventReferenceField, + GenericAddMigrationTarget, + GenericUpdateEventReferencePath, + GenericUpdateEventReferenceGuid, + GenericFixMigrationTargetConflict, + + Count + } + + public bool HasExecuted { get; private set; } + + // Suppress warnings about using the obsolete StudioEventEmitter.Event and FMODEventPlayable.eventName fields +#pragma warning disable 0618 + public static Task ClearEvent(StudioEventEmitter emitter) + { + return new Task() + { + type = Type.EmitterClearEvent, + Data = new string[] { emitter.Event }, + }; + } + +#if UNITY_TIMELINE_EXIST + public static Task ClearEventName(FMODEventPlayable playable) + { + return new Task() + { + type = Type.PlayableClearEventName, + Data = new string[] { playable.eventName }, + }; + } +#endif + + public static Task MoveEventToEventReference(StudioEventEmitter emitter) + { + return new Task() + { + type = Type.EmitterMoveEventToEventReference, + Data = new string[] { emitter.Event }, + }; + } + + +#if UNITY_TIMELINE_EXIST + public static Task MoveEventNameToEventReference(FMODEventPlayable playable) + { + return new Task() + { + type = Type.PlayableMoveEventNameToEventReference, + Data = new string[] { playable.eventName }, + }; + } +#endif + + public static Task MoveEventOverrideToEventReference(StudioEventEmitter emitter) + { + return new Task() + { + type = Type.EmitterMoveEventOverrideToEventReference, + Data = new string[] { emitter.Event }, + }; + } +#pragma warning restore 0618 + + public static Task RemoveEventRefField(string subObjectPath, string value, string fieldName, string targetType) + { + return new Task() + { + type = Type.GenericRemoveEventRefField, + Data = new string[] { subObjectPath, value, fieldName, targetType }, + }; + } + + public static Task RemoveEmptyEventRefField(string subObjectPath, string fieldName, string targetType) + { + return new Task() + { + type = Type.GenericRemoveEmptyEventRefField, + Data = new string[] { subObjectPath, fieldName, targetType }, + }; + } + + public static Task MoveEventRefFieldToEventReferenceField( + string subObjectPath, string value, string oldFieldName, string newFieldName) + { + return new Task() + { + type = Type.GenericMoveEventRefFieldToEventReferenceField, + Data = new string[] { subObjectPath, value, oldFieldName, newFieldName }, + }; + } + + public static Task AddMigrationTarget(string subObjectPath, string value, string fieldName, string targetType, + string targetName = null) + { + return new Task() + { + type = Type.GenericAddMigrationTarget, + Data = new string[] { subObjectPath, value, fieldName, targetType, targetName }, + }; + } + + public static Task UpdateEventReferencePath(string subObjectPath, string fieldName, + string oldPath, string newPath, FMOD.GUID guid) + { + return new Task() + { + type = Type.GenericUpdateEventReferencePath, + Data = new string[] { subObjectPath, fieldName, oldPath, newPath, guid.ToString() }, + }; + } + + public static Task UpdateEventReferenceGuid(string subObjectPath, string fieldName, + FMOD.GUID oldGuid, FMOD.GUID newGuid, string path) + { + return new Task() + { + type = Type.GenericUpdateEventReferenceGuid, + Data = new string[] { subObjectPath, fieldName, oldGuid.ToString(), newGuid.ToString(), path }, + }; + } + + public static Task FixMigrationTargetConflict(string subObjectPath, string targetType, + IEnumerable fieldNames) + { + return new Task() + { + type = Type.GenericFixMigrationTargetConflict, + Data = (new string[] { subObjectPath, targetType }).Concat(fieldNames).ToArray(), + }; + } + + private struct Delegates + { + public DescriptionDelegate Description; + public ManualInstructionsDelegate ManualInstructions; + public IsValidDelegate IsValid; + public ExecuteDelegate Execute; + } + + private static void Implement(Type type, + DescriptionDelegate Description, + IsValidDelegate IsValid, + ExecuteDelegate Execute, + ManualInstructionsDelegate ManualInstructions = null) + { + Implementations[(int)type] = new Delegates() { + Description = Description, + IsValid = IsValid, + Execute = Execute, + ManualInstructions = ManualInstructions, + }; + } + + private Delegates GetDelegates() + { + return Implementations[(int)type]; + } + + static Task() + { + Implementations = new Delegates[(int)Type.Count]; + + // Suppress warnings about using the obsolete StudioEventEmitter.Event + // and FMODEventPlayable.eventName fields +#pragma warning disable 0618 + + Implement(Type.EmitterClearEvent, + Description: (data) => { + return string.Format("Clear '{0}' from the {1} field", data[0], EmitterEventField); + }, + IsValid: (data, target) => { + StudioEventEmitter emitter = target as StudioEventEmitter; + return emitter != null && emitter.Event == data[0] && !emitter.EventReference.IsNull; + }, + Execute: (data, target) => { + StudioEventEmitter emitter = target as StudioEventEmitter; + + emitter.Event = string.Empty; + EditorUtility.SetDirty(emitter); + } + ); + Implement(Type.EmitterMoveEventToEventReference, + Description: (data) => { + return string.Format("Move '{0}' from {1} to {2}", + data[0], EmitterEventField, EmitterEventReferenceField); + }, + IsValid: (data, target) => { + StudioEventEmitter emitter = target as StudioEventEmitter; + return emitter != null && emitter.Event == data[0] && emitter.EventReference.IsNull; + }, + Execute: (data, target) => { + StudioEventEmitter emitter = target as StudioEventEmitter; + + emitter.EventReference.Path = emitter.Event; + emitter.Event = string.Empty; + + EditorEventRef eventRef = EventManager.EventFromPath(emitter.EventReference.Path); + + if (eventRef != null) + { + emitter.EventReference.Guid = eventRef.Guid; + } + + EditorUtility.SetDirty(emitter); + } + ); + Implement(Type.EmitterMoveEventOverrideToEventReference, + Description: (data) => { + return string.Format("Move prefab override '{0}' from {1} to {2}", + data[0], EmitterEventField, EmitterEventReferenceField); + }, + IsValid: (data, target) => { + if (!PrefabUtility.IsPartOfPrefabInstance(target)) + { + return false; + } + + StudioEventEmitter emitter = target as StudioEventEmitter; + + if (emitter == null) + { + return false; + } + + StudioEventEmitter sourceEmitter = PrefabUtility.GetCorrespondingObjectFromSource(emitter); + + if (sourceEmitter == null) + { + return false; + } + + PropertyModification[] modifications = PrefabUtility.GetPropertyModifications(emitter); + PropertyModification eventOverride = modifications.FirstOrDefault( + m => m.target == sourceEmitter && m.propertyPath == "Event"); + + if (eventOverride == null || eventOverride.value != data[0]) + { + return false; + } + + bool hasEventReferenceOverride = modifications.Any( + m => m.target == sourceEmitter && m.propertyPath.StartsWith("EventReference")); + + if (hasEventReferenceOverride) + { + return false; + } + + return true; + }, + Execute: (data, target) => { + StudioEventEmitter emitter = target as StudioEventEmitter; + + string path = emitter.Event; + + // Clear the Event override + StudioEventEmitter sourceEmitter = PrefabUtility.GetCorrespondingObjectFromSource(emitter); + PropertyModification[] modifications = PrefabUtility.GetPropertyModifications(emitter); + + modifications = modifications + .Where(m => !(m.target == sourceEmitter && m.propertyPath == "Event")) + .ToArray(); + + PrefabUtility.SetPropertyModifications(emitter, modifications); + + // Set the EventReference override + emitter.EventReference.Path = path; + + EditorEventRef eventRef = EventManager.EventFromPath(path); + + if (eventRef != null) + { + emitter.EventReference.Guid = eventRef.Guid; + } + + EditorUtility.SetDirty(emitter); + } + ); + +#if UNITY_TIMELINE_EXIST + Implement(Type.PlayableClearEventName, + Description: (data) => { + return string.Format("Clear '{0}' from the {1} field", data[0], PlayableEventNameField); + }, + IsValid: (data, target) => { + FMODEventPlayable playable = target as FMODEventPlayable; + return playable != null && playable.eventName == data[0] && !playable.EventReference.IsNull; + }, + Execute: (data, target) => { + FMODEventPlayable playable = target as FMODEventPlayable; + + playable.eventName = string.Empty; + EditorUtility.SetDirty(playable); + } + ); + Implement(Type.PlayableMoveEventNameToEventReference, + Description: (data) => { + return string.Format("Move '{0}' from {1} to {2}", + data[0], PlayableEventNameField, PlayableEventReferenceField); + }, + IsValid: (data, target) => { + FMODEventPlayable playable = target as FMODEventPlayable; + return playable != null && playable.eventName == data[0] && playable.EventReference.IsNull; + }, + Execute: (data, target) => { + FMODEventPlayable playable = target as FMODEventPlayable; + + playable.EventReference.Path = playable.eventName; + playable.eventName = string.Empty; + + EditorEventRef eventRef = EventManager.EventFromPath(playable.EventReference.Path); + + if (eventRef != null) + { + playable.EventReference.Guid = eventRef.Guid; + } + + EditorUtility.SetDirty(playable); + } + ); +#endif + Implement(Type.GenericRemoveEventRefField, + Description: (data) => { + return string.Format("Remove field {0}", FieldPath(data[0], data[2])); + }, + ManualInstructions: (data, component) => { + string subObjectPath = data[0]; + string value = data[1]; + string fieldName = data[2]; + string targetType = data[3]; + + string fieldPath = FieldPath(subObjectPath, fieldName); + + return string.Format( + "The {0} field on component {1} has value '{2}', " + + "but the corresponding EventReference field already has a value.\n" + + "* Ensure no other instances of the {3} type are using the {4} field\n" + + "* Edit the definition of the {3} type and remove the {4} field", + fieldPath, component.Type, value, targetType, fieldName); + }, + IsValid: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[2]); + + return field != null && IsEventRef(field) && (field.GetValue(target) as string) == data[1]; + }, + Execute: null + ); + Implement(Type.GenericRemoveEmptyEventRefField, + Description: (data) => { + return string.Format("Remove empty field {0}", FieldPath(data[0], data[1])); + }, + ManualInstructions: (data, component) => { + string subObjectPath = data[0]; + string fieldName = data[1]; + string targetType = data[2]; + + string fieldPath = FieldPath(subObjectPath, fieldName); + + return string.Format( + "The {0} field on component {1} is empty.\n" + + "* Ensure no other instances of the {2} type are using the {3} field\n" + + "* Edit the definition of the {2} type and remove the {3} field", + fieldPath, component.Type, targetType, fieldName); + }, + IsValid: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[1]); + + return field != null && IsEventRef(field) + && string.IsNullOrEmpty(field.GetValue(target) as string); + }, + Execute: null + ); + Implement(Type.GenericMoveEventRefFieldToEventReferenceField, + Description: (data) => { + string subObjectPath = data[0]; + string value = data[1]; + string oldFieldPath = FieldPath(subObjectPath, data[2]); + string newFieldPath = FieldPath(subObjectPath, data[3]); + + return string.Format("Move '{0}' from {1} to {2}", + value, oldFieldPath, newFieldPath); + }, + IsValid: (data, rootObject) => { + string subObjectPath = data[0]; + string value = data[1]; + string oldFieldName = data[2]; + string newFieldName = data[3]; + + object target = FindSubObject(rootObject, subObjectPath); + System.Type targetType = target.GetType(); + + FieldInfo oldField = targetType.GetField(oldFieldName, DefaultBindingFlags); + FieldInfo newField = targetType.GetField(newFieldName, DefaultBindingFlags); + + if (oldField == null || newField == null + || !IsEventRef(oldField) + || newField.FieldType != typeof(EventReference)) + { + return false; + } + + string oldValue = oldField.GetValue(target) as string; + EventReference newValue = (EventReference)newField.GetValue(target); + + return oldValue == value && newValue.IsNull; + }, + Execute: (data, rootObject) => { + string subObjectPath = data[0]; + string path = data[1]; + string oldFieldName = data[2]; + string newFieldName = data[3]; + + object target = FindSubObject(rootObject, subObjectPath); + System.Type type = target.GetType(); + + FieldInfo oldField = type.GetField(oldFieldName, DefaultBindingFlags); + FieldInfo newField = type.GetField(newFieldName, DefaultBindingFlags); + + EventReference eventReference = new EventReference() { Path = path }; + + EditorEventRef eventRef = EventManager.EventFromPath(path); + + if (eventRef != null) + { + eventReference.Guid = eventRef.Guid; + } + + oldField.SetValue(target, string.Empty); + newField.SetValue(target, eventReference); + + EditorUtility.SetDirty(rootObject); + } + ); + Implement(Type.GenericAddMigrationTarget, + Description: (data) => { + string value = data[1]; + string fieldPath = FieldPath(data[0], data[2]); + string targetName = data[4]; + + if (!string.IsNullOrEmpty(targetName)) + { + return string.Format( + "Add an EventReference field named {0} to hold '{1}' from {2}", + targetName, value, fieldPath); + } + else + { + return string.Format("Add an EventReference field to hold '{0}' from {1}", + value, fieldPath); + } + }, + ManualInstructions: (data, component) => { + string fieldName = data[2]; + string targetType = data[3]; + string targetName = data[4]; + string fieldPath = FieldPath(data[0], fieldName); + + string script; + + if (targetType != null) + { + script = string.Format("the definition of the {0} type", targetType); + } + else + { + script = component.ScriptPath; + } + + if (!string.IsNullOrEmpty(targetName)) + { + return string.Format( + "The {0} field on component {1} has an [EventRef(MigrateTo=\"{2}\")] " + + "attribute, but the {2} field doesn't exist.\n" + + "* Edit {3} and add an EventReference field named {2}:\n" + + " public EventReference {2};\n" + + "* Re-scan your project", + fieldPath, component.Type, targetName, script); + } + else + { + return string.Format( + "The {0} field on component {1} has an [EventRef] " + + "attribute with no migration target specified.\n" + + "* Edit {2} and add an EventReference field:\n" + + " public EventReference ;\n" + + "* Change the [EventRef] attribute on the {3} field to:\n" + + " [EventRef(MigrateTo=\"\")]\n" + + "* Re-scan your project.", + fieldPath, component.Type, script, fieldName); + } + }, + IsValid: (data, rootObject) => { + string value = data[1]; + string oldFieldName = data[2]; + + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo oldField = targetType.GetField(oldFieldName, DefaultBindingFlags); + + return oldField != null && IsEventRef(oldField) + && (oldField.GetValue(target) as string) == value; + }, + Execute: null + ); + Implement(Type.GenericUpdateEventReferencePath, + Description: (data) => { + return string.Format( + "Change the path on field {0} " + + "from '{1}' to '{2}' (to match GUID {3})", + FieldPath(data[0], data[1]), data[2], data[3], data[4]); + }, + IsValid: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[1], DefaultBindingFlags); + + if (field == null || field.FieldType != typeof(EventReference)) + { + return false; + } + + EventReference value = (EventReference)field.GetValue(target); + + return value.Path == data[2] && value.Guid.ToString() == data[4]; + }, + Execute: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[1], DefaultBindingFlags); + + EventReference value = (EventReference)field.GetValue(target); + value.Path = data[3]; + + field.SetValue(target, value); + + EditorUtility.SetDirty(rootObject); + } + ); + Implement(Type.GenericUpdateEventReferenceGuid, + Description: (data) => { + return string.Format( + "Change the GUID on field {0} " + + "from {1} to {2} (to match path '{3}')", + FieldPath(data[0], data[1]), data[2], data[3], data[4]); + }, + IsValid: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[1], DefaultBindingFlags); + + if (field == null || field.FieldType != typeof(EventReference)) + { + return false; + } + + EventReference value = (EventReference)field.GetValue(target); + + return value.Guid.ToString() == data[2] && value.Path == data[4]; + }, + Execute: (data, rootObject) => { + object target = FindSubObject(rootObject, data[0]); + + System.Type targetType = target.GetType(); + FieldInfo field = targetType.GetField(data[1], DefaultBindingFlags); + + EventReference value = (EventReference)field.GetValue(target); + value.Guid = FMOD.GUID.Parse(data[3]); + + field.SetValue(target, value); + + EditorUtility.SetDirty(rootObject); + } + ); + Implement(Type.GenericFixMigrationTargetConflict, + Description: (data) => { + string subObjectPath = data[0]; + IEnumerable fieldPaths = data.Skip(2).Select(field => FieldPath(subObjectPath, field)); + + return string.Format("Fix conflicting migration targets on fields {0}", + EditorUtils.SeriesString(", ", " and ", fieldPaths)); + }, + ManualInstructions: (data, component) => { + return string.Format( + "Fields {0} on the {1} type have [EventRef] attributes with the same MigrateTo value.\n" + + "* Edit the definition of the {1} type and make sure all [EventRef] attributes have " + + "different MigrateTo values\n" + + "* Re-scan your project", + EditorUtils.SeriesString(", ", " and ", data.Skip(2)), data[1]); + }, + IsValid: (data, target) => { + return true; + }, + Execute: null + ); + +#pragma warning restore 0618 + } + + public override string ToString() + { + return GetDelegates().Description(Data); + } + + public string PlainDescription() + { + return Regex.Replace(ToString(), "", string.Empty); + } + + public string ManualInstructions(Component component) + { + Delegates delegates = GetDelegates(); + + if (delegates.ManualInstructions != null) + { + return delegates.ManualInstructions(Data, component); + } + else + { + return null; + } + } + + public bool CanExecute() + { + return Enabled && !IsManual() && !HasExecuted; + } + + public bool IsManual() + { + return GetDelegates().Execute == null; + } + + public bool IsValid(UnityEngine.Object target) + { + return GetDelegates().IsValid(Data, target); + } + + public bool Execute(UnityEngine.Object target) + { + if (IsValid(target)) + { + Delegates delegates = GetDelegates(); + + if (delegates.Execute != null) + { + delegates.Execute(Data, target); + HasExecuted = true; + } + + return true; + } + else + { + return false; + } + } + } + + private static string FieldPath(string subObjectPath, string fieldName) + { + if (subObjectPath != null) + { + return string.Format("{0}.{1}", subObjectPath, fieldName); + } + else + { + return fieldName; + } + } + + private static string FieldPath(string subObjectPath, string fieldName, int index) + { + if (subObjectPath != null) + { + return string.Format("{0}.{1}[{2}]", subObjectPath, fieldName, index); + } + else + { + return string.Format("{0}[{1}]", fieldName, index); + } + } + + private static object FindSubObject(object o, string path) + { + if (path == null) + { + return o; + } + + object result = o; + + foreach (string pathElement in path.Split('.')) + { + Type type = result.GetType(); + + Regex regex = new Regex(@"(\w+)\[(\d+)\]$"); + Match match = regex.Match(pathElement); + int index = -1; + string fieldName = pathElement; + + if (match.Success) + { + fieldName = match.Groups[1].Value; + index = int.Parse(match.Groups[2].Value); + } + + FieldInfo field = type.GetField(fieldName, DefaultBindingFlags); + + if (field == null) + { + return null; + } + + result = field.GetValue(result); + + if (index >= 0) + { + System.Collections.IEnumerable enumerable = result as System.Collections.IEnumerable; + + result = null; + + if (enumerable != null) + { + int i = 0; + + foreach (object obj in enumerable) + { + if (index == i) + { + result = obj; + break; + } + i++; + } + } + } + + if (result == null) + { + return null; + } + } + + return result; + } + + private void ExecuteTask(Task task, SavePolicy savePolicy) + { + Asset asset = assets[task.AssetIndex]; + + if (asset.Type == AssetType.ScriptableObject) + { + ExecuteScriptableObjectTask(task, savePolicy); + } + else + { + ExecuteGameObjectTask(task, savePolicy); + } + } + + private void ExecuteScriptableObjectTask(Task task, SavePolicy savePolicy) + { + Asset asset = assets[task.AssetIndex]; + Component component = components[task.ComponentIndex]; + + IEnumerable scriptableObjects = + AssetDatabase.LoadAllAssetsAtPath(asset.Path).OfType(); + + foreach (ScriptableObject scriptableObject in scriptableObjects) + { + if (scriptableObject.GetType().Name == component.Type) + { + if (task.Execute(scriptableObject)) + { + break; + } + } + } + } + + private void ExecuteGameObjectTask(Task task, SavePolicy savePolicy) + { + GameObject gameObject = LoadTargetGameObject(task, savePolicy); + + if (gameObject == null) + { + return; + } + + Selection.activeGameObject = gameObject; + EditorGUIUtility.PingObject(gameObject); + + Component component = components[task.ComponentIndex]; + + foreach (MonoBehaviour behaviour in gameObject.GetComponents()) + { + if (behaviour.GetType().Name == component.Type) + { + if (task.Execute(behaviour)) + { + break; + } + } + } + } + + private enum SavePolicy + { + AskToSave, + AutoSave, + } + + private GameObject LoadTargetGameObject(Task task, SavePolicy savePolicy) + { + Asset asset = assets[task.AssetIndex]; + Component component = components[task.ComponentIndex]; + + if (IsPrefab(asset.Type)) + { + GameObject prefab = AssetDatabase.LoadAssetAtPath(asset.Path); + + if (prefab == null) + { + return null; + } + + if (!AssetDatabase.OpenAsset(prefab)) + { + return null; + } + + return GlobalObjectId.GlobalObjectIdentifierToObjectSlow(component.GameObjectID) as GameObject; + } + else if (asset.Type == AssetType.Scene) + { + Scene scene = SceneManager.GetSceneByPath(asset.Path); + + if (!scene.IsValid()) + { + if (savePolicy == SavePolicy.AskToSave) + { + if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) + { + return null; + } + } + else if (savePolicy == SavePolicy.AutoSave) + { + EditorSceneManager.SaveOpenScenes(); + } + else + { + throw new ArgumentException("Unrecognized SavePolicy: " + savePolicy, "savePolicy"); + } + + scene = EditorSceneManager.OpenScene(asset.Path, OpenSceneMode.Single); + + if (!scene.IsValid()) + { + return null; + } + } + + return GlobalObjectId.GlobalObjectIdentifierToObjectSlow(component.GameObjectID) as GameObject; + } + else + { + return null; + } + } + + private int AddAsset(AssetType type, string path) + { + Asset asset = new Asset() { + Type = type, + Path = path, + }; + + assets.Add(asset); + + return assets.Count - 1; + } + + private int AddComponent(MonoBehaviour behaviour, GameObject root) + { + MonoScript script = MonoScript.FromMonoBehaviour(behaviour); + + Component component = new Component() { + GameObjectID = GlobalObjectId.GetGlobalObjectIdSlow(behaviour.gameObject), + Type = behaviour.GetType().Name, + Path = EditorUtils.GameObjectPath(behaviour, root), + ScriptPath = AssetDatabase.GetAssetPath(script), + }; + + components.Add(component); + + return components.Count - 1; + } + + private int AddComponent(ScriptableObject scriptableObject) + { + MonoScript script = MonoScript.FromScriptableObject(scriptableObject); + + Component component = new Component() { + Type = scriptableObject.GetType().Name, + ScriptPath = AssetDatabase.GetAssetPath(script), + }; + + components.Add(component); + + return components.Count - 1; + } + + private void UpdateExecutableTaskCount() + { + executableTaskCount = tasks.Count(t => t.CanExecute()); + } + + private void AddTask(Task task) + { + tasks.Add(task); + UpdateExecutableTaskCount(); + taskView.Reload(); + taskView.ExpandAll(); + } + + private void UpdateProcessing() + { + if (processingState != null) + { + if (processingState.MoveNext()) + { + SetStatus(processingState.Current); + } + else + { + StopProcessing(true); + } + + Repaint(); + } + } + + private void OnEnable() + { + taskView = new TaskView(taskViewState, tasks, assets, components); + taskView.Reload(); + taskView.taskSelected += OnTaskSelected; + taskView.taskDoubleClicked += OnTaskDoubleClicked; + taskView.taskEnableStateChanged += OnTaskEnableStateChanged; + taskView.assetEnableStateChanged += ApplyAssetEnableStateToTasks; + + EditorApplication.update += UpdateProcessing; + } + + private void OnDisable() + { + EditorApplication.update -= UpdateProcessing; + } + + private void OnTaskSelected(Task task) + { + selectedTask = task; + } + + private void OnTaskDoubleClicked(Task task) + { + Asset asset = assets[task.AssetIndex]; + + if (asset.Type == AssetType.ScriptableObject) + { + UnityEngine.Object target = AssetDatabase.LoadAssetAtPath(asset.Path); + + if (target == null) + { + return; + } + + if (!AssetDatabase.OpenAsset(target)) + { + return; + } + + Component component = components[task.ComponentIndex]; + + IEnumerable scriptableObjects = + AssetDatabase.LoadAllAssetsAtPath(asset.Path).OfType(); + + foreach (ScriptableObject scriptableObject in scriptableObjects) + { + if (scriptableObject.GetType().Name == component.Type + && task.IsValid(scriptableObject)) + { + Selection.activeObject = scriptableObject; + } + } + } + else + { + GameObject gameObject = LoadTargetGameObject(task, SavePolicy.AskToSave); + + if (gameObject == null) + { + return; + } + + Selection.activeGameObject = gameObject; + EditorGUIUtility.PingObject(gameObject); + } + } + + private void OnTaskEnableStateChanged(Task task) + { + UpdateAssetEnableState(task.AssetIndex); + UpdateExecutableTaskCount(); + } + + private void UpdateAssetEnableState(int assetIndex) + { + Asset asset = assets[assetIndex]; + + asset.EnableState = tasks + .Where(t => t.AssetIndex == assetIndex) + .Select(t => t.Enabled ? EnableState.Enabled : EnableState.Disabled) + .Aggregate((current, next) => (current == next) ? current : EnableState.Mixed); + } + + private void ApplyAssetEnableStateToTasks(Asset asset) + { + int assetIndex = assets.IndexOf(asset); + + foreach (Task task in tasks.Where(t => t.AssetIndex == assetIndex)) + { + task.Enabled = (asset.EnableState == EnableState.Enabled); + } + + UpdateExecutableTaskCount(); + } + + private class Styles + { + public static GUIStyle RichText; + public static GUIStyle RichTextBox; + public static GUIStyle TreeViewRichText; + + private static bool Initialized = false; + + public static void Affirm() + { + if (!Initialized) + { + Initialized = true; + + RichText = new GUIStyle(GUI.skin.label) { richText = true }; + RichTextBox = new GUIStyle(EditorStyles.helpBox) { richText = true }; + TreeViewRichText = new GUIStyle(TreeView.DefaultStyles.label) { richText = true }; + } + } + } + + private class Icons + { + public static Texture2D Scene; + public static Texture2D Prefab; + public static Texture2D PrefabModel; + public static Texture2D PrefabVariant; + public static Texture2D ScriptableObject; + public static Texture2D GameObject; + + private static bool Initialized = false; + + public static void Affirm() + { + if (!Initialized) + { + Initialized = true; + + Scene = EditorGUIUtility.IconContent("SceneAsset Icon").image as Texture2D; + Prefab = EditorGUIUtility.IconContent("Prefab Icon").image as Texture2D; + PrefabModel = EditorGUIUtility.IconContent("PrefabModel Icon").image as Texture2D; + PrefabVariant = EditorGUIUtility.IconContent("PrefabVariant Icon").image as Texture2D; + ScriptableObject = EditorGUIUtility.IconContent("ScriptableObject Icon").image as Texture2D; + GameObject = EditorGUIUtility.IconContent("GameObject Icon").image as Texture2D; + } + } + + public static Texture2D GetAssetIcon(AssetType type) + { + Affirm(); + + if (type == AssetType.Scene) + { + return Scene; + } + else if (type == AssetType.Prefab) + { + return Prefab; + } + else if (type == AssetType.PrefabModel) + { + return PrefabModel; + } + else if (type == AssetType.PrefabVariant) + { + return PrefabVariant; + } + else if (type == AssetType.ScriptableObject) + { + return ScriptableObject; + } + else + { + throw new ArgumentException("Unrecognized AssetType: " + type, "type"); + } + } + + public static Texture2D GetComponentIcon(Component component) + { + return AssetDatabase.GetCachedIcon(component.ScriptPath) as Texture2D; + } + } + + private void SetStatus(string text) + { + status = new GUIContent(text, EditorGUIUtility.IconContent("console.infoicon.sml").image); + } + + private void OnGUI() + { + Styles.Affirm(); + + float buttonHeight = EditorGUIUtility.singleLineHeight * 2; + + // Task List + using (var scope = new EditorGUILayout.VerticalScope(GUILayout.ExpandHeight(true))) + { + taskView.DrawLayout(scope.rect); + } + + // Selected Task + if (selectedTask != null) + { + Asset asset = assets[selectedTask.AssetIndex]; + Component component = components[selectedTask.ComponentIndex]; + + DrawSelectableLabel(selectedTask.PlainDescription(), EditorStyles.wordWrappedLabel); + + using (new EditorGUI.IndentLevelScope()) + { + EditorGUILayout.LabelField(AssetContent, + new GUIContent(asset.Path, Icons.GetAssetIcon(asset.Type))); + EditorGUILayout.LabelField(ComponentTypeContent, + new GUIContent(component.Type, Icons.GetComponentIcon(component))); + + if (!string.IsNullOrEmpty(component.Path)) + { + EditorGUILayout.LabelField(GameObjectContent, new GUIContent(component.Path, Icons.GameObject)); + } + + if (selectedTask.IsManual()) + { + Rect buttonsRect = EditorGUILayout.GetControlRect(false, buttonHeight); + buttonsRect = EditorGUI.IndentedRect(buttonsRect); + + GUIContent openScriptContent = new GUIContent("Open " + component.ScriptPath); + + Rect openScriptRect = buttonsRect; + openScriptRect.width = GUI.skin.button.CalcSize(openScriptContent).x; + + if (GUI.Button(openScriptRect, openScriptContent)) + { + MonoScript script = AssetDatabase.LoadAssetAtPath(component.ScriptPath); + AssetDatabase.OpenAsset(script); + } + + GUIContent viewDocumentationContent = new GUIContent("View Documentation"); + + Rect viewDocumentationRect = buttonsRect; + viewDocumentationRect.x = openScriptRect.xMax + GUI.skin.button.margin.left; + viewDocumentationRect.width = GUI.skin.button.CalcSize(viewDocumentationContent).x; + + if (GUI.Button(viewDocumentationRect, viewDocumentationContent)) + { + EditorUtils.OpenOnlineDocumentation("unity", "tools", "manual-tasks"); + } + + using (var scope = new EditorGUILayout.ScrollViewScope(manualDescriptionScrollPosition, GUILayout.Height(100))) + { + manualDescriptionScrollPosition = scope.scrollPosition; + + DrawSelectableLabel(selectedTask.ManualInstructions(component), EditorStyles.wordWrappedLabel); + } + } + else + { + GUIContent buttonContent = new GUIContent("Execute"); + + Rect buttonRect = EditorGUILayout.GetControlRect(false, buttonHeight); + buttonRect.width = EditorGUIUtility.labelWidth; + buttonRect = EditorGUI.IndentedRect(buttonRect); + + if (GUI.Button(buttonRect, buttonContent)) + { + ExecuteTask(selectedTask, SavePolicy.AskToSave); + } + } + } + } + + // Status + if (IsProcessing) + { + DrawProgressBar("Prefabs", prefabProgress); + DrawProgressBar("ScriptableObjects", scriptableObjectProgress); + DrawProgressBar("Scenes", sceneProgress); + } + + GUILayout.Label(status, Styles.RichTextBox); + + // Buttons + using (new EditorGUILayout.HorizontalScope()) + { + if (GUILayout.Button("Cancel", GUILayout.Height(buttonHeight))) + { + Cancel(); + } + + using (new EditorGUI.DisabledScope(IsProcessing)) + { + if (GUILayout.Button(SearchButtonText, GUILayout.Height(buttonHeight))) + { + BeginSearching(); + } + + using (new EditorGUI.DisabledScope(executableTaskCount == 0)) + { + if (GUILayout.Button(ExecuteButtonText(), GUILayout.Height(buttonHeight))) + { + BeginExecuting(); + } + } + } + } + + if (focusedWindow == this + && Event.current.type == EventType.KeyDown + && Event.current.keyCode == KeyCode.Escape) + { + Cancel(); + Event.current.Use(); + } + } + + private static void DrawProgressBar(string label, SearchProgress progress) + { + Rect rect = EditorGUILayout.GetControlRect(); + EditorGUI.ProgressBar(rect, progress.Fraction(), label); + } + + private static void DrawSelectableLabel(string text, GUIStyle style) + { + float height = style.CalcHeight(new GUIContent(text), EditorGUIUtility.currentViewWidth); + + EditorGUILayout.SelectableLabel(text, style, GUILayout.Height(height)); + } + + private class TaskView : TreeView + { + private List tasks; + private List assets; + private List components; + + public delegate void TaskEventHandler(Task task); + + public event TaskEventHandler taskSelected; + public event TaskEventHandler taskDoubleClicked; + public event TaskEventHandler taskEnableStateChanged; + + public delegate void AssetEventHandler(Asset asset); + + public event AssetEventHandler assetEnableStateChanged; + + public TaskView(TreeViewState state, List tasks, List assets, List components) + : base(state, new MultiColumnHeader(CreateHeaderState())) + { + this.tasks = tasks; + this.assets = assets; + this.components = components; + + showAlternatingRowBackgrounds = true; + showBorder = true; + + multiColumnHeader.ResizeToFit(); + } + + public static MultiColumnHeaderState CreateHeaderState() + { + MultiColumnHeaderState.Column[] columns = new MultiColumnHeaderState.Column[] { + new MultiColumnHeaderState.Column() + { + headerContent = new GUIContent("Target"), + width = 225, + autoResize = false, + allowToggleVisibility = false, + canSort = false, + }, + new MultiColumnHeaderState.Column() { + headerContent = new GUIContent("Task"), + autoResize = true, + allowToggleVisibility = false, + canSort = false, + }, + new MultiColumnHeaderState.Column() + { + headerContent = new GUIContent("Status"), + width = 175, + autoResize = false, + allowToggleVisibility = false, + canSort = false, + } + }; + + return new MultiColumnHeaderState(columns); + } + + public void DrawLayout(Rect rect) + { + extraSpaceBeforeIconAndLabel = ToggleWidth(); + + OnGUI(rect); + } + + public enum Column + { + Asset, + Task, + Status, + } + + private class AssetItem : TreeViewItem + { + public Asset asset; + } + + private class TaskItem : TreeViewItem + { + public Task task; + } + + protected override TreeViewItem BuildRoot() + { + TreeViewItem root = new TreeViewItem(-1, -1); + + if (tasks.Count > 0) + { + int index = 0; + + AssetItem assetItem = null; + + foreach (Task task in tasks) + { + Asset asset = assets[task.AssetIndex]; + + if (assetItem == null || assetItem.asset != asset) + { + assetItem = new AssetItem() { + id = index++, + asset = asset, + displayName = asset.Path, + icon = Icons.GetAssetIcon(asset.Type), + }; + + root.AddChild(assetItem); + } + + TreeViewItem taskItem = new TaskItem() { + id = index++, + task = task, + }; + + assetItem.AddChild(taskItem); + } + } + else + { + TreeViewItem item = new TreeViewItem(0); + item.displayName = "No tasks."; + + root.AddChild(item); + } + + SetupDepthsFromParentsAndChildren(root); + + return root; + } + + protected override bool CanMultiSelect(TreeViewItem item) + { + return false; + } + + protected override void SelectionChanged(IList selectedIds) + { + base.SelectionChanged(selectedIds); + + if (taskSelected != null) + { + if (selectedIds.Count > 0) + { + TaskItem item = FindItem(selectedIds[0], rootItem) as TaskItem; + + if (item != null) + { + taskSelected(item.task); + return; + } + } + + taskSelected(null); + } + } + + protected override void SingleClickedItem(int id) + { + TreeViewItem item = FindItem(id, rootItem); + + if (!(item is TaskItem)) + { + SetExpanded(id, !IsExpanded(id)); + } + else + { + base.SingleClickedItem(id); + } + } + + protected override void DoubleClickedItem(int id) + { + if (taskDoubleClicked != null) + { + TaskItem item = FindItem(id, rootItem) as TaskItem; + + if (item == null) + { + return; + } + + taskDoubleClicked(item.task); + } + } + + protected override void RowGUI(RowGUIArgs args) + { + TreeViewItem item = args.item; + + if (item is TaskItem) + { + Task task = (item as TaskItem).task; + + Rect toggleRect = args.rowRect; + toggleRect.x = GetContentIndent(item); + toggleRect.width = ToggleWidth(); + + TaskToggle(toggleRect, task); + + for (int i = 0; i < args.GetNumVisibleColumns(); ++i) + { + Rect rect = args.GetCellRect(i); + + if (i == 0) + { + rect.xMin = toggleRect.xMax; + } + + CellGUI(rect, task, args.GetColumn(i), args.selected, args.focused); + } + } + else if (item is AssetItem) + { + base.RowGUI(args); + + Rect rect = args.rowRect; + rect.x = GetContentIndent(item); + rect.width = ToggleWidth(); + + AssetToggle(rect, (item as AssetItem).asset); + } + else + { + base.RowGUI(args); + } + } + + private static float ToggleWidth() + { + return GUI.skin.toggle.CalcSize(GUIContent.none).x; + } + + private void AssetToggle(Rect rect, Asset asset) + { + using (var scope = new EditorGUI.ChangeCheckScope()) + { + EditorGUI.showMixedValue = (asset.EnableState == EnableState.Mixed); + + bool enabled = EditorGUI.Toggle(rect, asset.EnableState == EnableState.Enabled); + + EditorGUI.showMixedValue = false; + + if (scope.changed) + { + asset.EnableState = enabled ? EnableState.Enabled : EnableState.Disabled; + + if (assetEnableStateChanged != null) + { + assetEnableStateChanged(asset); + } + } + } + } + + private void TaskToggle(Rect rect, Task task) + { + if (!task.IsManual()) + { + using (var scope = new EditorGUI.ChangeCheckScope()) + { + task.Enabled = EditorGUI.Toggle(rect, task.Enabled); + + if (scope.changed && taskEnableStateChanged != null) + { + taskEnableStateChanged(task); + } + } + } + } + + private void CellGUI(Rect rect, Task task, int columnIndex, bool selected, bool focused) + { + Component component = components[task.ComponentIndex]; + + switch ((Column)columnIndex) + { + case Column.Asset: + if (Event.current.type == EventType.Repaint) + { + Texture2D typeIcon = Icons.GetComponentIcon(components[task.ComponentIndex]); + + using (new GUI.GroupScope(rect)) + { + Rect iconRect = new Rect(0, 0, rect.height, rect.height); + + GUI.DrawTexture(iconRect, typeIcon, ScaleMode.ScaleToFit); + + GUIContent type = new GUIContent(component.Type); + + bool hasGameObjectPath = !string.IsNullOrEmpty(component.Path); + + if (hasGameObjectPath) + { + type.text += " on"; + } + + Rect typeRect = new Rect(iconRect.xMax, 0, + DefaultStyles.label.CalcSize(type).x, rect.height); + + DefaultGUI.Label(typeRect, type.text, selected, focused); + + if (hasGameObjectPath) + { + iconRect.x = typeRect.xMax; + + GUI.DrawTexture(iconRect, Icons.GameObject, ScaleMode.ScaleToFit); + + GUIContent gameObject = new GUIContent(component.Path); + + Rect gameObjectRect = new Rect(iconRect.xMax, 0, + DefaultStyles.label.CalcSize(gameObject).x, rect.height); + + DefaultGUI.Label(gameObjectRect, gameObject.text, selected, focused); + } + } + } + + break; + case Column.Task: + if (Event.current.type == EventType.Repaint) + { + string text = task.ToString(); + + if (task.IsManual()) + { + text = "Manual task: " + text; + } + + Styles.TreeViewRichText.Draw(rect, text, false, false, selected, focused); + } + break; + case Column.Status: + if (Event.current.type == EventType.Repaint) + { + if (task.IsManual()) + { + DefaultGUI.Label(rect, "Manual Changes Required", selected, focused); + } + else + { + DefaultGUI.Label(rect, task.HasExecuted ? "Complete" : "Pending", selected, focused); + } + } + break; + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs.meta b/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs.meta new file mode 100644 index 0000000..8c44239 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0b58df65bd3bb6649801b24a7a942ccb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs b/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs new file mode 100644 index 0000000..26cacd7 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs @@ -0,0 +1,501 @@ +#if UNITY_TIMELINE_EXIST + +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.Timeline; +using UnityEngine; +using UnityEngine.Timeline; +using System; +using System.Linq; +using System.Reflection; + +namespace FMODUnity +{ + [CustomEditor(typeof(FMODEventPlayable))] + public class FMODEventPlayableEditor : Editor + { + private FMODEventPlayable eventPlayable; + private EditorEventRef editorEventRef; + private List missingInitialParameterValues = new List(); + private List missingParameterAutomations = new List(); + + private SerializedProperty parametersProperty; + private SerializedProperty parameterLinksProperty; + private SerializedProperty parameterAutomationProperty; + + private ListView parameterLinksView; + private ListView initialParameterValuesView; + + private string eventPath; + + public void OnEnable() + { + eventPlayable = target as FMODEventPlayable; + + parametersProperty = serializedObject.FindProperty("Parameters"); + parameterLinksProperty = serializedObject.FindProperty("Template.ParameterLinks"); + parameterAutomationProperty = serializedObject.FindProperty("Template.ParameterAutomation"); + + parameterLinksView = new ListView(parameterLinksProperty); + parameterLinksView.drawElementWithLabelCallback = DrawParameterLink; + parameterLinksView.onCanAddCallback = (list) => missingParameterAutomations.Count > 0; + parameterLinksView.onAddDropdownCallback = DoAddParameterLinkMenu; + parameterLinksView.onRemoveCallback = (list) => DeleteParameterAutomation(list.index); + + initialParameterValuesView = new ListView(parametersProperty); + initialParameterValuesView.drawElementWithLabelCallback = DrawInitialParameterValue; + initialParameterValuesView.onCanAddCallback = (list) => missingInitialParameterValues.Count > 0; + initialParameterValuesView.onAddDropdownCallback = DoAddInitialParameterValueMenu; + initialParameterValuesView.onRemoveCallback = (list) => DeleteInitialParameterValue(list.index); + + RefreshEventRef(); + + Undo.undoRedoPerformed += OnUndoRedo; + } + + public void OnDestroy() + { + Undo.undoRedoPerformed -= OnUndoRedo; + } + + private void OnUndoRedo() + { + RefreshMissingParameterLists(); + + // This is in case the undo/redo modified any curves on the Playable's clip + RefreshTimelineEditor(); + } + + private void RefreshEventRef() + { + if (eventPath != eventPlayable.EventReference.Path) + { + eventPath = eventPlayable.EventReference.Path; + + if (!string.IsNullOrEmpty(eventPath)) + { + editorEventRef = EventManager.EventFromPath(eventPath); + } + else + { + editorEventRef = null; + } + + if (editorEventRef != null) + { + eventPlayable.UpdateEventDuration( + editorEventRef.IsOneShot ? editorEventRef.Length : float.PositiveInfinity); + } + + ValidateParameterSettings(); + RefreshMissingParameterLists(); + } + } + + private void ValidateParameterSettings() + { + if (editorEventRef != null) + { + List namesToDelete = new List(); + + for (int i = 0; i < parametersProperty.arraySize; ++i) + { + SerializedProperty current = parametersProperty.GetArrayElementAtIndex(i); + SerializedProperty name = current.FindPropertyRelative("Name"); + + EditorParamRef paramRef = editorEventRef.LocalParameters.FirstOrDefault(p => p.Name == name.stringValue); + + if (paramRef != null) + { + SerializedProperty value = current.FindPropertyRelative("Value"); + value.floatValue = Mathf.Clamp(value.floatValue, paramRef.Min, paramRef.Max); + } + else + { + namesToDelete.Add(name.stringValue); + } + } + + foreach(string name in namesToDelete) + { + DeleteInitialParameterValue(name); + } + + namesToDelete.Clear(); + + for (int i = 0; i < parameterLinksProperty.arraySize; ++i) + { + SerializedProperty current = parameterLinksProperty.GetArrayElementAtIndex(i); + SerializedProperty name = current.FindPropertyRelative("Name"); + + if (!editorEventRef.LocalParameters.Any(p => p.Name == name.stringValue)) + { + namesToDelete.Add(name.stringValue); + } + } + + foreach(string name in namesToDelete) + { + DeleteParameterAutomation(name); + } + } + } + + private void RefreshMissingParameterLists() + { + if (editorEventRef != null) + { + serializedObject.Update(); + + missingInitialParameterValues = + editorEventRef.LocalParameters.Where(p => !InitialParameterValueExists(p.Name)).ToList(); + missingParameterAutomations = + editorEventRef.LocalParameters.Where(p => !ParameterLinkExists(p.Name)).ToList(); + } + else + { + missingInitialParameterValues.Clear(); + missingParameterAutomations.Clear(); + } + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + RefreshEventRef(); + + var eventReference = serializedObject.FindProperty("EventReference"); + var stopType = serializedObject.FindProperty("StopType"); + + const string EventReferenceLabel = "Event"; + + EditorUtils.DrawLegacyEvent(serializedObject.FindProperty("eventName"), EventReferenceLabel); + + EditorGUILayout.PropertyField(eventReference, new GUIContent(EventReferenceLabel)); + EditorGUILayout.PropertyField(stopType, new GUIContent("Stop Mode")); + + DrawInitialParameterValues(); + DrawParameterAutomations(); + + eventPlayable.OnValidate(); + + serializedObject.ApplyModifiedProperties(); + } + + private void DrawInitialParameterValues() + { + if (editorEventRef != null) + { + parametersProperty.isExpanded = + EditorGUILayout.Foldout(parametersProperty.isExpanded, "Initial Parameter Values", true); + + if (parametersProperty.isExpanded) + { + initialParameterValuesView.DrawLayout(); + } + } + } + + private void DoAddInitialParameterValueMenu(Rect rect, UnityEditorInternal.ReorderableList list) + { + GenericMenu menu = new GenericMenu(); + menu.AddItem(new GUIContent("All"), false, () => + { + foreach (EditorParamRef parameter in missingInitialParameterValues) + { + AddInitialParameterValue(parameter); + } + }); + + menu.AddSeparator(string.Empty); + + foreach (EditorParamRef parameter in missingInitialParameterValues) + { + string text = parameter.Name; + + if (ParameterLinkExists(parameter.Name)) + { + text += " (automated)"; + } + + menu.AddItem(new GUIContent(text), false, + (userData) => + { + AddInitialParameterValue(userData as EditorParamRef); + }, + parameter); + } + + menu.DropDown(rect); + } + + private void DrawInitialParameterValue(Rect rect, float labelRight, int index, bool active, bool focused) + { + if (editorEventRef == null) + { + return; + } + + SerializedProperty property = parametersProperty.GetArrayElementAtIndex(index); + + string name = property.FindPropertyRelative("Name").stringValue; + + EditorParamRef paramRef = editorEventRef.LocalParameters.FirstOrDefault(p => p.Name == name); + + if (paramRef == null) + { + return; + } + + Rect nameLabelRect = rect; + nameLabelRect.xMax = labelRight; + + Rect sliderRect = rect; + sliderRect.xMin = nameLabelRect.xMax; + + SerializedProperty valueProperty = property.FindPropertyRelative("Value"); + + GUI.Label(nameLabelRect, name); + + using (new NoIndentScope()) + { + valueProperty.floatValue = + EditorGUI.Slider(sliderRect, valueProperty.floatValue, paramRef.Min, paramRef.Max); + } + } + + private void DrawParameterAutomations() + { + if (editorEventRef != null) + { + parameterLinksProperty.isExpanded = + EditorGUILayout.Foldout(parameterLinksProperty.isExpanded, "Parameter Automations", true); + + if (parameterLinksProperty.isExpanded) + { + parameterLinksView.DrawLayout(); + } + } + } + + private void DoAddParameterLinkMenu(Rect rect, UnityEditorInternal.ReorderableList list) + { + GenericMenu menu = new GenericMenu(); + menu.AddItem(new GUIContent("All"), false, () => + { + foreach (EditorParamRef parameter in missingParameterAutomations) + { + AddParameterAutomation(parameter.Name); + } + }); + + menu.AddSeparator(string.Empty); + + foreach (EditorParamRef parameter in missingParameterAutomations) + { + string text = parameter.Name; + + if (InitialParameterValueExists(parameter.Name)) + { + text += " (has initial value)"; + } + + menu.AddItem(new GUIContent(text), false, + (userData) => + { + AddParameterAutomation(userData as string); + }, + parameter.Name); + } + + menu.DropDown(rect); + } + + private void DrawParameterLink(Rect rect, float labelRight, int index, bool active, bool focused) + { + if (editorEventRef == null) + { + return; + } + + SerializedProperty linkProperty = parameterLinksProperty.GetArrayElementAtIndex(index); + + string name = linkProperty.FindPropertyRelative("Name").stringValue; + + EditorParamRef paramRef = editorEventRef.LocalParameters.FirstOrDefault(p => p.Name == name); + + if (paramRef == null) + { + return; + } + + int slot = linkProperty.FindPropertyRelative("Slot").intValue; + + string slotName = string.Format("Slot{0:D2}", slot); + SerializedProperty valueProperty = parameterAutomationProperty.FindPropertyRelative(slotName); + + GUIStyle slotStyle = GUI.skin.label; + + Rect slotRect = rect; + slotRect.width = slotStyle.CalcSize(new GUIContent("slot 00:")).x; + + Rect nameRect = rect; + nameRect.xMin = slotRect.xMax; + nameRect.xMax = labelRight; + + Rect valueRect = rect; + valueRect.xMin = nameRect.xMax; + + using (new EditorGUI.PropertyScope(rect, GUIContent.none, valueProperty)) + { + GUI.Label(slotRect, string.Format("slot {0:D2}:", slot), slotStyle); + GUI.Label(nameRect, name); + + using (new NoIndentScope()) + { + valueProperty.floatValue = + EditorGUI.Slider(valueRect, valueProperty.floatValue, paramRef.Min, paramRef.Max); + } + } + } + + private bool InitialParameterValueExists(string name) + { + return parametersProperty.ArrayContains("Name", p => p.stringValue == name); + } + + private bool ParameterLinkExists(string name) + { + return parameterLinksProperty.ArrayContains("Name", p => p.stringValue == name); + } + + private void AddInitialParameterValue(EditorParamRef editorParamRef) + { + serializedObject.Update(); + + if (!InitialParameterValueExists(editorParamRef.Name)) + { + DeleteParameterAutomation(editorParamRef.Name); + + parametersProperty.ArrayAdd(p => { + p.FindPropertyRelative("Name").stringValue = editorParamRef.Name; + p.FindPropertyRelative("Value").floatValue = editorParamRef.Default; + }); + + serializedObject.ApplyModifiedProperties(); + + RefreshMissingParameterLists(); + } + } + + private void DeleteInitialParameterValue(string name) + { + serializedObject.Update(); + + int index = parametersProperty.FindArrayIndex("Name", p => p.stringValue == name); + + if (index >= 0) + { + DeleteInitialParameterValue(index); + } + } + + private void DeleteInitialParameterValue(int index) + { + serializedObject.Update(); + + parametersProperty.DeleteArrayElementAtIndex(index); + + serializedObject.ApplyModifiedProperties(); + RefreshMissingParameterLists(); + } + + private void AddParameterAutomation(string name) + { + serializedObject.Update(); + + if (!ParameterLinkExists(name)) + { + int slot = -1; + + for (int i = 0; i < AutomatableSlots.Count; ++i) + { + if (!parameterLinksProperty.ArrayContains("Slot", p => p.intValue == i)) + { + slot = i; + break; + } + } + + if (slot >= 0) + { + DeleteInitialParameterValue(name); + + parameterLinksProperty.ArrayAdd(p => { + p.FindPropertyRelative("Name").stringValue = name; + p.FindPropertyRelative("Slot").intValue = slot; + }); + + serializedObject.ApplyModifiedProperties(); + + RefreshMissingParameterLists(); + RefreshTimelineEditor(); + } + } + } + + private void DeleteParameterAutomation(string name) + { + serializedObject.Update(); + + int index = parameterLinksProperty.FindArrayIndex("Name", p => p.stringValue == name); + + if (index >= 0) + { + DeleteParameterAutomation(index); + } + } + + private void DeleteParameterAutomation(int index) + { + serializedObject.Update(); + + if (eventPlayable.OwningClip.hasCurves) + { + SerializedProperty linkProperty = parameterLinksProperty.GetArrayElementAtIndex(index); + SerializedProperty slotProperty = linkProperty.FindPropertyRelative("Slot"); + + AnimationClip curvesClip = eventPlayable.OwningClip.curves; + + Undo.RecordObject(curvesClip, string.Empty); + AnimationUtility.SetEditorCurve(curvesClip, GetParameterCurveBinding(slotProperty.intValue), null); + } + + parameterLinksProperty.DeleteArrayElementAtIndex(index); + + serializedObject.ApplyModifiedProperties(); + + RefreshMissingParameterLists(); + + RefreshTimelineEditor(); + } + + private static EditorCurveBinding GetParameterCurveBinding(int index) + { + EditorCurveBinding result = new EditorCurveBinding() { + path = string.Empty, + type = typeof(FMODEventPlayable), + propertyName = string.Format("parameterAutomation.slot{0:D2}", index), + }; + + return result; + } + + private static void RefreshTimelineEditor() + { + TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); + } + } +} +#endif diff --git a/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs.meta new file mode 100644 index 0000000..25f5415 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODEventPlayableEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fa325be8441506c4bb1462c8333ccce9 +timeCreated: 1523230773 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs b/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs new file mode 100644 index 0000000..328af4e --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs @@ -0,0 +1,38 @@ +#if UNITY_TIMELINE_EXIST + +using UnityEditor; +using UnityEditor.Timeline; +using UnityEngine; +using UnityEngine.Timeline; + +namespace FMODUnity +{ + [CustomTimelineEditor(typeof(FMODEventTrack))] + public class FMODEventTrackEditor : TrackEditor + { + private static readonly Texture2D icon = EditorUtils.LoadImage("StudioIcon.png"); + + public override TrackDrawOptions GetTrackOptions(TrackAsset track, Object binding) + { + TrackDrawOptions options = base.GetTrackOptions(track, binding); + options.icon = icon; + + return options; + } + } + + // This custom property drawer is here to draw the volume property at the + // top level of the inspector, rather than in a Template foldout. + [CustomPropertyDrawer(typeof(FMODEventMixerBehaviour))] + public class FMODEventMixerBehaviourInspector : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + SerializedProperty volumeProperty = property.FindPropertyRelative("volume"); + + EditorGUI.PropertyField(position, volumeProperty); + } + } +} + +#endif diff --git a/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs.meta new file mode 100644 index 0000000..7696ab2 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODEventTrackEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 31e1c5e7d70e58f45ae86764f7c3ec2f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef b/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef new file mode 100644 index 0000000..a9cf29d --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef @@ -0,0 +1,39 @@ +{ + "name": "FMODUnityEditor", + "references": [ + "FMODUnity", + "Unity.Timeline.Editor", + "Unity.Timeline", + "Unity.VisualScripting.Core", + "Unity.VisualScripting.Core.Editor", + "Unity.VisualScripting.Flow.Editor", + "Unity.ScriptableBuildPipeline.Editor" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.timeline", + "expression": "1.0.0", + "define": "UNITY_TIMELINE_EXIST" + }, + { + "name": "com.unity.addressables", + "expression": "1.0.0", + "define": "UNITY_ADDRESSABLES_EXIST" + }, + { + "name": "com.unity.visualscripting", + "expression": "1.0.0", + "define": "UNITY_VISUALSCRIPTING_EXIST" + } + ], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef.meta b/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef.meta new file mode 100644 index 0000000..ceb2e40 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FMODUnityEditor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: aab3caaf43456d6449a3e035348ff798 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs b/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs new file mode 100644 index 0000000..3183bed --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs @@ -0,0 +1,1354 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +namespace FMODUnity +{ + public class FileReorganizer : EditorWindow, ISerializationCallbackReceiver + { + public const string ReorganizerMenuItemPath = "FMOD/Reorganize Plugin Files"; + + [SerializeField] + private List tasks = new List(); + + [SerializeField] + private int taskCount; + + [SerializeField] + private int currentTask; + + private TaskView taskView; + + [SerializeField] + private TreeViewState taskViewState = new TreeViewState(); + + [SerializeField] + private MultiColumnHeaderState taskHeaderState; + + [SerializeField] + private bool reloadingFromSerializedState = false; + + [NonSerialized] + private GUIContent statusContent = GUIContent.none; + + private IEnumerator processingState; + + [MenuItem(ReorganizerMenuItemPath)] + public static void ShowWindow() + { + FileReorganizer reorganizer = GetWindow("FMOD File Reorganizer"); + reorganizer.minSize = new Vector2(850, 600); + + reorganizer.PopulateTasks(); + + reorganizer.Show(); + } + + [Serializable] + private class Task + { + public int step = int.MaxValue; + + private Task() + { + } + + public static Task Move(string source, string destination, Platform platform) + { + return new Task() { + type = Type.Move, + status = Status.Pending, + platform = platform, + source = source, + destination = destination, + statusText = string.Format("{0} will be moved to\n{1}", source, destination), + }; + } + + public static Task RemoveFolder(string path) + { + return new Task() { + type = Type.RemoveFolder, + status = Status.Pending, + source = path, + statusText = string.Format("{0} will be removed if it is empty", path), + }; + } + + public static Task Missing(string path, Platform platform) + { + return new Task() { + type = Type.Missing, + status = Status.Missing, + platform = platform, + source = path, + statusText = string.Format( + "{0} is missing.\nYou may need to reinstall the {1} support package from {2}.", + path, platform.DisplayName, EditorSettings.DownloadURL), + }; + } + + public static Task RemoveAsset(string path, Platform platform) + { + return new Task() { + type = Type.RemoveAsset, + status = Status.Pending, + platform = platform, + source = path, + statusText = string.Format("{0} will be removed", path), + }; + } + + public Platform platform { get; private set; } + public string source { get; private set; } + public string destination { get; private set; } + + public enum Status + { + Pending, + Succeeded, + Failed, + Missing, + } + + public Status status { get; private set; } + public string statusText { get; private set; } + + public void SetSucceeded(string message) + { + status = Status.Succeeded; + statusText = message; + } + + public void SetFailed(string message) + { + status = Status.Failed; + statusText = message; + } + + public enum Type + { + Move, + RemoveFolder, + RemoveAsset, + Missing, + } + + public Type type { get; private set; } + + public string platformName { get { return (platform != null) ? platform.DisplayName : string.Empty; } } + } + + public void OnBeforeSerialize() + { + taskViewState = taskView.state; + taskHeaderState = taskView.multiColumnHeader.state; + } + + public void OnAfterDeserialize() + { + } + + private void OnEnable() + { + { + MultiColumnHeaderState newHeaderState = TaskView.CreateHeaderState(); + + if (MultiColumnHeaderState.CanOverwriteSerializedFields(taskHeaderState, newHeaderState)) + { + MultiColumnHeaderState.OverwriteSerializedFields(taskHeaderState, newHeaderState); + } + + taskHeaderState = newHeaderState; + } + + MultiColumnHeader taskHeader = new MultiColumnHeader(taskHeaderState); + + taskView = new TaskView(taskViewState, taskHeader, tasks); + taskView.taskSelected += OnTaskSelected; + + taskView.Reload(); + + if (reloadingFromSerializedState) + { + taskView.SortRows(); + } + else + { + taskHeader.ResizeToFit(); + taskHeader.SetSorting((int)TaskView.Column.Step, true); + } + + reloadingFromSerializedState = true; + + EditorApplication.update += ProcessNextTask; + } + + private void OnDestroy() + { + EditorApplication.update -= ProcessNextTask; + + StopProcessing(); + } + + private void PopulateTasks() + { + tasks.Clear(); + + TaskGenerator.Generate(tasks); + + SetTaskSequence(); + UpdateTaskCount(); + SetDefaultStatus(); + + taskView.Reload(); + taskView.SortRows(); + } + + public static bool IsUpToDate() + { + List tasks = new List(); + + TaskGenerator.Generate(tasks); + + return !tasks.Any(t => t.type != Task.Type.Missing); + } + + private void SetDefaultStatus() + { + int missingCount = tasks.Count(t => t.type == Task.Type.Missing); + + if (missingCount > 0) + { + string message; + + if (missingCount == 1) + { + message = "There is a file missing. Select it above for more information."; + } + else + { + message = string.Format( + "There are {0} files missing. Select them above for more information.", missingCount); + } + + statusContent = new GUIContent(message, Resources.StatusIcon[Task.Status.Missing]); + } + else + { + statusContent = GUIContent.none; + } + } + + private void SetTaskSequence() + { + int step = 1; + + foreach (Task task in tasks.Where(t => t.type == Task.Type.Move)) + { + task.step = step; + ++step; + } + + foreach (Task task in tasks.Where(t => t.type == Task.Type.RemoveAsset)) + { + task.step = step; + ++step; + } + + // Sort folder tasks in reverse path order, so subfolders are processed before their parents + foreach (Task task in tasks.Where(t => t.type == Task.Type.RemoveFolder).OrderByDescending(t => t.source)) + { + task.step = step; + ++step; + } + + tasks.Sort((a, b) => a.step.CompareTo(b.step)); + } + + private void UpdateTaskCount() + { + taskCount = tasks.Count(t => t.status == Task.Status.Pending); + } + + private class TaskView : TreeView + { + private List tasks; + + public delegate void TaskSelectedHandler(Task task); + + public event TaskSelectedHandler taskSelected; + + public TaskView(TreeViewState state, MultiColumnHeader header, List tasks) + : base(state, header) + { + this.tasks = tasks; + + showAlternatingRowBackgrounds = true; + + header.sortingChanged += SortRows; + } + + public static MultiColumnHeaderState CreateHeaderState() + { + MultiColumnHeaderState.Column[] columns = new MultiColumnHeaderState.Column[] { + new MultiColumnHeaderState.Column() + { + headerContent = new GUIContent("Task #"), + width = 50, + autoResize = false, + allowToggleVisibility = false, + }, + new MultiColumnHeaderState.Column() + { + headerContent = new GUIContent("Status"), + width = 100, + autoResize = false, + allowToggleVisibility = false, + }, + new MultiColumnHeaderState.Column() { + headerContent = new GUIContent("Platform"), + width = 150, + autoResize = false, + allowToggleVisibility = false, + }, + new MultiColumnHeaderState.Column() + { + headerContent = new GUIContent("Description"), + minWidth = 500, + allowToggleVisibility = false, + }, + }; + + return new MultiColumnHeaderState(columns); + } + + public enum Column + { + Step, + Status, + Platform, + Description, + } + + private class TaskItem : TreeViewItem + { + public Task task; + } + + protected override TreeViewItem BuildRoot() + { + TreeViewItem root = new TreeViewItem(-1, -1); + + if (tasks.Count > 0) + { + int index = 0; + + foreach (Task task in tasks) + { + TreeViewItem taskItem = new TaskItem() { + id = index++, + task = task, + }; + + root.AddChild(taskItem); + } + } + else + { + TreeViewItem item = new TreeViewItem(0); + item.displayName = "Nothing to do here."; + + root.AddChild(item); + } + + SetupDepthsFromParentsAndChildren(root); + + return root; + } + + protected override bool CanMultiSelect(TreeViewItem item) + { + return false; + } + + protected override void SelectionChanged(IList selectedIds) + { + base.SelectionChanged(selectedIds); + + if (taskSelected != null) + { + if (selectedIds.Count > 0) + { + TaskItem item = FindItem(selectedIds[0], rootItem) as TaskItem; + + if (item != null) + { + taskSelected(item.task); + return; + } + } + + taskSelected(null); + } + } + + public void SortRows() + { + SortRows(multiColumnHeader); + } + + private void SortRows(MultiColumnHeader header) + { + IList rows = GetRows(); + int[] sortedColumns = header.state.sortedColumns; + + if (sortedColumns.Length > 0 && rows.Count > 1) + { + int firstColumn = sortedColumns[0]; + + IOrderedEnumerable query = + InitialQuery(rows, (Column)firstColumn, header.IsSortedAscending(firstColumn)); + + for (int i = 1; i < sortedColumns.Length; ++i) + { + query = SubQuery(query, sortedColumns[i], header.IsSortedAscending(sortedColumns[i])); + } + + // We need to execute the query before clearing rows, otherwise it returns nothing + List newRows = query.ToList(); + + rows.Clear(); + + foreach (TreeViewItem item in newRows) + { + rows.Add(item); + } + } + + RefreshCustomRowHeights(); + } + + private IOrderedEnumerable InitialQuery(IList rows, Column column, bool ascending) + { + switch (column) + { + case Column.Step: + return Sort(rows, r => (r as TaskItem).task.step, ascending); + case Column.Status: + return Sort(rows, r => (r as TaskItem).task.status, ascending); + case Column.Platform: + return Sort(rows, r => (r as TaskItem).task.platformName, ascending); + case Column.Description: + return Sort(rows, r => (r as TaskItem).task.source, ascending); + default: + throw new ArgumentException("Unrecognised column: " + column); + } + } + + private static IOrderedEnumerable SubQuery( + IOrderedEnumerable query, int column, bool ascending) + { + switch ((Column)column) + { + case Column.Step: + return SubSort(query, r => (r as TaskItem).task.step, ascending); + case Column.Status: + return SubSort(query, r => (r as TaskItem).task.status, ascending); + case Column.Platform: + return SubSort(query, r => (r as TaskItem).task.platformName, ascending); + case Column.Description: + return SubSort(query, r => (r as TaskItem).task.source, ascending); + default: + throw new ArgumentException("Unrecognised column: " + column); + } + } + + protected override float GetCustomRowHeight(int row, TreeViewItem item) + { + if (item is TaskItem) + { + Task task = (item as TaskItem).task; + + if (task.type == Task.Type.Move) + { + return EditorGUIUtility.singleLineHeight * 2; + } + else + { + return Resources.StatusHeight(); + } + } + else + { + return base.GetCustomRowHeight(row, item); + } + } + + protected override void RowGUI(RowGUIArgs args) + { + if (args.item is TaskItem) + { + TaskItem taskItem = args.item as TaskItem; + + for (int i = 0; i < args.GetNumVisibleColumns(); ++i) + { + CellGUI(args.GetCellRect(i), taskItem.task, args.GetColumn(i)); + } + } + else + { + base.RowGUI(args); + } + } + + private void CellGUI(Rect rect, Task task, int columnIndex) + { + switch ((Column)columnIndex) + { + case Column.Step: + if (task.step != int.MaxValue) + { + GUI.Label(rect, task.step.ToString(), Resources.StepStyle()); + } + break; + case Column.Status: + GUI.Label(rect, Resources.StatusContent[task.status], Resources.StatusColumnStyle()); + break; + case Column.Platform: + GUI.Label(rect, task.platformName, Resources.PlatformStyle()); + break; + case Column.Description: + DrawDescription(rect, task); + break; + } + } + + private void DrawDescription(Rect rect, Task task) + { + switch (task.type) + { + case Task.Type.Move: + DrawMoveDescription(rect, task); + break; + case Task.Type.RemoveFolder: + DrawRemoveFolderDescription(rect, task); + break; + case Task.Type.RemoveAsset: + DrawRemoveAssetDescription(rect, task); + break; + case Task.Type.Missing: + DrawMissingDescription(rect, task); + break; + } + } + + private void DrawMoveDescription(Rect rect, Task task) + { + Rect sourcePrefixRect = new Rect(rect.x, rect.y, Resources.PrefixSize().x, Resources.PrefixSize().y); + + Rect destinationPrefixRect = sourcePrefixRect; + destinationPrefixRect.y = sourcePrefixRect.yMax; + + Rect sourceRect = sourcePrefixRect; + sourceRect.x = sourcePrefixRect.xMax; + sourceRect.xMax = rect.xMax; + + Rect destinationRect = destinationPrefixRect; + destinationRect.x = destinationPrefixRect.xMax; + destinationRect.xMax = rect.xMax; + + EditorGUI.BeginDisabledGroup(true); + + GUI.Label(sourcePrefixRect, Resources.SourcePrefix, Resources.PrefixStyle()); + GUI.Label(destinationPrefixRect, Resources.DestinationPrefix, Resources.PrefixStyle()); + + EditorGUI.EndDisabledGroup(); + + DrawAssetPath(sourceRect, task.source); + DrawAssetPath(destinationRect, task.destination); + } + + private void DrawRemoveFolderDescription(Rect rect, Task task) + { + Rect prefixRect = new Rect(rect.x, rect.y, Resources.PrefixSize().x, Resources.PrefixSize().y); + + Rect pathRect = prefixRect; + pathRect.x = prefixRect.xMax; + pathRect.width = Resources.AssetPathStyle().CalcSize(new GUIContent(task.source)).x; + + Rect suffixRect = prefixRect; + suffixRect.x = pathRect.xMax; + suffixRect.xMax = rect.xMax; + + EditorGUI.BeginDisabledGroup(true); + + GUI.Label(prefixRect, Resources.RemovePrefix, Resources.PrefixStyle()); + + EditorGUI.EndDisabledGroup(); + + DrawAssetPath(pathRect, task.source); + + EditorGUI.BeginDisabledGroup(true); + + GUI.Label(suffixRect, "if empty", Resources.SuffixStyle()); + + EditorGUI.EndDisabledGroup(); + } + + private void DrawRemoveAssetDescription(Rect rect, Task task) + { + Rect prefixRect = new Rect(rect.x, rect.y, Resources.PrefixSize().x, Resources.PrefixSize().y); + + Rect pathRect = prefixRect; + pathRect.x = prefixRect.xMax; + pathRect.width = Resources.AssetPathStyle().CalcSize(new GUIContent(task.source)).x; + + EditorGUI.BeginDisabledGroup(true); + + GUI.Label(prefixRect, Resources.RemovePrefix, Resources.PrefixStyle()); + + EditorGUI.EndDisabledGroup(); + + DrawAssetPath(pathRect, task.source); + } + + private void DrawMissingDescription(Rect rect, Task task) + { + Rect sourceRect = rect; + sourceRect.xMin += Resources.PrefixSize().x; + + DrawAssetPath(sourceRect, task.source); + } + } + + private static IOrderedEnumerable Sort(IEnumerable enumerable, + Func keySelector, bool ascending) + { + if (ascending) + { + return enumerable.OrderBy(keySelector); + } + else + { + return enumerable.OrderByDescending(keySelector); + } + } + + private static IOrderedEnumerable SubSort(IOrderedEnumerable enumerable, + Func keySelector, bool ascending) + { + if (ascending) + { + return enumerable.ThenBy(keySelector); + } + else + { + return enumerable.ThenByDescending(keySelector); + } + } + + private class Resources + { + private static GUIStyle statusColumnStyle; + + private static GUIStyle statusBarStyle; + + private static float statusHeight; + + private static GUIStyle stepStyle; + + public static readonly GUIContent SourcePrefix = new GUIContent("Move"); + public static readonly GUIContent DestinationPrefix = new GUIContent("to"); + public static readonly GUIContent RemovePrefix = new GUIContent("Remove"); + + private static Vector2 prefixSize; + + private static GUIStyle prefixStyle; + + private static GUIStyle suffixStyle; + + private static GUIStyle assetPathStyle; + + private static bool cacheInitialized = false; + + public static readonly Dictionary StatusIcon = + new Dictionary() { + { Task.Status.Pending, EditorGUIUtility.FindTexture("TestNormal") }, + { Task.Status.Succeeded, EditorGUIUtility.FindTexture("TestPassed") }, + { Task.Status.Failed, EditorGUIUtility.FindTexture("TestFailed") }, + { Task.Status.Missing, EditorGUIUtility.FindTexture("console.warnicon.sml") }, + }; + + public static readonly Dictionary StatusContent = + new Dictionary() { + { Task.Status.Pending, new GUIContent("Pending", StatusIcon[Task.Status.Pending]) }, + { Task.Status.Succeeded, new GUIContent("Succeeded", StatusIcon[Task.Status.Succeeded]) }, + { Task.Status.Failed, new GUIContent("Failed", StatusIcon[Task.Status.Failed]) }, + { Task.Status.Missing, new GUIContent("Missing", StatusIcon[Task.Status.Missing]) }, + }; + + public static GUIStyle StatusColumnStyle() + { + AffirmCache(); + return statusColumnStyle; + } + + public static GUIStyle StatusBarStyle() + { + AffirmCache(); + return statusBarStyle; + } + + public static GUIStyle PlatformStyle() + { + return StatusColumnStyle(); + } + + public static float StatusHeight() + { + if (statusHeight == 0) + { + foreach (var current in StatusIcon) + { + statusHeight = Math.Max(statusHeight, current.Value.height + 4); + } + } + + return statusHeight; + } + + public static GUIStyle StepStyle() + { + AffirmCache(); + return stepStyle; + } + + public static Vector2 PrefixSize() + { + AffirmCache(); + return prefixSize; + } + + public static GUIStyle PrefixStyle() + { + AffirmCache(); + return prefixStyle; + } + + public static GUIStyle SuffixStyle() + { + AffirmCache(); + return suffixStyle; + } + + public static GUIStyle AssetPathStyle() + { + AffirmCache(); + return assetPathStyle; + } + + private static void AffirmCache() + { + if (!cacheInitialized) + { + cacheInitialized = true; + + statusColumnStyle = new GUIStyle(GUI.skin.label) { + alignment = TextAnchor.MiddleLeft, + }; + + statusBarStyle = new GUIStyle(GUI.skin.label) { + alignment = TextAnchor.UpperLeft, + wordWrap = true, + }; + + stepStyle = new GUIStyle(GUI.skin.label) { + alignment = TextAnchor.MiddleRight, + }; + + prefixStyle = new GUIStyle(GUI.skin.label) { + alignment = TextAnchor.MiddleRight, + }; + + suffixStyle = new GUIStyle(GUI.skin.label) { + alignment = TextAnchor.MiddleLeft, + }; + + assetPathStyle = new GUIStyle(GUI.skin.label); + + prefixSize = prefixStyle.CalcSize(SourcePrefix); + prefixSize = Vector2.Max(prefixSize, prefixStyle.CalcSize(DestinationPrefix)); + prefixSize = Vector2.Max(prefixSize, prefixStyle.CalcSize(RemovePrefix)); + } + } + } + + private void OnTaskSelected(Task task) + { + if (task != null) + { + statusContent = new GUIContent(task.statusText, Resources.StatusIcon[task.status]); + } + else + { + SetDefaultStatus(); + } + } + + private void OnGUI() + { + if (focusedWindow == this + && Event.current.type == EventType.KeyDown + && Event.current.keyCode == KeyCode.Escape) + { + Cancel(); + Event.current.Use(); + } + + // Task list + GUILayout.BeginVertical(GUI.skin.box); + + Rect treeViewRect = GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); + + taskView.OnGUI(treeViewRect); + + GUILayout.EndVertical(); + + // Status bar + GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.Height(EditorGUIUtility.singleLineHeight * 2)); + + GUILayout.Label(statusContent.image, GUILayout.ExpandWidth(false)); + EditorGUILayout.SelectableLabel(statusContent.text, Resources.StatusBarStyle()); + + GUILayout.EndHorizontal(); + + // Buttons + float buttonHeight = EditorGUIUtility.singleLineHeight * 2; + + GUILayout.BeginHorizontal(); + + if (GUILayout.Button("Cancel", GUILayout.Height(buttonHeight))) + { + Cancel(); + } + + EditorGUI.BeginDisabledGroup(IsProcessing()); + + if (GUILayout.Button("Refresh", GUILayout.Height(buttonHeight))) + { + PopulateTasks(); + } + + EditorGUI.EndDisabledGroup(); + + if (IsProcessing()) + { + EditorGUI.BeginDisabledGroup(true); + + GUILayout.Button(string.Format("Processing Task {0} of {1}", currentTask, taskCount), GUILayout.Height(buttonHeight)); + + EditorGUI.EndDisabledGroup(); + } + else + { + if (GUILayout.Button(string.Format("Process {0} Tasks", taskCount), GUILayout.Height(buttonHeight))) + { + StartProcessing(); + } + } + + GUILayout.EndHorizontal(); + } + + private void Cancel() + { + if (IsProcessing()) + { + StopProcessing(); + } + else + { + Close(); + } + } + + private static void DrawAssetPath(Rect rect, string path) + { + GUIStyle pathStyle = Resources.AssetPathStyle(); + GUIContent pathContent = new GUIContent(path); + + Rect pathRect = rect; + pathRect.width = pathStyle.CalcSize(pathContent).x; + + GUI.Label(pathRect, pathContent, pathStyle); + EditorGUIUtility.AddCursorRect(pathRect, MouseCursor.Link); + + if (Event.current.type == EventType.MouseDown + && pathRect.Contains(Event.current.mousePosition)) + { + SelectAssetOrParentFolder(path); + Event.current.Use(); + } + } + + private static void SelectAssetOrParentFolder(string path) + { + while (!AssetExists(path)) + { + path = EditorUtils.GetParentFolder(path); + + if (string.IsNullOrEmpty(path)) + { + return; + } + } + + Selection.activeObject = AssetDatabase.LoadAssetAtPath(path); + } + + private void OnInspectorUpdate() + { + ProcessNextTask(); + } + + private struct TaskGenerator + { + private const string AssetsFolder = "Assets"; + private const string FMODRoot = "Assets/Plugins/FMOD"; + private const string FMODSource = FMODRoot + "/src"; + + private static readonly string[] BaseFolders = { + FMODSource, + FMODRoot, + "Assets/Plugins", + "Assets", + }; + + private static readonly MoveRecord[] looseAssets = { + // Release 1.10 layout + new MoveRecord() { source = FMODRoot + "/fmodplugins.cpp", destination = "obsolete" }, + new MoveRecord() { source = "Assets/Editor/FMODMigrationUtil.cs", destination = "obsolete" }, + new MoveRecord() { source = "Assets/GoogleVR", destination = "addons" }, + new MoveRecord() { source = "Assets/ResonanceAudio", destination = "addons" }, + new MoveRecord() { source = "Assets/Resources/FMODStudioSettings.asset", destination = "Resources" }, + new MoveRecord() { source = "Assets/FMODStudioCache.asset", destination = "Resources" }, + + // Release 2.0 layout + new MoveRecord() { source = FMODRoot + "/src/Runtime/fmodplugins.cpp", destination = "obsolete" }, + + // Release 2.1 layout + new MoveRecord() { source = FMODRoot + "/src/Runtime/fmod_static_plugin_support.h", destination = "obsolete" }, + + // Release 2.2 layout + new MoveRecord() { source = FMODRoot + "/src/fmodplugins.cpp", destination = "obsolete" }, + new MoveRecord() { source = FMODRoot + "/src/fmod_static_plugin_support.h", destination = "obsolete" }, + new MoveRecord() { source = FMODSource + "/CodeGeneration.cs", destination = "src/Editor" }, + }; + + private static readonly string[] foldersToCleanUp = { + "Assets/Plugins/FMOD/Runtime", + "Assets/Plugins/Editor", + }; + + private List tasks; + + public static void Generate(List tasks) + { + TaskGenerator generator = new TaskGenerator() { tasks = tasks }; + + Settings.Instance.Platforms.ForEach(generator.GenerateTasksForPlatform); + generator.GenerateTasksForLooseAssets(); + generator.GenerateTasksForCodeFolders(); + generator.GenerateTasksForLegacyCodeFiles(); + generator.GenerateTasksForFolderCleanup(); + } + + private void GenerateTasksForPlatform(Platform platform) + { + IEnumerable files = platform.GetSourceFileInfo().Cast(); + + foreach (BuildTarget buildTarget in platform.GetBuildTargets()) + { + files = files.Concat(platform.GetBinaryFileInfo(buildTarget, Platform.BinaryType.All).Cast()); + } + + foreach (Platform.FileInfo info in files) + { + string newPath = info.LatestLocation(); + + if (!AssetExists(newPath)) + { + bool foundPath = false; + string oldPath = null; + + foreach (string path in info.OldLocations()) + { + oldPath = path; + + if (tasks.Any(t => t.source == oldPath)) + { + foundPath = true; + break; + } + + if (AssetExists(oldPath)) + { + tasks.Add(Task.Move(oldPath, newPath, platform)); + + foundPath = true; + break; + } + } + + if (oldPath != null) + { + string oldFolder = EditorUtils.GetParentFolder(oldPath); + string newFolder = EditorUtils.GetParentFolder(newPath); + + if (newFolder != oldFolder) + { + AddFolderTasks(oldFolder); + } + } + + if (!foundPath && ((info.type & Platform.BinaryType.Optional) == 0) + && !tasks.Any(t => t.source == newPath)) + { + tasks.Add(Task.Missing(newPath, platform)); + } + } + } + + foreach (string path in platform.GetObsoleteAssetPaths()) + { + if (AssetExists(path) && !tasks.Any(t => t.source == path)) + { + tasks.Add(Task.RemoveAsset(path, platform)); + } + } + } + + private void AddFolderTasks(string path) + { + string baseFolder = BaseFolders.First(f => path.StartsWith(f)); + + string currentFolder = path; + + // Find the last folder in the path that exists, without leaving the base folder + while (currentFolder.StartsWith(baseFolder) && !AssetDatabase.IsValidFolder(currentFolder)) + { + currentFolder = EditorUtils.GetParentFolder(currentFolder); + } + + while (currentFolder.StartsWith(baseFolder) && currentFolder != baseFolder) + { + AddFolderTask(currentFolder); + currentFolder = EditorUtils.GetParentFolder(currentFolder); + } + } + + private void AddFolderTask(string path) + { + if (!tasks.Any(t => t.type == Task.Type.RemoveFolder && t.source == path)) + { + tasks.Add(Task.RemoveFolder(path)); + } + } + + private struct MoveRecord + { + public string source; + public string destination; + } + + private static readonly MoveRecord[] codeFolders = { + // Release 2.0 layout + new MoveRecord() { source = FMODSource + "/Runtime", destination = "src" }, + new MoveRecord() { source = FMODSource + "/Runtime/Timeline", destination = "src" }, + new MoveRecord() { source = FMODSource + "/Runtime/wrapper", destination = "src" }, + new MoveRecord() { source = FMODSource + "/Editor/Timeline", destination = "src/Editor" }, + + // Release 1.10 layout + new MoveRecord() { source = FMODRoot + "/Timeline", destination = "src" }, + new MoveRecord() { source = FMODRoot + "/Wrapper", destination = "src" }, + new MoveRecord() { source = "Assets/Plugins/Editor/FMOD", destination = "src/Editor" }, + new MoveRecord() { source = "Assets/Plugins/Editor/FMOD/Timeline", destination = "src/Editor" }, + }; + + private void AddMoveTask(string source, string destination) + { + if (!tasks.Any(t => t.source == source)) + { + tasks.Add(Task.Move(source, destination, null)); + } + } + + private void GenerateTasksForCodeFolders() + { + foreach (MoveRecord folder in codeFolders) + { + if (AssetDatabase.IsValidFolder(folder.source)) + { + foreach (string sourcePath in FindFileAssets(folder.source)) + { + string filename = Path.GetFileName(sourcePath); + + AddMoveTask( + sourcePath, $"{RuntimeUtils.PluginBasePath}/{folder.destination}/{filename}"); + + } + + AddFolderTask(folder.source); + } + } + } + + private void GenerateTasksForLooseAssets() + { + foreach (MoveRecord asset in looseAssets) + { + string filename = Path.GetFileName(asset.source); + string destinationPath = $"{RuntimeUtils.PluginBasePath}/{asset.destination}/{filename}"; + + if (AssetExists(asset.source) && !AssetExists(destinationPath)) + { + AddMoveTask(asset.source, destinationPath); + AddFolderTasks(EditorUtils.GetParentFolder(asset.source)); + } + else if (AssetDatabase.IsValidFolder(asset.source) && AssetDatabase.IsValidFolder(destinationPath)) + { + GenerateFolderMergeTasks(asset.source, destinationPath); + AddFolderTasks(asset.source); + } + } + } + + private void GenerateFolderMergeTasks(string sourceFolder, string destinationFolder) + { + IEnumerable assetPaths = AssetDatabase.FindAssets(string.Empty, new string[] { sourceFolder }) + .Select(g => AssetDatabase.GUIDToAssetPath(g)) + .Where(p => !AssetDatabase.IsValidFolder(p) || IsFolderEmpty(p)); + + foreach (string sourcePath in assetPaths) + { + int prefixLength = sourceFolder.Length; + + if (!sourceFolder.EndsWith("/")) + { + ++prefixLength; + } + + string relativePath = sourcePath.Substring(prefixLength); + string destinationPath = string.Format("{0}/{1}", destinationFolder, relativePath); + + if (!AssetExists(destinationPath)) + { + AddMoveTask(sourcePath, destinationPath); + AddFolderTasks(EditorUtils.GetParentFolder(sourcePath)); + } + else if (AssetDatabase.IsValidFolder(sourcePath)) + { + AddFolderTasks(sourcePath); + } + } + } + + private void GenerateTasksForLegacyCodeFiles() + { + foreach (string path in FindFileAssets(FMODRoot).Where(p => p.EndsWith(".cs"))) + { + string destinationPath = $"{RuntimeUtils.PluginBasePath}/src/{Path.GetFileName(path)}"; + + if (!AssetExists(destinationPath)) + { + AddMoveTask(path, destinationPath); + } + } + } + + private void GenerateTasksForFolderCleanup() + { + foreach (string folder in foldersToCleanUp) + { + if (AssetDatabase.IsValidFolder(folder)) + { + AddFolderTask(folder); + } + } + } + + private static IEnumerable FindFileAssets(string folder) + { + if (AssetDatabase.IsValidFolder(folder)) + { + return AssetDatabase.FindAssets(string.Empty, new string[] { folder }) + .Select(g => AssetDatabase.GUIDToAssetPath(g)) + .Where(p => (EditorUtils.GetParentFolder(p) == folder) && !AssetDatabase.IsValidFolder(p)); + } + else + { + return Enumerable.Empty(); + } + } + } + + private void StartProcessing() + { + if (!IsProcessing()) + { + EditorApplication.LockReloadAssemblies(); + + currentTask = 0; + processingState = ProcessMoveTasks() + .Concat(ProcessRemoveAssetTasks()) + .Concat(ProcessRemoveFolderTasks()) + .GetEnumerator(); + } + } + + private void StopProcessing() + { + if (IsProcessing()) + { + processingState = null; + UpdateTaskCount(); + SetDefaultStatus(); + + EditorApplication.UnlockReloadAssemblies(); + + if (taskCount == 0) + { + SetupWizardWindow.SetUpdateTaskComplete(SetupWizardWindow.UpdateTaskType.ReorganizePluginFiles); + } + } + } + + private bool IsProcessing() + { + return processingState != null; + } + + private void ProcessNextTask() + { + if (processingState != null) + { + if (processingState.MoveNext()) + { + statusContent = new GUIContent(processingState.Current); + Repaint(); + } + else + { + StopProcessing(); + } + } + } + + private IEnumerable ProcessMoveTasks() + { + foreach (Task task in tasks.Where(t => t.type == Task.Type.Move && t.status == Task.Status.Pending)) + { + EditorUtils.EnsureFolderExists(EditorUtils.GetParentFolder(task.destination)); + + currentTask = task.step; + + yield return string.Format("Moving {0} to {1}", task.source, task.destination); + + string result = AssetDatabase.MoveAsset(task.source, task.destination); + + if (string.IsNullOrEmpty(result)) + { + task.SetSucceeded(string.Format("{0} was moved to\n{1}", task.source, task.destination)); + } + else + { + task.SetFailed(string.Format("{0} could not be moved to\n{1}: '{2}'", + task.source, task.destination, result)); + } + + yield return task.statusText; + } + } + + private static bool AssetExists(string path) + { + return EditorUtils.AssetExists(path); + } + + private IEnumerable ProcessRemoveAssetTasks() + { + foreach (Task task in tasks.Where(t => t.type == Task.Type.RemoveAsset && t.status == Task.Status.Pending)) + { + currentTask = task.step; + + if (AssetDatabase.MoveAssetToTrash(task.source)) + { + task.SetSucceeded(string.Format("{0} was removed", task.source)); + } + else + { + task.SetFailed(string.Format("{0} could not be removed", task.source)); + } + + yield return task.statusText; + } + } + + private static bool IsFolderEmpty(string path) + { + return AssetDatabase.FindAssets(string.Empty, new string[] { path }).Length == 0; + } + + private IEnumerable ProcessRemoveFolderTasks() + { + foreach (Task task in tasks.Where(t => t.type == Task.Type.RemoveFolder && t.status == Task.Status.Pending)) + { + currentTask = task.step; + + foreach (string result in RemoveFolderIfEmpty(task)) + { + yield return result; + } + } + } + + private static IEnumerable RemoveFolderIfEmpty(Task task) + { + if (!Directory.Exists(Application.dataPath + "/../" + task.source)) + { + task.SetSucceeded(string.Format("{0} has already been removed", task.source)); + yield break; + } + + if (!AssetDatabase.IsValidFolder(task.source)) + { + task.SetFailed(string.Format("{0} is not a valid folder", task.source)); + yield break; + } + + if (!IsFolderEmpty(task.source)) + { + task.SetFailed(string.Format("{0} is not empty", task.source)); + yield break; + } + + yield return string.Format("Removing empty folder {0}", task.source); + + if (AssetDatabase.MoveAssetToTrash(task.source)) + { + task.SetSucceeded(string.Format("{0} was removed", task.source)); + } + else + { + task.SetFailed(string.Format("{0} could not be removed", task.source)); + } + + yield return task.statusText; + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs.meta b/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs.meta new file mode 100644 index 0000000..fc3232b --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FileReorganizer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3349615af02d64e4e8d1026e228c4a25 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs b/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs new file mode 100644 index 0000000..07e9b21 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs @@ -0,0 +1,190 @@ +using System; +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; + +namespace FMODUnity +{ + public class FindAndReplace : EditorWindow + { + private bool levelScope = true; + private bool prefabScope; + private string findText; + private string replaceText; + private string message = ""; + private MessageType messageType = MessageType.None; + private int lastMatch = -1; + private List emitters; + + private bool first = true; + + [MenuItem("FMOD/Find and Replace", priority = 2)] + private static void ShowFindAndReplace() + { + var window = CreateInstance(); + window.titleContent = new GUIContent("FMOD Find and Replace"); + window.OnHierarchyChange(); + var position = window.position; + window.maxSize = window.minSize = position.size = new Vector2(400, 170); + window.position = position; + window.ShowUtility(); + } + + private void OnHierarchyChange() + { + emitters = new List(Resources.FindObjectsOfTypeAll()); + + if (!levelScope) + { + emitters.RemoveAll(x => PrefabUtility.GetPrefabAssetType(x) == PrefabAssetType.NotAPrefab); + } + + if (!prefabScope) + { + emitters.RemoveAll(x => PrefabUtility.GetPrefabAssetType(x) != PrefabAssetType.NotAPrefab); + } + } + + private void OnGUI() + { + bool doFind = false; + if ((Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)) + { + Event.current.Use(); + doFind = true; + } + + GUI.SetNextControlName("find"); + EditorGUILayout.PrefixLabel("Find:"); + EditorGUI.BeginChangeCheck(); + findText = EditorGUILayout.TextField(findText); + if (EditorGUI.EndChangeCheck()) + { + lastMatch = -1; + message = null; + } + EditorGUILayout.PrefixLabel("Replace:"); + replaceText = EditorGUILayout.TextField(replaceText); + + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginChangeCheck(); + levelScope = EditorGUILayout.ToggleLeft("Current Level", levelScope, GUILayout.ExpandWidth(false)); + prefabScope = EditorGUILayout.ToggleLeft("Prefabs", prefabScope, GUILayout.ExpandWidth(false)); + if (EditorGUI.EndChangeCheck()) + { + OnHierarchyChange(); + } + EditorGUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + if (GUILayout.Button("Find") || doFind) + { + message = ""; + { + FindNext(); + } + if (lastMatch == -1) + { + message = "Finished Search"; + messageType = MessageType.Warning; + } + } + if (GUILayout.Button("Replace")) + { + message = ""; + if (lastMatch == -1) + { + FindNext(); + } + else + { + Replace(); + } + if (lastMatch == -1) + { + message = "Finished Search"; + messageType = MessageType.Warning; + } + } + if (GUILayout.Button("Replace All")) + { + if (EditorUtility.DisplayDialog("Replace All", "Are you sure you wish to replace all in the current hierachy?", "yes", "no")) + { + ReplaceAll(); + } + } + GUILayout.EndHorizontal(); + if (!string.IsNullOrEmpty(message)) + { + EditorGUILayout.HelpBox(message, messageType); + } + else + { + EditorGUILayout.HelpBox("\n\n", MessageType.None); + } + + if (first) + { + first = false; + EditorGUI.FocusTextInControl("find"); + } + } + + private void FindNext() + { + for (int i = lastMatch + 1; i < emitters.Count; i++) + { + if (emitters[i].EventReference.Path.IndexOf(findText, 0, StringComparison.CurrentCultureIgnoreCase) >= 0) + { + lastMatch = i; + EditorGUIUtility.PingObject(emitters[i]); + Selection.activeGameObject = emitters[i].gameObject; + message = "Found object"; + messageType = MessageType.Info; + return; + } + } + lastMatch = -1; + } + + private void ReplaceAll() + { + int replaced = 0; + for (int i = 0; i < emitters.Count; i++) + { + if (ReplaceText(emitters[i])) + { + replaced++; + } + } + + message = string.Format("{0} replaced", replaced); + messageType = MessageType.Info; + } + + private bool ReplaceText(StudioEventEmitter emitter) + { + int findLength = findText.Length; + int replaceLength = replaceText.Length; + int position = 0; + var serializedObject = new SerializedObject(emitter); + var pathProperty = serializedObject.FindProperty("Event"); + string path = pathProperty.stringValue; + position = path.IndexOf(findText, position, StringComparison.CurrentCultureIgnoreCase); + while (position >= 0) + { + path = path.Remove(position, findLength).Insert(position, replaceText); + position += replaceLength; + position = path.IndexOf(findText, position, StringComparison.CurrentCultureIgnoreCase); + } + pathProperty.stringValue = path; + return serializedObject.ApplyModifiedProperties(); + } + + private void Replace() + { + ReplaceText(emitters[lastMatch]); + FindNext(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs.meta b/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs.meta new file mode 100644 index 0000000..97e7e31 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/FindAndReplace.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a3d0ed60438564241a4e62b152836893 +timeCreated: 1453876443 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/ListView.cs b/Assets/Plugins/FMOD/src/Editor/ListView.cs new file mode 100644 index 0000000..2a59df0 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/ListView.cs @@ -0,0 +1,45 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + public class ListView : UnityEditorInternal.ReorderableList + { + private const float ElementPadding = 2; + + public DrawElementWithLabelDelegate drawElementWithLabelCallback; + + public delegate void DrawElementWithLabelDelegate(Rect rect, float labelRight, int index, + bool active, bool focused); + + private float labelRight; + + public ListView(SerializedProperty property) + : base(property.serializedObject, property, true, false, true, true) + { + headerHeight = 3; + elementHeight = EditorGUIUtility.singleLineHeight + ElementPadding; + drawElementCallback = DrawElementWrapper; + } + + public void DrawLayout() + { + Rect rect = EditorGUILayout.GetControlRect(false, GetHeight()); + + labelRight = rect.x + EditorGUIUtility.labelWidth; + + DoList(EditorGUI.IndentedRect(rect)); + } + + private void DrawElementWrapper(Rect rect, int index, bool active, bool focused) + { + if (drawElementWithLabelCallback != null) + { + rect.height -= ElementPadding; + + drawElementWithLabelCallback(rect, labelRight, index, active, focused); + } + } + } +} + diff --git a/Assets/Plugins/FMOD/src/Editor/ListView.cs.meta b/Assets/Plugins/FMOD/src/Editor/ListView.cs.meta new file mode 100644 index 0000000..4452efb --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/ListView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1573bef36bd46e34f8f2b4dad628a461 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs b/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs new file mode 100644 index 0000000..af4ce28 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs @@ -0,0 +1,81 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomPropertyDrawer(typeof(ParamRefAttribute))] + public class ParamRefDrawer : PropertyDrawer + { + public bool MouseDrag(Event e) + { + bool isDragging = false; + + if (e.type == EventType.DragPerform) + { + isDragging = true; + } + + return isDragging; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Texture browseIcon = EditorUtils.LoadImage("SearchIconBlack.png"); + Texture openIcon = EditorUtils.LoadImage("BrowserIcon.png"); + Texture addIcon = EditorUtils.LoadImage("AddIcon.png"); + + EditorGUI.BeginProperty(position, label, property); + SerializedProperty pathProperty = property; + + Event e = Event.current; + if (MouseDrag(e) && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorParamRef)) + { + pathProperty.stringValue = ((EditorParamRef)DragAndDrop.objectReferences[0]).Name; + GUI.changed = true; + e.Use(); + } + } + if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition)) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorParamRef)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Move; + DragAndDrop.AcceptDrag(); + e.Use(); + } + } + + float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y; + + position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); + + GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); + buttonStyle.padding.top = 1; + buttonStyle.padding.bottom = 1; + + Rect addRect = new Rect(position.x + position.width - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight); + Rect openRect = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight); + Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight); + Rect pathRect = new Rect(position.x, position.y, searchRect.x - position.x - 3, baseHeight); + + EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none); + + if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle)) + { + var eventBrowser = ScriptableObject.CreateInstance(); + + eventBrowser.ChooseParameter(property); + var windowRect = position; + windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); + windowRect.height = openRect.height + 1; + eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400)); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs.meta b/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs.meta new file mode 100644 index 0000000..cdb3d99 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/ParamRefDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ea88808aa26cd614db1c5c1dcbb14d4e +timeCreated: 1444197074 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs b/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs new file mode 100644 index 0000000..a6670d1 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs @@ -0,0 +1,2782 @@ +using UnityEngine; +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.IMGUI.Controls; +using UnityEditorInternal; +using System.IO; +using System; +using System.Linq; +using System.Text.RegularExpressions; + +namespace FMODUnity +{ + [CustomEditor(typeof(Settings))] + public class SettingsEditor : Editor + { + private static readonly string[] ToggleDisplay = new string[] { "Disabled", "Enabled", "Development Build Only", }; + + private static readonly string[] OverlayLocations = new string[] { "TopLeft", "TopCenter", "TopRight", "BottomLeft", "BottomCenter", "BottomRight", "Center", "VR", }; + + private static readonly string[] FrequencyDisplay = new string[] { + "Platform Default", + "22.05 kHz", + "24 kHz", + "32 kHz", + "44.1 kHz", + "48 kHz" + }; + + private static readonly int[] FrequencyValues = new int[] { 0, 22050, 24000, 32000, 44100, 48000 }; + + private static readonly string[] SpeakerModeDisplay = new string[] { + "Stereo", + "Surround 5.1", + "Surround 7.1", + "Surround 7.1.4" + }; + + private static readonly FMOD.SPEAKERMODE[] SpeakerModeValues = new FMOD.SPEAKERMODE[] { + FMOD.SPEAKERMODE.STEREO, + FMOD.SPEAKERMODE._5POINT1, + FMOD.SPEAKERMODE._7POINT1, + FMOD.SPEAKERMODE._7POINT1POINT4 + }; + + private bool hasBankSourceChanged = false; + private bool hasBankTargetChanged = false; + + private bool expandThreadAffinity; + private bool expandCodecChannels; + private bool expandDynamicPlugins; + private bool expandStaticPlugins; + + private static Section sExpandedSections; + + private SerializedProperty automaticEventLoading; + private SerializedProperty automaticSampleLoading; + private SerializedProperty bankLoadType; + private SerializedProperty banksToLoad; + private SerializedProperty enableMemoryTracking; + private SerializedProperty encryptionKey; + private SerializedProperty hasSourceProject; + private SerializedProperty hasPlatforms; + private SerializedProperty importType; + private SerializedProperty loggingLevel; + private SerializedProperty meterChannelOrdering; + private SerializedProperty sourceBankPath; + private SerializedProperty sourceProjectPath; + private SerializedProperty stopEventsOutsideMaxDistance; + private SerializedProperty enableErrorCallback; + private SerializedProperty targetAssetPath; + private SerializedProperty targetBankFolder; + private SerializedProperty bankRefreshCooldown; + private SerializedProperty showBankRefreshWindow; + private SerializedProperty eventLinkage; + + [NonSerialized] + private bool resourcesLoaded = false; + + private GUIStyle mainHeaderStyle; + private GUIStyle sectionHeaderStyle; + private GUIStyle platformHeaderStyle; + private GUIStyle dropdownStyle; + private GUIStyle inheritedPropertyLabelStyle; + private GUIStyle overriddenPropertyLabelStyle; + private GUIStyle inheritedPropertyFoldoutStyle; + private GUIStyle overriddenPropertyFoldoutStyle; + + private GUIContent mainHeaderIcon; + + private Texture2D propertyOverrideIndicator; + + private const int THREAD_AFFINITY_CORES_PER_ROW = 8; + + private const string EditPlatformUndoMessage = "Edit FMOD Platform Properties"; + + private PlatformPropertyStringListView staticPluginsView; + private PlatformPropertyStringListView dynamicPluginsView; + + private static readonly int[] LoggingValues = new int[] { + (int)FMOD.DEBUG_FLAGS.NONE, + (int)FMOD.DEBUG_FLAGS.ERROR, + (int)FMOD.DEBUG_FLAGS.WARNING, + (int)FMOD.DEBUG_FLAGS.LOG, + }; + + private static readonly string[] LoggingDisplay = new string[] { + "None", + "Error", + "Warning", + "Log", + }; + + private ReorderableList banksToLoadView; + + private PlatformsView platformsView; + private TreeViewState platformTreeViewState = new TreeViewState(); + + private string lastSourceBankPath; + + private static readonly GUIContent BankRefreshLabel = new GUIContent("Refresh Banks"); + + private static readonly GUIContent[] BankRefreshCooldownLabels = new GUIContent[] { + new GUIContent("After 1 second"), + new GUIContent("After 5 seconds"), + new GUIContent("After 10 seconds"), + new GUIContent("After 20 seconds"), + new GUIContent("After 30 seconds"), + new GUIContent("After 1 minute"), + new GUIContent("Prompt Me"), + new GUIContent("Manually"), + }; + + private static readonly int[] BankRefreshCooldownValues = new int[] { + 1, + 5, + 10, + 20, + 30, + 60, + Settings.BankRefreshPrompt, + Settings.BankRefreshManual, + }; + + internal enum SourceType : uint + { + FMODStudioProject = 0, + SinglePlatformBuild, + MultiplePlatformBuild + } + + [Flags] + private enum Section + { + BankImport = 1 << 0, + Initialization = 1 << 1, + Behavior = 1 << 2, + UserInterface = 1 << 3, + PlatformSpecific = 1 << 4, + } + + private void OnEnable() + { + automaticEventLoading = serializedObject.FindProperty("AutomaticEventLoading"); + automaticSampleLoading = serializedObject.FindProperty("AutomaticSampleLoading"); + bankLoadType = serializedObject.FindProperty("BankLoadType"); + banksToLoad = serializedObject.FindProperty("BanksToLoad"); + enableMemoryTracking = serializedObject.FindProperty("EnableMemoryTracking"); + encryptionKey = serializedObject.FindProperty("EncryptionKey"); + hasSourceProject = serializedObject.FindProperty("HasSourceProject"); + hasPlatforms = serializedObject.FindProperty("HasPlatforms"); + importType = serializedObject.FindProperty("ImportType"); + loggingLevel = serializedObject.FindProperty("LoggingLevel"); + meterChannelOrdering = serializedObject.FindProperty("MeterChannelOrdering"); + sourceBankPath = serializedObject.FindProperty("sourceBankPath"); + sourceProjectPath = serializedObject.FindProperty("sourceProjectPath"); + stopEventsOutsideMaxDistance = serializedObject.FindProperty("StopEventsOutsideMaxDistance"); + enableErrorCallback = serializedObject.FindProperty("EnableErrorCallback"); + targetAssetPath = serializedObject.FindProperty("TargetAssetPath"); + targetBankFolder = serializedObject.FindProperty("TargetBankFolder"); + bankRefreshCooldown = serializedObject.FindProperty("BankRefreshCooldown"); + showBankRefreshWindow = serializedObject.FindProperty("ShowBankRefreshWindow"); + eventLinkage = serializedObject.FindProperty("EventLinkage"); + + platformsView = new PlatformsView(target as Settings, platformTreeViewState); + + banksToLoadView = new ReorderableList(banksToLoad); + banksToLoadView.onAddDropdownCallback = (rect, list) => { + GenericMenu menu = new GenericMenu(); + + menu.AddItem(new GUIContent("Browse..."), false, BrowseForBankToLoad); + menu.AddItem(new GUIContent("Add All"), false, AddAllBanksToLoad); + + menu.DropDown(rect); + }; + + staticPluginsView = new PlatformPropertyStringListView(Platform.PropertyAccessors.StaticPlugins); + dynamicPluginsView = new PlatformPropertyStringListView(Platform.PropertyAccessors.Plugins); + + Undo.undoRedoPerformed += OnUndoRedo; + } + + private void OnDestroy() + { + Undo.undoRedoPerformed -= OnUndoRedo; + } + + private void OnUndoRedo() + { + platformsView.ForceReload(); + + RefreshBanks(); + + Repaint(); + } + + private void AffirmResources() + { + if (!resourcesLoaded) + { + resourcesLoaded = true; + + mainHeaderStyle = new GUIStyle(EditorStyles.label) { + fontStyle = FontStyle.Bold, + fontSize = 18, + }; + mainHeaderStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; + + sectionHeaderStyle = new GUIStyle(GUI.skin.FindStyle("Foldout")) { + fontStyle = FontStyle.Bold, + }; + + platformHeaderStyle = new GUIStyle(GUI.skin.label) { + richText = true, + }; + + dropdownStyle = new GUIStyle(GUI.skin.FindStyle("dropdownButton")); + dropdownStyle.fixedHeight = 0; + + inheritedPropertyLabelStyle = GUI.skin.label; + + overriddenPropertyLabelStyle = new GUIStyle(inheritedPropertyLabelStyle) { + fontStyle = FontStyle.Bold, + }; + + inheritedPropertyFoldoutStyle = EditorStyles.foldout; + + overriddenPropertyFoldoutStyle = new GUIStyle(inheritedPropertyFoldoutStyle) { + fontStyle = FontStyle.Bold, + }; + + mainHeaderIcon = new GUIContent(EditorUtils.LoadImage("StudioIcon.png")); + + propertyOverrideIndicator = new Texture2D(2, 1); + + Color darkBlue; + ColorUtility.TryParseHtmlString("#1974a5", out darkBlue); + + Color blue; + ColorUtility.TryParseHtmlString("#0f81be", out blue); + + propertyOverrideIndicator.SetPixel(0, 0, darkBlue); + propertyOverrideIndicator.SetPixel(1, 0, blue); + + propertyOverrideIndicator.Apply(); + } + } + + private Rect DrawPlatformPropertyLabel(string label, Platform platform, + params Platform.PropertyOverrideControl[] properties) + { + PlatformPropertyLabelData data; + PreparePlatformPropertyLabel(platform, properties, out data); + + GUI.Label(data.labelRect, label, data.overridden ? overriddenPropertyLabelStyle : inheritedPropertyLabelStyle); + + DecoratePlatformPropertyLabel(data, platform, properties); + + return data.remainderRect; + } + + private Rect DrawPlatformPropertyFoldout(string label, ref bool expand, Platform platform, + params Platform.PropertyOverrideControl[] properties) + { + PlatformPropertyLabelData data; + PreparePlatformPropertyLabel(platform, properties, out data); + + using (new NoIndentScope()) + { + expand = EditorGUI.Foldout(data.labelRect, expand, label, true, + data.overridden ? overriddenPropertyFoldoutStyle : inheritedPropertyFoldoutStyle); + } + + DecoratePlatformPropertyLabel(data, platform, properties); + + return data.remainderRect; + } + + private struct PlatformPropertyLabelData + { + public bool hasParent; + public bool overridden; + public Rect labelRect; + public Rect remainderRect; + } + + private void PreparePlatformPropertyLabel(Platform platform, Platform.PropertyOverrideControl[] properties, + out PlatformPropertyLabelData data) + { + AffirmResources(); + + Rect rect = EditorGUILayout.GetControlRect(); + + data.hasParent = (platform.Parent != null || platform is PlatformPlayInEditor); + data.overridden = data.hasParent && properties.Any(p => p.HasValue(platform)); + data.labelRect = LabelRect(rect); + data.remainderRect = new Rect(rect) { xMin = data.labelRect.xMax }; + } + + private void DecoratePlatformPropertyLabel(PlatformPropertyLabelData data, Platform platform, + Platform.PropertyOverrideControl[] properties) + { + if (data.hasParent) + { + if (data.overridden) + { + Rect indicatorRect = new Rect(data.labelRect) { x = 1, width = 2 }; + GUI.DrawTexture(indicatorRect, propertyOverrideIndicator); + } + + if (Event.current.type == EventType.MouseUp + && Event.current.button == 1 + && data.labelRect.Contains(Event.current.mousePosition)) + { + GenericMenu menu = new GenericMenu(); + + GUIContent revertContent = new GUIContent("Revert"); + + if (data.overridden) + { + menu.AddItem(revertContent, false, () => { + Undo.RecordObject(platform, "Revert FMOD Platform Properties"); + + foreach (Platform.PropertyOverrideControl property in properties) + { + property.Clear(platform); + } + }); + } + else + { + menu.AddDisabledItem(revertContent); + } + + menu.ShowAsContext(); + } + } + } + + private static int DrawPopup(Rect position, int selectedIndex, string[] displayedOptions) + { + using (new NoIndentScope()) + { + return EditorGUI.Popup(position, selectedIndex, displayedOptions); + } + } + + private void DisplayTriStateBool(string label, Platform platform, Platform.PropertyAccessor property) + { + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + + EditorGUI.BeginChangeCheck(); + + int next = DrawPopup(rect, (int)property.Get(platform), ToggleDisplay); + + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, (TriStateBool)next); + } + } + + private void DisplayPositionRect(string label, Platform platform, Platform.PropertyAccessor property) + { + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + EditorGUI.BeginChangeCheck(); + int next = DrawPopup(rect, (int)property.Get(platform), OverlayLocations); + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, (ScreenPosition)next); + } + } + + private void DisplayDebugFontSelection(string label, Platform platform, Platform.PropertyAccessor property) + { + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + EditorGUI.BeginChangeCheck(); + int next = EditorGUI.IntField(rect, property.Get(platform)); + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, Mathf.Min(next, 20)); + } + } + + private void DisplayOutputMode(string label, Platform platform) + { + if (platform.ValidOutputTypes != null) + { + string[] valuesChild = new string[platform.ValidOutputTypes.Length + 3]; + string[] valuesChildEnum = new string[platform.ValidOutputTypes.Length + 3]; + valuesChild[0] = string.Format("Auto"); + valuesChild[1] = string.Format("No Sound"); + valuesChild[2] = string.Format("Wav Writer"); + valuesChildEnum[0] = Enum.GetName(typeof(FMOD.OUTPUTTYPE), FMOD.OUTPUTTYPE.AUTODETECT); + valuesChildEnum[1] = Enum.GetName(typeof(FMOD.OUTPUTTYPE), FMOD.OUTPUTTYPE.NOSOUND); + valuesChildEnum[2] = Enum.GetName(typeof(FMOD.OUTPUTTYPE), FMOD.OUTPUTTYPE.WAVWRITER); + for (int i = 0; i < platform.ValidOutputTypes.Length; i++) + { + valuesChild[i + 3] = platform.ValidOutputTypes[i].displayName; + valuesChildEnum[i + 3] = Enum.GetName(typeof(FMOD.OUTPUTTYPE), platform.ValidOutputTypes[i].outputType); + } + int currentIndex = Array.IndexOf(valuesChildEnum, platform.OutputTypeName); + if (currentIndex == -1) + { + currentIndex = 0; + platform.OutputTypeName = Enum.GetName(typeof(FMOD.OUTPUTTYPE), FMOD.OUTPUTTYPE.AUTODETECT); + } + int next = EditorGUILayout.Popup(label, currentIndex, valuesChild); + platform.OutputTypeName = valuesChildEnum[next]; + } + } + + private void DisplayThreadAffinity(string label, Platform platform) + { + if (platform.CoreCount > 0 && DisplayThreadAffinityFoldout(label, platform)) + { + using (new EditorGUI.IndentLevelScope()) + { + DisplayThreadAffinityGroups(platform); + } + } + } + + private bool DisplayThreadAffinityFoldout(string label, Platform platform) + { + Rect headerRect = EditorGUILayout.GetControlRect(); + + Rect labelRect = headerRect; + labelRect.width = EditorGUIUtility.labelWidth; + + expandThreadAffinity = EditorGUI.Foldout(labelRect, expandThreadAffinity, label, true); + + bool useDefaults = !platform.ThreadAffinitiesProperty.HasValue; + + EditorGUI.BeginChangeCheck(); + + Rect toggleRect = headerRect; + toggleRect.xMin = labelRect.xMax; + + useDefaults = GUI.Toggle(toggleRect, useDefaults, "Use Defaults"); + + if (EditorGUI.EndChangeCheck()) + { + if (useDefaults) + { + platform.ThreadAffinitiesProperty.Value.Clear(); + platform.ThreadAffinitiesProperty.HasValue = false; + } + else + { + platform.ThreadAffinitiesProperty.Value = new List(); + platform.ThreadAffinitiesProperty.HasValue = true; + + foreach (ThreadAffinityGroup group in platform.DefaultThreadAffinities) + { + platform.ThreadAffinitiesProperty.Value.Add(new ThreadAffinityGroup(group)); + } + } + } + + return expandThreadAffinity; + } + + private void DisplayThreadAffinityGroups(Platform platform) + { + GUIStyle affinityStyle = EditorStyles.miniButton; + float affinityWidth = affinityStyle.CalcSize(new GUIContent("00")).x; + + GUIContent anyButtonContent = new GUIContent("Any"); + float anyButtonWidth = affinityStyle.CalcSize(anyButtonContent).x; + + float threadsWidth = EditorGUIUtility.labelWidth; + float affinitiesWidth = affinityWidth * THREAD_AFFINITY_CORES_PER_ROW + anyButtonWidth; + + bool editable = platform.ThreadAffinitiesProperty.HasValue; + + if (platform.ThreadAffinities.Any()) + { + DisplayThreadAffinitiesHeader(threadsWidth, affinitiesWidth); + + using (new EditorGUI.DisabledScope(!editable)) + { + ThreadAffinityGroup groupToDelete = null; + + foreach (ThreadAffinityGroup group in platform.ThreadAffinities) + { + bool delete; + DisplayThreadAffinityGroup(group, platform, threadsWidth, affinitiesWidth, + anyButtonWidth, anyButtonContent, affinityStyle, affinityWidth, out delete); + + if (delete) + { + groupToDelete = group; + } + } + + if (groupToDelete != null) + { + platform.ThreadAffinitiesProperty.Value.Remove(groupToDelete); + } + } + } + else + { + Rect messageRect = EditorGUILayout.GetControlRect(); + messageRect.width = threadsWidth + affinitiesWidth; + messageRect = EditorGUI.IndentedRect(messageRect); + + GUI.Label(messageRect, "List is Empty"); + } + + if (editable) + { + Rect addButtonRect = EditorGUILayout.GetControlRect(); + addButtonRect.width = threadsWidth + affinitiesWidth; + addButtonRect = EditorGUI.IndentedRect(addButtonRect); + + if (GUI.Button(addButtonRect, "Add")) + { + platform.ThreadAffinitiesProperty.Value.Add(new ThreadAffinityGroup()); + } + } + } + + private void DisplayThreadAffinitiesHeader(float threadsWidth, float affinitiesWidth) + { + Rect controlRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); + + Rect threadsRect = controlRect; + threadsRect.width = threadsWidth; + + threadsRect = EditorGUI.IndentedRect(threadsRect); + + GUI.Label(threadsRect, "Threads"); + + Rect coresRect = controlRect; + coresRect.x = threadsRect.xMax; + coresRect.width = affinitiesWidth; + + GUI.Label(coresRect, "Cores"); + } + + private void DisplayThreadAffinityGroup(ThreadAffinityGroup group, Platform platform, + float threadsWidth, float affinitiesWidth, float anyButtonWidth, GUIContent anyButtonContent, + GUIStyle affinityStyle, float affinityWidth, out bool delete) + { + delete = false; + + GUIStyle editButtonStyle = EditorStyles.popup; + + GUIContent editButtonContent = new GUIContent("Edit"); + Rect editButtonRect = new Rect(Vector2.zero, editButtonStyle.CalcSize(editButtonContent)); + + float threadsHeight = group.threads.Count * EditorGUIUtility.singleLineHeight; + + bool editable = platform.ThreadAffinitiesProperty.HasValue; + + if (editable) + { + threadsHeight += EditorGUIUtility.standardVerticalSpacing + editButtonRect.height; + } + + float affinitiesHeight = + Mathf.Ceil(platform.CoreCount / (float)THREAD_AFFINITY_CORES_PER_ROW) * EditorGUIUtility.singleLineHeight; + + Rect controlRect = EditorGUILayout.GetControlRect(false, Math.Max(threadsHeight, affinitiesHeight)); + + Rect threadsRect = controlRect; + threadsRect.width = threadsWidth; + + threadsRect = EditorGUI.IndentedRect(threadsRect); + + GUIStyle boxStyle = EditorStyles.textArea; + + GUI.Box(threadsRect, string.Empty, boxStyle); + + Rect threadRect = threadsRect; + threadRect.height = EditorGUIUtility.singleLineHeight; + + foreach (ThreadType thread in group.threads) + { + GUI.Label(threadRect, thread.DisplayName()); + threadRect.y += threadRect.height; + } + + if (editable) + { + editButtonRect.y = threadsRect.yMax - editButtonRect.height - editButtonStyle.margin.bottom; + editButtonRect.center = new Vector2(threadsRect.center.x, editButtonRect.center.y); + + if (EditorGUI.DropdownButton(editButtonRect, editButtonContent, FocusType.Passive, editButtonStyle)) + { + ThreadListEditor.Show(editButtonRect, group, platform, this); + } + } + + Rect affinitiesRect = controlRect; + affinitiesRect.xMin = threadsRect.xMax; + affinitiesRect.width = affinitiesWidth; + + GUI.Box(affinitiesRect, string.Empty, boxStyle); + + Rect anyButtonRect = affinitiesRect; + anyButtonRect.height = affinitiesHeight; + anyButtonRect.width = anyButtonWidth; + + if (GUI.Toggle(anyButtonRect, group.affinity == ThreadAffinity.Any, anyButtonContent, affinityStyle)) + { + group.affinity = ThreadAffinity.Any; + } + + Rect affinityRect = affinitiesRect; + affinityRect.x = anyButtonRect.xMax; + affinityRect.height = EditorGUIUtility.singleLineHeight; + affinityRect.width = affinityWidth; + + for (int i = 0; i < platform.CoreCount; ++i) + { + ThreadAffinity mask = (ThreadAffinity)(1U << i); + + if (GUI.Toggle(affinityRect, (group.affinity & mask) == mask, i.ToString(), affinityStyle)) + { + group.affinity |= mask; + } + else + { + group.affinity &= ~mask; + } + + if (i % THREAD_AFFINITY_CORES_PER_ROW == THREAD_AFFINITY_CORES_PER_ROW - 1) + { + affinityRect.x = anyButtonRect.xMax; + affinityRect.y += affinityRect.height; + } + else + { + affinityRect.x += affinityRect.width; + } + } + + if (editable) + { + GUIStyle deleteButtonStyle = GUI.skin.button; + GUIContent deleteButtonContent = new GUIContent("Delete"); + + Rect deleteButtonRect = controlRect; + deleteButtonRect.x = affinitiesRect.xMax; + deleteButtonRect.width = deleteButtonStyle.CalcSize(deleteButtonContent).x; + + if (GUI.Button(deleteButtonRect, deleteButtonContent, deleteButtonStyle)) + { + delete = true; + } + } + } + + private class ThreadListEditor : EditorWindow + { + private ThreadAffinityGroup group; + private Platform platform; + private Editor parent; + + public static void Show(Rect buttonRect, ThreadAffinityGroup group, Platform platform, Editor parent) + { + ThreadListEditor editor = CreateInstance(); + editor.group = group; + editor.platform = platform; + editor.parent = parent; + + Rect rect = new Rect(GUIUtility.GUIToScreenPoint(buttonRect.position), buttonRect.size); + + editor.ShowAsDropDown(rect, CalculateSize()); + } + + private static GUIStyle FrameStyle { get { return GUI.skin.box; } } + private static GUIStyle ThreadStyle { get { return EditorStyles.toggle; } } + + private static Vector2 CalculateSize() + { + Vector2 result = Vector2.zero; + + Array enumValues = Enum.GetValues(typeof(ThreadType)); + + foreach (ThreadType thread in enumValues) + { + Vector2 size = ThreadStyle.CalcSize(new GUIContent(thread.DisplayName())); + result.x = Mathf.Max(result.x, size.x); + } + + result.y = enumValues.Length * EditorGUIUtility.singleLineHeight + + (enumValues.Length - 1) * EditorGUIUtility.standardVerticalSpacing; + + result.x += FrameStyle.padding.horizontal; + result.y += FrameStyle.padding.vertical; + + return result; + } + + private void OnGUI() + { + Rect frameRect = new Rect(0, 0, position.width, position.height); + + GUI.Box(frameRect, string.Empty, FrameStyle); + + Rect threadRect = FrameStyle.padding.Remove(frameRect); + threadRect.height = EditorGUIUtility.singleLineHeight; + + foreach (ThreadType thread in Enum.GetValues(typeof(ThreadType))) + { + EditorGUI.BeginChangeCheck(); + + bool include = EditorGUI.ToggleLeft(threadRect, thread.DisplayName(), group.threads.Contains(thread)); + + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(platform, EditPlatformUndoMessage); + + if (include) + { + // Make sure each thread is only in one group + foreach (ThreadAffinityGroup other in platform.ThreadAffinities) + { + other.threads.Remove(thread); + } + + group.threads.Add(thread); + group.threads.Sort(); + } + else + { + group.threads.Remove(thread); + } + + parent.Repaint(); + } + + threadRect.y = threadRect.yMax + EditorGUIUtility.standardVerticalSpacing; + } + } + } + + private void DisplayCodecChannels(string label, Platform platform) + { + if (platform is PlatformGroup) + { + return; + } + + if (DisplayCodecChannelsFoldout(label, platform)) + { + using (new EditorGUI.IndentLevelScope()) + { + bool editable = platform.CodecChannelsProperty.HasValue; + + using (new EditorGUI.DisabledScope(!editable)) + { + foreach (CodecChannelCount channelCount in platform.CodecChannels) + { + EditorGUI.BeginChangeCheck(); + + int channels = EditorGUILayout.IntSlider(channelCount.format.ToString(), channelCount.channels, 0, 256); + + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(platform, "Edit Codec Channels"); + + channelCount.channels = channels; + } + } + } + } + } + } + + private bool DisplayCodecChannelsFoldout(string label, Platform platform) + { + Rect controlRect = EditorGUILayout.GetControlRect(); + + Rect labelRect = controlRect; + labelRect.width = EditorGUIUtility.labelWidth; + + expandCodecChannels = EditorGUI.Foldout(labelRect, expandCodecChannels, label, true); + + bool useDefaults = !platform.CodecChannelsProperty.HasValue; + + EditorGUI.BeginChangeCheck(); + + Rect toggleRect = controlRect; + toggleRect.xMin = labelRect.xMax; + + useDefaults = GUI.Toggle(toggleRect, useDefaults, "Use Defaults"); + + if (EditorGUI.EndChangeCheck()) + { + if (useDefaults) + { + platform.CodecChannelsProperty.Value = null; + platform.CodecChannelsProperty.HasValue = false; + } + else + { + platform.CodecChannelsProperty.Value = new List(); + platform.CodecChannelsProperty.HasValue = true; + + foreach (CodecChannelCount channelCount in platform.DefaultCodecChannels) + { + platform.CodecChannelsProperty.Value.Add(new CodecChannelCount(channelCount)); + } + } + } + + return expandCodecChannels; + } + + private void DisplaySampleRate(string label, Platform platform) + { + Platform.PropertyAccessor property = Platform.PropertyAccessors.SampleRate; + + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + + EditorGUI.BeginChangeCheck(); + + int currentIndex = Math.Max(0, Array.IndexOf(FrequencyValues, platform.SampleRate)); + int nextIndex = DrawPopup(rect, currentIndex, FrequencyDisplay); + + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, FrequencyValues[nextIndex]); + } + } + + private void DisplayProjectPlatform(string label, Platform platform) + { + Rect rect = DrawPlatformPropertyLabel(label, platform, + Platform.PropertyAccessors.BuildDirectory, Platform.PropertyAccessors.SpeakerMode); + + int speakerModeIndex = Math.Max(0, Array.IndexOf(SpeakerModeValues, platform.SpeakerMode)); + string speakerModeName = SpeakerModeDisplay[speakerModeIndex]; + + if (GUI.Button(rect, string.Format("{0} ({1})", platform.BuildDirectory, speakerModeName))) + { + PopupWindow.Show(rect, new ProjectPlatformSelector(platform, this)); + } + } + + private class ProjectPlatformSelector : PopupWindowContent + { + private Platform platform; + private SettingsEditor settingsEditor; + private string[] outputSubdirectories; + + private GUIStyle headerStyle; + private GUIStyle toggleStyle; + + private GUIContent subdirectoryHeader = new GUIContent("Output sub-directory:"); + private GUIContent speakerModeHeader = new GUIContent("Surround speaker mode:"); + + private const string HelpText = "Select the output sub-directory and speaker mode that match the project " + + "platform settings in the FMOD Studio build preferences."; + private const string UndoText = "Edit FMOD Platform Settings"; + + private const float InterColumnSpace = 25; + + private Vector2 subdirectorySize; + private Vector2 speakerModeSize; + private Vector2 helpButtonSize; + + private Vector2 windowSize; + + public ProjectPlatformSelector(Platform platform, SettingsEditor settingsEditor) + { + this.platform = platform; + this.settingsEditor = settingsEditor; + + headerStyle = GUI.skin.label; + + toggleStyle = new GUIStyle(EditorStyles.radioButton); + toggleStyle.margin.left = headerStyle.margin.left + 10; + + outputSubdirectories = EditorUtils.GetBankPlatforms(); + + Vector2 subdirectoryHeaderSize = headerStyle.CalcSize(subdirectoryHeader); + + subdirectorySize = ToggleGroupSize(outputSubdirectories); + subdirectorySize.x = Math.Max(subdirectoryHeaderSize.x, subdirectorySize.x); + subdirectorySize.y += subdirectoryHeaderSize.y + headerStyle.margin.bottom; + + Vector2 speakerModeHeaderSize = headerStyle.CalcSize(speakerModeHeader); + + speakerModeSize = ToggleGroupSize(SpeakerModeDisplay); + speakerModeSize.x = Math.Max(speakerModeHeaderSize.x, speakerModeSize.x); + speakerModeSize.y += speakerModeHeaderSize.y + headerStyle.margin.bottom; + + helpButtonSize = EditorUtils.GetHelpButtonSize(); + + float width = headerStyle.margin.left + subdirectorySize.x + InterColumnSpace + speakerModeSize.x + + helpButtonSize.x; + float height = Math.Max(subdirectorySize.y, speakerModeSize.y); + + windowSize = new Vector2(width, height); + } + + private Vector2 ToggleGroupSize(IEnumerable labels) + { + Vector2 totalSize = Vector2.zero; + + foreach (string label in labels) + { + Vector2 size = toggleStyle.CalcSize(new GUIContent(label)); + + totalSize.x = Math.Max(totalSize.x, size.x); + totalSize.y += size.y + toggleStyle.margin.top; + } + + totalSize.y += toggleStyle.margin.bottom; + + return totalSize; + } + + public override Vector2 GetWindowSize() + { + return windowSize; + } + + public override void OnGUI(Rect rect) + { + float y = rect.y + headerStyle.margin.top; + + Rect subdirectoryRect = new Rect(rect.x + headerStyle.margin.left, y, subdirectorySize.x, rect.height); + + using (new GUILayout.AreaScope(subdirectoryRect)) + { + GUILayout.Label(subdirectoryHeader, headerStyle); + + foreach (string buildDirectory in outputSubdirectories) + { + bool selected = (platform.BuildDirectory == buildDirectory); + + EditorGUI.BeginChangeCheck(); + + selected = GUILayout.Toggle(selected, buildDirectory, toggleStyle); + + if (EditorGUI.EndChangeCheck() && selected) + { + Undo.RecordObject(platform, UndoText); + + Platform.PropertyAccessors.BuildDirectory.Set(platform, buildDirectory); + + // Ensure SpeakerMode is also overridden + Platform.PropertyAccessors.SpeakerMode.Set(platform, platform.SpeakerMode); + + settingsEditor.Repaint(); + } + } + } + + Rect speakerModeRect = new Rect(subdirectoryRect.xMax + InterColumnSpace, y, speakerModeSize.x, rect.height); + + using (new GUILayout.AreaScope(speakerModeRect)) + { + GUILayout.Label(speakerModeHeader, headerStyle); + + for (int i = 0; i < SpeakerModeValues.Length; ++i) + { + bool selected = (platform.SpeakerMode == SpeakerModeValues[i]); + + EditorGUI.BeginChangeCheck(); + + selected = GUILayout.Toggle(selected, SpeakerModeDisplay[i], toggleStyle); + + if (EditorGUI.EndChangeCheck() && selected) + { + Undo.RecordObject(platform, UndoText); + + Platform.PropertyAccessors.SpeakerMode.Set(platform, SpeakerModeValues[i]); + + // Ensure BuildDirectory is also overridden + Platform.PropertyAccessors.BuildDirectory.Set(platform, platform.BuildDirectory); + + settingsEditor.Repaint(); + } + } + } + + Rect helpButtonRect = new Rect(speakerModeRect.xMax, y, helpButtonSize.x, helpButtonSize.y); + EditorUtils.DrawHelpButton(helpButtonRect, () => new SimpleHelp(HelpText)); + } + } + + private void DisplaySpeakerMode(string label, Platform platform) + { + const string HelpText = "Select the speaker mode that matches the project " + + "platform settings in the FMOD Studio build preferences."; + + Rect rect = EditorUtils.DrawHelpButtonLayout(() => new SimpleHelp(HelpText)); + + Rect labelRect = LabelRect(rect); + + GUI.Label(labelRect, label); + + Rect speakerModeRect = rect; + speakerModeRect.xMin = labelRect.xMax; + + int currentIndex = Math.Max(0, Array.IndexOf(SpeakerModeValues, platform.SpeakerMode)); + + int next = DrawPopup(speakerModeRect, currentIndex, SpeakerModeDisplay); + + Platform.PropertyAccessors.SpeakerMode.Set(platform, SpeakerModeValues[next]); + } + + private void DisplayCallbackHandler(string label, Platform platform) + { + Platform.PropertyAccessor property = Platform.PropertyAccessors.CallbackHandler; + + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + + using (new NoIndentScope()) + { + EditorGUI.BeginChangeCheck(); + + PlatformCallbackHandler next = EditorGUI.ObjectField(rect, property.Get(platform), + typeof(PlatformCallbackHandler), false) as PlatformCallbackHandler; + + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, next); + } + } + } + + private void DisplayInt(string label, Platform platform, Platform.PropertyAccessor property, int min, int max) + { + int currentValue = property.Get(platform); + + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + + using (new NoIndentScope()) + { + EditorGUI.BeginChangeCheck(); + + int next = EditorGUI.IntSlider(rect, currentValue, min, max); + + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, next); + } + } + } + + private void DisplayLiveUpdatePort(string label, Platform platform, Platform.PropertyAccessor property) + { + Rect rect = DrawPlatformPropertyLabel(label, platform, property); + + GUIContent resetContent = new GUIContent("Reset"); + + Rect resetRect = rect; + resetRect.xMin = resetRect.xMax - GUI.skin.button.CalcSize(resetContent).x; + + Rect textRect = rect; + textRect.xMax = resetRect.xMin; + + using (new NoIndentScope()) + { + EditorGUI.BeginChangeCheck(); + + int next = EditorGUI.IntField(textRect, property.Get(platform)); + + if (GUI.Button(resetRect, resetContent)) + { + next = 9264; + } + + if (EditorGUI.EndChangeCheck()) + { + property.Set(platform, next); + } + } + } + + private void DisplayPlatform(Platform platform) + { + if (!platform.Active) + { + return; + } + + DisplayPlatformHeader(platform); + + Undo.RecordObject(platform, EditPlatformUndoMessage); + + Settings settings = target as Settings; + + using (new EditorGUI.IndentLevelScope()) + { + EditorGUI.BeginChangeCheck(); + DisplayTriStateBool("Live Update", platform, Platform.PropertyAccessors.LiveUpdate); + + if (platform.IsLiveUpdateEnabled) + { + DisplayLiveUpdatePort("Live Update Port", platform, Platform.PropertyAccessors.LiveUpdatePort); + } + + DisplayTriStateBool("Debug Overlay", platform, Platform.PropertyAccessors.Overlay); + if (platform.IsOverlayEnabled) + { + DisplayPositionRect("Debug Location", platform, Platform.PropertyAccessors.OverlayPosition); + DisplayDebugFontSelection("Font size", platform, Platform.PropertyAccessors.OverlayFontSize); + } + + DisplayOutputMode("Output Mode", platform); + DisplaySampleRate("Sample Rate", platform); + + if (settings.HasPlatforms) + { + DisplayProjectPlatform("Project Platform", platform); + } + else if (platform is PlatformDefault) + { + DisplaySpeakerMode("Speaker Mode", platform); + } + + DisplayCallbackHandler("Callback Handler", platform); + + DisplayInt("Virtual Channel Count", platform, Platform.PropertyAccessors.VirtualChannelCount, 1, 2048); + DisplayInt("Real Channel Count", platform, Platform.PropertyAccessors.RealChannelCount, 1, 256); + + DisplayCodecChannels("Codec Counts", platform); + + DisplayDSPBufferSettings(platform); + + string warning = null; + + BuildTargetGroup buildTargetGroup = + BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); +#if UNITY_2021_2_OR_NEWER + NamedBuildTarget namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup); + ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(namedBuildTarget); +#else + ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(buildTargetGroup); +#endif + + if (scriptingBackend != ScriptingImplementation.IL2CPP) + { + warning = "Only supported on the IL2CPP scripting backend"; + } + + DisplayPlugins("Static Plugins", staticPluginsView, platform, ref expandStaticPlugins, warning); + + DisplayPlugins("Dynamic Plugins", dynamicPluginsView, platform, ref expandDynamicPlugins); + + DisplayThreadAffinity("Thread Affinity", platform); + + if (EditorGUI.EndChangeCheck()) + { + EditorUtility.SetDirty(target); + } + } + } + + private void DisplayPlatformHeader(Platform platform) + { + string type; + + if (platform is PlatformGroup) + { + type = "platform group"; + } + else if (platform.IsIntrinsic) + { + type = "built-in platform"; + } + else + { + type = "platform"; + } + + if (platform.Parent != null || platform is PlatformPlayInEditor) + { + Platform parent; + GUIContent labelContent; + + if (platform is PlatformPlayInEditor) + { + labelContent = new GUIContent(string.Format("{0}: {1} inheriting from Unity build target: ", + platform.DisplayName, type)); + parent = EditorSettings.Instance.CurrentEditorPlatform; + + while (!parent.Active) + { + parent = parent.Parent; + } + } + else + { + labelContent = new GUIContent(string.Format("{0}: {1} inheriting from", platform.DisplayName, type)); + parent = platform.Parent; + } + + Rect rect = EditorGUILayout.GetControlRect(); + + GUIContent buttonContent = new GUIContent(string.Format("{0}", parent.DisplayName)); + GUIContent iconContent = EditorGUIUtility.IconContent("UnityEditor.FindDependencies"); + + Rect labelRect = LabelRect(rect); + labelRect.width = platformHeaderStyle.CalcSize(labelContent).x; + + Rect buttonRect = rect; + buttonRect.x = labelRect.xMax; + buttonRect.width = platformHeaderStyle.CalcSize(buttonContent).x; + + Rect iconRect = rect; + iconRect.x = buttonRect.xMax; + iconRect.width = iconContent.image.width; + iconRect.height = iconContent.image.height; + iconRect.y += (rect.height - iconRect.height) / 2; + + buttonRect.width += iconRect.width; + + GUI.Label(labelRect, labelContent, platformHeaderStyle); + + if (GUI.Button(buttonRect, buttonContent, platformHeaderStyle)) + { + platformsView.SelectAndFramePlatform(parent); + } + + if (Event.current.type == EventType.Repaint) + { + GUI.DrawTexture(iconRect, iconContent.image); + } + + EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link); + } + else + { + string text = string.Format("{0}: {1}", platform.DisplayName, type); + EditorGUILayout.LabelField(text, platformHeaderStyle); + } + } + + private void DisplayDSPBufferSettings(Platform platform) + { + Rect rect = DrawPlatformPropertyLabel("DSP Buffer Settings", platform, + Platform.PropertyAccessors.DSPBufferLength, Platform.PropertyAccessors.DSPBufferCount); + + bool useAutoDSPBufferSettings = DisplayAutoDSPBufferSettings(rect, platform); + + if (!useAutoDSPBufferSettings) + { + DisplayDSPBufferFields(platform); + } + } + + private bool DisplayAutoDSPBufferSettings(Rect rect, Platform platform) + { + Platform.PropertyAccessor lengthProperty = Platform.PropertyAccessors.DSPBufferLength; + Platform.PropertyAccessor countProperty = Platform.PropertyAccessors.DSPBufferCount; + + GUIStyle style = GUI.skin.toggle; + + GUIContent content = new GUIContent("Auto"); + rect.width = style.CalcSize(content).x; + + bool useAutoDSPBufferSettings = lengthProperty.Get(platform) == 0 && countProperty.Get(platform) == 0; + + EditorGUI.BeginChangeCheck(); + + useAutoDSPBufferSettings = GUI.Toggle(rect, useAutoDSPBufferSettings, content, style); + + if (EditorGUI.EndChangeCheck()) + { + if (useAutoDSPBufferSettings) + { + lengthProperty.Set(platform, 0); + countProperty.Set(platform, 0); + + } + else + { + // set a helpful default value (real default is 0 for auto behaviour) + lengthProperty.Set(platform, 512); + countProperty.Set(platform, 4); + } + } + + return useAutoDSPBufferSettings; + } + + private void DisplayDSPBufferFields(Platform platform) + { + Platform.PropertyAccessor lengthProperty = Platform.PropertyAccessors.DSPBufferLength; + Platform.PropertyAccessor countProperty = Platform.PropertyAccessors.DSPBufferCount; + + using (new EditorGUI.IndentLevelScope()) + { + EditorGUI.BeginChangeCheck(); + + int nextLength = Mathf.Max(EditorGUILayout.IntField("DSP Buffer Length", lengthProperty.Get(platform)), 8); + int nextCount = Mathf.Max(EditorGUILayout.IntField("DSP Buffer Count", countProperty.Get(platform)), 2); + + if (EditorGUI.EndChangeCheck()) + { + lengthProperty.Set(platform, nextLength); + countProperty.Set(platform, nextCount); + } + } + } + + private void DisplayPlugins(string title, PlatformPropertyStringListView view, Platform platform, + ref bool expand, string warning = null) + { + List plugins = view.property.Get(platform); + + string fullTitle = string.Format("{0}: {1}", title, plugins.Count); + + DrawPlatformPropertyFoldout(fullTitle, ref expand, platform, view.property); + + if (expand) + { + using (new EditorGUI.IndentLevelScope()) + { + if (warning != null) + { + EditorGUILayout.HelpBox(warning, MessageType.Warning); + } + + view.platform = platform; + view.DrawLayout(); + } + } + } + + protected override void OnHeaderGUI() + { + AffirmResources(); + + GUIContent text = new GUIContent("FMOD Settings"); + + Vector2 textSize = mainHeaderStyle.CalcSize(text); + Vector2 iconSize = GUI.skin.label.CalcSize(mainHeaderIcon); + + Rect rect = EditorGUILayout.GetControlRect(false, Math.Max(textSize.y, iconSize.y)); + + Rect iconRect = rect; + iconRect.width = iconSize.x; + iconRect.height = iconSize.y; + iconRect.y += (rect.height - iconRect.height) / 2; + + Rect textRect = rect; + textRect.xMin = iconRect.xMax; + textRect.height = textSize.y; + textRect.y += (rect.height - textRect.height) / 2; + + GUI.Label(iconRect, mainHeaderIcon); + GUI.Label(textRect, text, mainHeaderStyle); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + string invalidSourceMessage = CheckValidSource(); + + DrawImportSection(invalidSourceMessage); + + if (invalidSourceMessage != null) + { + serializedObject.ApplyModifiedProperties(); + return; + } + + EditorGUILayout.Separator(); + + DrawInitializationSection(); + + EditorGUILayout.Separator(); + + DrawBehaviorSection(); + + EditorGUILayout.Separator(); + + DrawUserInterfaceSection(); + + EditorGUILayout.Separator(); + + DrawPlatforms(); + + serializedObject.ApplyModifiedProperties(); + + ApplyPendingActions(); + } + + private bool DrawSectionHeaderLayout(Section section, string title) + { + Rect rect = EditorGUILayout.GetControlRect(); + + return DrawSectionHeader(rect, section, title); + } + + private bool DrawSectionHeader(Rect rect, Section section, string title) + { + AffirmResources(); + + bool expanded = (section & sExpandedSections) == section; + + expanded = EditorGUI.Foldout(rect, expanded, title, true, sectionHeaderStyle); + + sExpandedSections = expanded ? (sExpandedSections | section) : (sExpandedSections & ~section); + + return expanded; + } + + private void DrawImportSection(string invalidSourceMessage) + { + if (DrawSectionHeaderLayout(Section.BankImport, "Bank Import")) + { + using (new EditorGUI.IndentLevelScope()) + { + DrawSourceSelection(invalidSourceMessage); + + if (invalidSourceMessage != null) + { + return; + } + + DrawTargetSelection(); + } + } + } + + private void DrawSourceSelection(string invalidSourceMessage) + { + Rect popupRect = EditorUtils.DrawHelpButtonLayout(() => new SourceSelectionHelp()); + + hasBankSourceChanged = false; + + SourceType sourceType = hasSourceProject.boolValue + ? SourceType.FMODStudioProject + : (hasPlatforms.boolValue ? SourceType.MultiplePlatformBuild : SourceType.SinglePlatformBuild); + + sourceType = (SourceType)EditorGUI.EnumPopup(popupRect, "Source Type", sourceType); + + if (sourceType == SourceType.FMODStudioProject) + { + string oldPath = sourceProjectPath.stringValue; + + using (new EditorGUILayout.HorizontalScope()) + { + EditorGUI.BeginChangeCheck(); + string newPath = EditorGUILayout.TextField("Studio Project Path", sourceProjectPath.stringValue); + if (EditorGUI.EndChangeCheck()) + { + if (newPath.EndsWith(".fspro")) + { + sourceProjectPath.stringValue = newPath; + } + } + + if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) + { + GUI.FocusControl(null); + EditorApplication.delayCall += BrowseForSourceProjectPathAndRefresh; + } + } + + // Cache in settings for runtime access in play-in-editor mode + sourceBankPath.stringValue = GetBankDirectory(serializedObject); + hasPlatforms.boolValue = true; + hasSourceProject.boolValue = true; + + // First time project path is set or changes, copy to streaming assets + if (sourceProjectPath.stringValue != oldPath) + { + hasBankSourceChanged = true; + } + } + else if (sourceType == SourceType.SinglePlatformBuild || sourceType == SourceType.MultiplePlatformBuild) + { + string oldPath = sourceBankPath.stringValue; + + using (new EditorGUILayout.HorizontalScope()) + { + EditorGUILayout.PropertyField(sourceBankPath, new GUIContent("Build Path")); + + if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) + { + GUI.FocusControl(null); + EditorApplication.delayCall += BrowseForSourceBankPathAndRefresh; + } + } + + hasPlatforms.boolValue = (sourceType == SourceType.MultiplePlatformBuild); + hasSourceProject.boolValue = false; + + // First time project path is set or changes, copy to streaming assets + if (sourceBankPath.stringValue != oldPath) + { + hasBankSourceChanged = true; + } + } + + if (invalidSourceMessage != null) + { + EditorGUILayout.HelpBox(invalidSourceMessage, MessageType.Error, true); + } + } + + private void BrowseForSourceProjectPathAndRefresh() + { + if (BrowseForSourceProjectPath(serializedObject)) + { + Repaint(); + } + } + + private void BrowseForSourceBankPathAndRefresh() + { + if (BrowseForSourceBankPath(serializedObject, hasPlatforms.boolValue)) + { + Repaint(); + } + } + + private string CheckValidSource() + { + bool validSource; + string invalidMessage; + EditorUtils.ValidateSource(out validSource, out invalidMessage); + + if (validSource) + { + return null; + } + else + { + sExpandedSections |= Section.BankImport; + + return invalidMessage + "\n\nFor detailed setup instructions, please see the FMOD/Help/Getting Started menu item."; + } + } + + private class SourceSelectionHelp : HelpContent + { + private GUIStyle style; + + private readonly GUIContent introduction = new GUIContent("Choose how to access your FMOD Studio content:"); + + private readonly ListEntry[] listEntries = { + new ListEntry("FMOD Studio Project", + "If you have the complete FMOD Studio project." + ), + new ListEntry("Single Platform Build", + "If you have the contents of the Build folder for a single platform." + ), + new ListEntry("Multiple Platform Build", + "If you have the contents of the Build folder for multiple platforms, " + + "with each platform in its own subdirectory." + ), + }; + + protected override void Prepare() + { + style = new GUIStyle(GUI.skin.label) { + richText = true, + wordWrap = true, + }; + } + + private struct ListEntry + { + public ListEntry(string label, string description) + { + this.label = new GUIContent(label); + this.description = new GUIContent(description); + } + + public GUIContent label; + public GUIContent description; + } + + protected override Vector2 GetContentSize() + { + Vector2 size = new Vector2(440, 0); + + size.y += style.margin.top; + size.y += style.CalcHeight(introduction, size.x); + + foreach (ListEntry entry in listEntries) + { + size.y += style.margin.top; + size.y += style.CalcHeight(entry.description, size.x - EditorGUIUtility.labelWidth); + } + + size.y += style.margin.bottom; + + return size; + } + + protected override void DrawContent() + { + EditorGUILayout.LabelField(introduction, style); + + using (new EditorGUI.IndentLevelScope()) + { + foreach (ListEntry entry in listEntries) + { + EditorGUILayout.LabelField(entry.label, entry.description, style); + } + } + } + } + + private static string GetBankDirectory(SerializedObject serializedObject) + { + var sourceProjectPath = serializedObject.FindProperty("sourceProjectPath"); + var sourceBankPath = serializedObject.FindProperty("sourceBankPath"); + var hasSourceProject = serializedObject.FindProperty("HasSourceProject"); + + if (hasSourceProject.boolValue && !string.IsNullOrEmpty(sourceProjectPath.stringValue)) + { + string projectFolder = Path.GetDirectoryName(sourceProjectPath.stringValue); + return RuntimeUtils.GetCommonPlatformPath(Path.Combine(projectFolder, EditorUtils.BuildFolder)); + } + else if (!string.IsNullOrEmpty(sourceBankPath.stringValue)) + { + return RuntimeUtils.GetCommonPlatformPath(Path.GetFullPath(sourceBankPath.stringValue)); + } + else + { + return null; + } + } + + private void DrawTargetSelection() + { + Settings settings = target as Settings; + + hasBankTargetChanged = false; + + string[] importTypeNames = importType.enumDisplayNames; + int importTypeIndex = importType.enumValueIndex; + + int newImportTypeIndex = EditorGUILayout.Popup("Import Type", importTypeIndex, importTypeNames); + + if (newImportTypeIndex != importType.enumValueIndex) + { + bool deleteBanks = EditorUtility.DisplayDialog( + "FMOD Bank Import Type Changed", + "Do you want to delete the " + importTypeNames[importTypeIndex] + " banks in " + settings.TargetPath, + "Yes", "No"); + + if (deleteBanks) + { + // Delete the old banks + EventManager.RemoveBanks(settings.TargetPath); + } + + hasBankTargetChanged = true; + importType.enumValueIndex = newImportTypeIndex; + } + + // ----- Asset Sub Directory ------------- + SerializedProperty targetSubFolder; + string label; + + if (importType.intValue == (int)ImportType.AssetBundle) + { + targetSubFolder = targetAssetPath; + label = "FMOD Asset Sub Folder"; + } + else + { + targetSubFolder = targetBankFolder; + label = "FMOD Bank Sub Folder"; + } + + string newSubFolder = EditorGUILayout.DelayedTextField(label, targetSubFolder.stringValue); + + if (newSubFolder != targetSubFolder.stringValue) + { + EventManager.RemoveBanks(settings.TargetPath); + targetSubFolder.stringValue = newSubFolder; + hasBankTargetChanged = true; + } + + DisplayBankRefreshSettings(bankRefreshCooldown, showBankRefreshWindow, true); + + EditorGUILayout.PropertyField(eventLinkage); + } + + private void DrawBehaviorSection() + { + if (DrawSectionHeaderLayout(Section.Behavior, "Behavior")) + { + using (new EditorGUI.IndentLevelScope()) + { + EditorGUILayout.PropertyField(stopEventsOutsideMaxDistance, + new GUIContent("Stop Events Outside Max Distance")); + } + } + } + + private void DrawUserInterfaceSection() + { + if (DrawSectionHeaderLayout(Section.UserInterface, "User Interface")) + { + using (new EditorGUI.IndentLevelScope()) + { + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(meterChannelOrdering, new GUIContent("Meter Channel Ordering")); + + if (EditorGUI.EndChangeCheck() && EventBrowser.IsOpen) + { + EditorWindow.GetWindow("FMOD Events", false).Repaint(); + } + } + } + } + + private void DrawInitializationSection() + { + if (DrawSectionHeaderLayout(Section.Initialization, "Initialization")) + { + using (new EditorGUI.IndentLevelScope()) + { + loggingLevel.intValue = EditorGUILayout.IntPopup("Logging Level", + loggingLevel.intValue, LoggingDisplay, LoggingValues); + + EditorGUILayout.PropertyField(enableErrorCallback, + new GUIContent("Enable API Error Logging")); + + EditorGUILayout.PropertyField(enableMemoryTracking, new GUIContent("Enable Memory Tracking")); + + using (new EditorGUI.DisabledScope(importType.intValue == (int)ImportType.AssetBundle)) + { + EditorGUILayout.PropertyField(bankLoadType, new GUIContent("Load Banks")); + + switch ((BankLoadType)bankLoadType.intValue) + { + case BankLoadType.All: + break; + case BankLoadType.Specified: + automaticEventLoading.boolValue = false; + DisplayBanksToLoad(); + break; + case BankLoadType.None: + automaticEventLoading.boolValue = false; + break; + default: + break; + } + + using (new EditorGUI.DisabledScope(bankLoadType.intValue == (int)BankLoadType.None)) + { + EditorGUILayout.PropertyField(automaticSampleLoading, new GUIContent("Load Bank Sample Data")); + } + + EditorGUILayout.DelayedTextField(encryptionKey, new GUIContent("Bank Encryption Key")); + } + } + } + } + + private void DisplayBanksToLoad() + { + banksToLoad.isExpanded = EditorGUILayout.Foldout(banksToLoad.isExpanded, "Specified Banks", true); + + if (banksToLoad.isExpanded) + { + using (new EditorGUI.IndentLevelScope()) + { + banksToLoadView.DrawLayout(); + } + } + } + + private void BrowseForBankToLoad() + { + string bankDirectory = CurrentBankDirectory(); + string path = EditorUtility.OpenFilePanel("Locate Bank", bankDirectory, "bank"); + + if (!string.IsNullOrEmpty(path)) + { + serializedObject.Update(); + + path = RuntimeUtils.GetCommonPlatformPath(path); + path = path.Replace(bankDirectory, ""); + path = Regex.Replace(path, "\\.bank$", ""); + + banksToLoad.ArrayAdd(p => p.stringValue = path); + + serializedObject.ApplyModifiedProperties(); + + Repaint(); + } + } + + private void AddAllBanksToLoad() + { + string sourceDir = CurrentBankDirectory(); + string[] banksFound = Directory.GetFiles(sourceDir, "*.bank", SearchOption.AllDirectories); + + serializedObject.Update(); + + for (int i = 0; i < banksFound.Length; i++) + { + string bankLongName = RuntimeUtils.GetCommonPlatformPath(Path.GetFullPath(banksFound[i])); + string bankShortName = bankLongName.Replace(sourceDir, ""); + bankShortName = Regex.Replace(bankShortName, "\\.bank$", ""); + + if (!banksToLoad.ArrayContains(p => p.stringValue == bankShortName)) + { + banksToLoad.ArrayAdd(p => p.stringValue = bankShortName); + } + } + + serializedObject.ApplyModifiedProperties(); + + Repaint(); + } + + private string CurrentBankDirectory() + { + Settings settings = target as Settings; + + string bankDirectory; + + if (settings.HasPlatforms) + { + bankDirectory = string.Format("{0}/{1}/", + settings.SourceBankPath, EditorSettings.Instance.CurrentEditorPlatform.BuildDirectory); + } + else + { + bankDirectory = settings.SourceBankPath + "/"; + } + + return RuntimeUtils.GetCommonPlatformPath(Path.GetFullPath(bankDirectory)); + } + + private void DrawPlatforms() + { + platformsView.ReloadIfNecessary(); + + if (DrawSectionHeaderLayout(Section.PlatformSpecific, "Platform Specific")) + { + using (new EditorGUI.IndentLevelScope()) + { + platformsView.DrawLayout(); + + Platform selectedPlatform = platformsView.SelectedPlatform; + + if (selectedPlatform != null) + { + DisplayPlatform(selectedPlatform); + } + } + } + } + + private class PlatformsView : TreeView + { + private const float RowPadding = 2; + + private Settings settings; + + private static UnityEditorInternal.ReorderableList.Defaults s_Defaults; + + private const float HeaderHeight = 3; + private const float BodyHeight = 150; + private const float FooterHeight = 13; + private const float TotalHeight = HeaderHeight + BodyHeight + FooterHeight; + + private const float ButtonWidth = 25; + private const float ButtonHeight = 16; + private const float ButtonMarginTop = 0; + + private const float FooterMarginRight = 10; + + private static readonly RectOffset BodyPadding = new RectOffset(1, 2, 1, 4); + private static readonly RectOffset FooterPadding = new RectOffset(4, 4, 0, 0); + + private static readonly Vector2 DragHandleSize = new Vector2(10, 7); + private static readonly Vector2 DragHandlePadding = new Vector2(5, 6); + + public PlatformsView(Settings settings, TreeViewState state) : base(state) + { + this.settings = settings; + rowHeight = EditorGUIUtility.singleLineHeight + RowPadding; + } + + public Platform SelectedPlatform + { + get + { + IList selection = GetSelection(); + + if (selection.Count != 1) + { + return null; + } + + PlatformItem selectedItem = FindItem(selection[0], rootItem) as PlatformItem; + + if (selectedItem == null) + { + return null; + } + + return selectedItem.platform; + } + } + + private static UnityEditorInternal.ReorderableList.Defaults defaultBehaviours + { + get + { + if (s_Defaults == null) + { + s_Defaults = new UnityEditorInternal.ReorderableList.Defaults(); + } + + return s_Defaults; + } + } + + public void DrawLayout() + { + Rect rect = EditorGUILayout.GetControlRect(false, TotalHeight); + rect = EditorGUI.IndentedRect(rect); + + Rect headerRect = rect; + headerRect.height = HeaderHeight; + + Rect bodyRect = rect; + bodyRect.y = headerRect.yMax; + bodyRect.height = BodyHeight; + + Rect footerRect = rect; + footerRect.xMax -= FooterMarginRight; + footerRect.y = bodyRect.yMax; + footerRect.height = FooterHeight; + + Rect removeRect = footerRect; + removeRect.x = footerRect.xMax - FooterPadding.right - ButtonWidth; + removeRect.y += ButtonMarginTop; + removeRect.width = ButtonWidth; + removeRect.height = ButtonHeight; + + Rect addRect = footerRect; + addRect.x = removeRect.x - ButtonWidth; + addRect.y += ButtonMarginTop; + addRect.width = ButtonWidth; + addRect.height = ButtonHeight; + + footerRect.xMin = addRect.xMin - FooterPadding.left; + footerRect.xMax = removeRect.xMax + FooterPadding.right; + + defaultBehaviours.DrawHeaderBackground(headerRect); + + if (Event.current.type == EventType.Repaint) + { + defaultBehaviours.boxBackground.Draw(bodyRect, false, false, false, false); + } + + Rect contentRect = BodyPadding.Remove(bodyRect); + + using (new NoIndentScope()) + { + base.OnGUI(contentRect); + } + + if (Event.current.type == EventType.Repaint) + { + defaultBehaviours.footerBackground.Draw(footerRect, false, false, false, false); + } + + if (GUI.Button(addRect, defaultBehaviours.iconToolbarPlusMore, defaultBehaviours.preButton)) + { + DoAddMenu(addRect); + } + + using (new EditorGUI.DisabledScope(SelectedPlatform == null)) + { + if (GUI.Button(removeRect, defaultBehaviours.iconToolbarMinus, defaultBehaviours.preButton)) + { + DeleteSelectedPlatform(); + } + } + } + + private void DoAddMenu(Rect rect) + { + GenericMenu menu = new GenericMenu(); + + menu.AddItem(new GUIContent("New Group"), false, AddGroup); + + menu.AddSeparator(string.Empty); + + IEnumerable missingPlatforms = settings.Platforms + .Where(p => !p.Active) + .OrderBy(p => p.DisplayName, new NaturalComparer()); + + foreach (Platform platform in missingPlatforms) + { + menu.AddItem(new GUIContent(platform.DisplayName), false, AddPlatform, platform.Identifier); + } + + menu.DropDown(rect); + } + + private void AddPlatform(object data) + { + string identifier = data as string; + + Platform platform = settings.FindPlatform(identifier); + + const string UndoMessage = "Add FMOD Platform"; + + Undo.RecordObjects(new UnityEngine.Object[] { settings, platform, platform.Parent }, UndoMessage); + + platform.DisplaySortOrder = UpdateSortOrderForChildren(platform.Parent, platform, UndoMessage); + + settings.AddPlatformProperties(platform); + + ForceReload(); + + SelectAndFramePlatform(platform); + } + + private void AddGroup() + { + const string UndoMessage = "Add FMOD Platform Group"; + + Undo.RecordObjects(new UnityEngine.Object[] { settings, settings.DefaultPlatform }, UndoMessage); + + int sortOrder = UpdateSortOrderForChildren(settings.DefaultPlatform, null, UndoMessage); + + PlatformGroup group = EditorSettings.Instance.AddPlatformGroup("New Group", sortOrder); + + Undo.RegisterCreatedObjectUndo(group, UndoMessage); + + ForceReload(); + + SelectAndFramePlatform(group); + + // Bring up the rename UI + DoubleClickedItem(group.Identifier.GetHashCode()); + } + + private int UpdateSortOrderForChildren(Platform platform, Platform skipChild, string undoMessage) + { + int sortOrder = 0; + + foreach (string childID in platform.ChildIdentifiers) + { + Platform child = settings.FindPlatform(childID); + + if (child.Active && child != skipChild) + { + Undo.RecordObject(child, undoMessage); + + child.DisplaySortOrder = sortOrder; + ++sortOrder; + } + } + + return sortOrder; + } + + // Removes a platform from the inheritance hierarchy and clears its properties, thus hiding + // it in the UI. Also destroys the platform if it is a group. + private void DeleteSelectedPlatform() + { + Platform platform = SelectedPlatform; + + if (platform == null || platform == settings.DefaultPlatform || platform == settings.PlayInEditorPlatform) + { + return; + } + + + const string UndoMessage = "Delete FMOD Platform"; + + Undo.RecordObjects(new UnityEngine.Object[] { platform, platform.Parent, settings }, UndoMessage); + + while (platform.ChildIdentifiers.Count > 0) + { + Platform child = settings.FindPlatform(platform.ChildIdentifiers[platform.ChildIdentifiers.Count - 1]); + + SetPlatformParent(UndoMessage, settings, child, platform.Parent, (int)platform.DisplaySortOrder + 1); + } + + if (platform is PlatformGroup) + { + PlatformGroup group = platform as PlatformGroup; + + settings.SetPlatformParent(group, null); + settings.RemovePlatform(group.Identifier); + + Undo.DestroyObjectImmediate(group); + } + else + { + platform.ClearProperties(); + + Undo.RecordObject(settings.DefaultPlatform, UndoMessage); + + settings.SetPlatformParent(platform, settings.DefaultPlatform); + } + + ForceReload(); + } + + public void SelectAndFramePlatform(Platform platform) + { + SetSelection(new List() { platform.Identifier.GetHashCode() }, + TreeViewSelectionOptions.RevealAndFrame); + } + + protected override void RowGUI(RowGUIArgs args) + { + if (Event.current.type == EventType.Repaint) + { + defaultBehaviours.elementBackground.Draw(args.rowRect, false, args.selected, args.selected, args.focused); + + if (IsItemDraggable(args.item)) + { + Rect dragRect = new Rect(args.rowRect.position + DragHandlePadding, DragHandleSize); + + defaultBehaviours.draggingHandle.Draw(dragRect, false, false, false, false); + } + + GUIContent labelContent = new GUIContent(args.label); + + GUIStyle labelStyle = GUI.skin.label; + + Rect labelRect = args.rowRect; + CenterRectUsingSingleLineHeight(ref labelRect); + + labelRect.x = GetContentIndent(args.item); + labelRect.width = GUI.skin.label.CalcSize(labelContent).x; + + Texture renameIcon = EditorGUIUtility.IconContent("SettingsIcon").image; + + bool canRename = CanRename(args.item); + + if (canRename) + { + labelContent.tooltip = "Double-click to rename"; + labelRect.width += renameIcon.width; + } + + GUI.Label(labelRect, labelContent); + + if (canRename && Event.current.type == EventType.Repaint) + { + Rect iconRect = new Rect() { + x = labelRect.xMax - renameIcon.width, + y = labelRect.yMax - labelStyle.padding.bottom - renameIcon.height, + width = renameIcon.width, + height = renameIcon.height, + }; + + GUI.DrawTexture(iconRect, renameIcon, ScaleMode.ScaleToFit, + true, 0, labelStyle.normal.textColor, 0, 0); + } + } + } + + public void ForceReload() + { + Reload(); + ExpandAll(); + } + + public void ReloadIfNecessary() + { + if (!isInitialized) + { + ForceReload(); + } + } + + protected override bool CanMultiSelect(TreeViewItem item) + { + return false; + } + + protected override bool CanChangeExpandedState(TreeViewItem item) + { + return false; + } + + protected override TreeViewItem BuildRoot() + { + TreeViewItem root = new TreeViewItem(-1, -1); + + root.AddChild(CreateItem(settings.PlayInEditorPlatform)); + + TreeViewItem defaultItem = CreateItem(settings.DefaultPlatform); + root.AddChild(defaultItem); + + CreateItems(defaultItem, settings.DefaultPlatform.ChildIdentifiers); + + SetupDepthsFromParentsAndChildren(root); + + return root; + } + + private class PlatformItem : TreeViewItem + { + public Platform platform; + + public PlatformItem(Platform platform) + : base(platform.Identifier.GetHashCode(), 0, platform.DisplayName) + { + this.platform = platform; + } + } + + private void CreateItems(TreeViewItem parent, IEnumerable platformIdentifiers) + { + foreach (string identifier in platformIdentifiers) + { + Platform platform = settings.FindPlatform(identifier); + + if (platform.Active) + { + TreeViewItem item = CreateItem(platform); + parent.AddChild(item); + + CreateItems(item, platform.ChildIdentifiers); + } + } + } + + private static TreeViewItem CreateItem(Platform platform) + { + return new PlatformItem(platform); + } + + protected override void DoubleClickedItem(int id) + { + TreeViewItem item = FindItem(id, rootItem); + + if (CanRename(item)) + { + BeginRename(item); + } + } + + protected override bool CanRename(TreeViewItem item) + { + PlatformItem platformItem = item as PlatformItem; + return (platformItem != null) && (platformItem.platform is PlatformGroup); + } + + protected override void RenameEnded(RenameEndedArgs args) + { + if (!args.acceptedRename || string.IsNullOrEmpty(args.newName)) + { + return; + } + + PlatformItem item = FindItem(args.itemID, rootItem) as PlatformItem; + + if (item == null) + { + return; + } + + PlatformGroup group = item.platform as PlatformGroup; + + if (group == null) + { + return; + } + + // Undo.RecordObject doesn't capture PlatformGroup.displayName, maybe due to inheritance? + // This means we need to use the SerializedObject interface instead. + SerializedObject serializedGroup = new SerializedObject(group); + SerializedProperty displayName = serializedGroup.FindProperty("displayName"); + + displayName.stringValue = args.newName; + + serializedGroup.ApplyModifiedProperties(); + + item.displayName = args.newName; + } + + protected override bool CanStartDrag(CanStartDragArgs args) + { + return IsItemDraggable(args.draggedItem); + } + + private bool IsItemDraggable(TreeViewItem draggedItem) + { + PlatformItem item = draggedItem as PlatformItem; + + return (item != null) && !item.platform.IsIntrinsic; + } + + protected override void SetupDragAndDrop(SetupDragAndDropArgs args) + { + PlatformItem item = FindItem(args.draggedItemIDs[0], rootItem) as PlatformItem; + + if (item != null) + { + DragAndDrop.PrepareStartDrag(); + DragAndDrop.objectReferences = new UnityEngine.Object[] { item.platform }; + DragAndDrop.StartDrag("Change FMOD Platform Inheritance"); + } + } + + protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args) + { + if (DragAndDrop.objectReferences.Length != 1) + { + return DragAndDropVisualMode.None; + } + + Platform draggedPlatform = DragAndDrop.objectReferences[0] as Platform; + + if (draggedPlatform == null) + { + return DragAndDropVisualMode.None; + } + + PlatformItem parentItem = args.parentItem as PlatformItem; + + if (parentItem == null) + { + return DragAndDropVisualMode.None; + } + + Platform parent = parentItem.platform; + + if (parent is PlatformPlayInEditor) + { + return DragAndDropVisualMode.None; + } + + switch (args.dragAndDropPosition) + { + case DragAndDropPosition.UponItem: + return HandleDragOverPlatform(draggedPlatform, parent, args.performDrop); + case DragAndDropPosition.BetweenItems: + return HandleDragBetweenChildren(draggedPlatform, parent, args.insertAtIndex, args.performDrop); + case DragAndDropPosition.OutsideItems: + return DragAndDropVisualMode.Move; + default: + return DragAndDropVisualMode.None; + } + } + + private DragAndDropVisualMode HandleDragOverPlatform(Platform draggedPlatform, Platform parent, bool performDrop) + { + if (parent == draggedPlatform) + { + return DragAndDropVisualMode.Move; + } + + if (parent.InheritsFrom(draggedPlatform)) + { + return DragAndDropVisualMode.None; + } + + if (performDrop) + { + SetPlatformParent("Set FMOD Platform Inheritance", settings, draggedPlatform, parent); + ForceReload(); + } + + return DragAndDropVisualMode.Link; + } + + private DragAndDropVisualMode HandleDragBetweenChildren(Platform draggedPlatform, Platform parent, + int insertAtIndex, bool performDrop) + { + if (parent.InheritsFrom(draggedPlatform)) + { + return DragAndDropVisualMode.None; + } + + if (performDrop) + { + SetPlatformParent("Set FMOD Platform Inheritance", settings, draggedPlatform, parent, insertAtIndex); + ForceReload(); + } + + return DragAndDropVisualMode.Move; + } + } + + private class ReorderableList : UnityEditorInternal.ReorderableList + { + private const float ElementPadding = 2; + + public ReorderableList(SerializedProperty property) + : base(property.serializedObject, property, true, false, true, true) + { + headerHeight = 3; + elementHeight = EditorGUIUtility.singleLineHeight + ElementPadding; + drawElementCallback = DrawElement; + } + + public void DrawLayout() + { + Rect rect = EditorGUILayout.GetControlRect(false, GetHeight()); + rect = EditorGUI.IndentedRect(rect); + + DoList(rect); + } + + private void DrawElement(Rect rect, int index, bool active, bool focused) + { + using (new NoIndentScope()) + { + rect.height -= ElementPadding; + + EditorGUI.PropertyField(rect, serializedProperty.GetArrayElementAtIndex(index), GUIContent.none); + } + } + } + + private class PlatformPropertyStringListView : UnityEditorInternal.ReorderableList + { + private const float ElementPadding = 2; + + public Platform platform; + + private List displayList; + + public PlatformPropertyStringListView(Platform.PropertyAccessor> property) + : base(null, typeof(string), true, false, true, true) + { + this.property = property; + + displayList = new List(); + list = displayList; + + headerHeight = 3; + elementHeight = EditorGUIUtility.singleLineHeight + ElementPadding; + + drawElementCallback = DrawElement; + onAddCallback = AddElement; + onRemoveCallback = RemoveElement; + onReorderCallback = OnReorder; + } + + public Platform.PropertyAccessor> property { get; private set; } + + // We need this because ReorderableList modifies the list before calling + // onReorderCallback, meaning we can't call AffirmOverriddenList + // soon enough. + public void DrawLayout() + { + if (IsReloadNeeded()) + { + displayList.Clear(); + displayList.AddRange(property.Get(platform)); + } + + Rect rect = EditorGUILayout.GetControlRect(false, GetHeight()); + rect = EditorGUI.IndentedRect(rect); + + DoList(rect); + } + + public bool IsReloadNeeded() + { + List propertyList = property.Get(platform); + + if (displayList.Count != propertyList.Count) + { + return true; + } + + for (int i = 0; i < displayList.Count; ++i) + { + if (displayList[i] != propertyList[i]) + { + return true; + } + } + + return false; + } + + private void DrawElement(Rect rect, int index, bool active, bool focused) + { + using (new NoIndentScope()) + { + rect.height -= ElementPadding; + + EditorGUI.BeginChangeCheck(); + + string newValue = EditorGUI.TextField(rect, list[index] as string); + + if (EditorGUI.EndChangeCheck()) + { + displayList[index] = newValue; + AffirmOverriddenList()[index] = newValue; + } + } + } + + private void AddElement(UnityEditorInternal.ReorderableList list) + { + AffirmOverriddenList().Add(string.Empty); + } + + private void RemoveElement(UnityEditorInternal.ReorderableList list) + { + AffirmOverriddenList().RemoveAt(list.index); + } + + private void OnReorder(UnityEditorInternal.ReorderableList list) + { + List propertyList = AffirmOverriddenList(); + + propertyList.Clear(); + propertyList.AddRange(displayList); + } + + private List AffirmOverriddenList() + { + if (!property.HasValue(platform)) + { + List newList = new List(property.Get(platform)); + + property.Set(platform, newList); + } + + return property.Get(platform); + } + } + + // If insertAtIndex == -1, insert at the end + private static void SetPlatformParent(string undoMessage, Settings settings, Platform child, Platform parent, int insertAtIndex = -1) + { + if (parent == child.Parent) + { + if (insertAtIndex > child.DisplaySortOrder) + { + --insertAtIndex; + } + + if (insertAtIndex == child.DisplaySortOrder) + { + return; + } + } + + Undo.RecordObjects(new[] { child, child.Parent, parent }, undoMessage); + + int index = 0; + + for (int i = 0; i < parent.ChildIdentifiers.Count; ++i) + { + Platform sibling = settings.FindPlatform(parent.ChildIdentifiers[i]); + + if (sibling.Active && sibling != child) + { + if (index == insertAtIndex) + { + ++index; + } + + Undo.RecordObject(sibling, undoMessage); + + sibling.DisplaySortOrder = index; + ++index; + } + } + + if (insertAtIndex == -1) + { + insertAtIndex = index; + } + + child.DisplaySortOrder = insertAtIndex; + + settings.SetPlatformParent(child, parent); + } + + private void ApplyPendingActions() + { + if (hasBankSourceChanged || hasBankTargetChanged) + { + RefreshBanks(); + } + } + + private void RefreshBanks() + { + Settings settings = target as Settings; + + if (lastSourceBankPath != settings.SourceBankPath) + { + lastSourceBankPath = settings.SourceBankPath; + EventManager.RefreshBanks(); + } + } + + public static void DisplayBankRefreshSettings(SerializedProperty cooldown, SerializedProperty showWindow, + bool inInspector) + { + Rect controlRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); + + Rect labelRect; + + if (inInspector) + { + labelRect = LabelRect(controlRect); + } + else + { + labelRect = EditorGUI.IndentedRect(controlRect); + labelRect.width = GUI.skin.label.CalcSize(BankRefreshLabel).x; + } + + + Rect popupRect = controlRect; + popupRect.x = labelRect.xMax; + popupRect.width = BankRefreshCooldownLabels.Max(l => EditorStyles.popup.CalcSize(l).x); + + using (new NoIndentScope()) + { + GUI.Label(labelRect, BankRefreshLabel); + + cooldown.intValue = EditorGUI.IntPopup(popupRect, cooldown.intValue, + BankRefreshCooldownLabels, BankRefreshCooldownValues); + + if (cooldown.intValue >= 0) + { + Rect toggleRect = controlRect; + toggleRect.xMin = popupRect.xMax + GUI.skin.toggle.margin.left; + + showWindow.boolValue = EditorGUI.ToggleLeft(toggleRect, "Show Status Window", showWindow.boolValue); + } + } + } + + private static Rect LabelRect(Rect controlRect) + { + Rect result = controlRect; + result.width = EditorGUIUtility.labelWidth; + result = EditorGUI.IndentedRect(result); + + return result; + } + + public static bool BrowseForSourceProjectPath(SerializedObject serializedObject) + { + serializedObject.Update(); + var sourceProjectPath = serializedObject.FindProperty("sourceProjectPath"); + var sourceBankPath = serializedObject.FindProperty("sourceBankPath"); + var hasSourceProject = serializedObject.FindProperty("HasSourceProject"); + var hasPlatforms = serializedObject.FindProperty("HasPlatforms"); + + string newPath = EditorUtility.OpenFilePanel("Locate Studio Project", sourceProjectPath.stringValue, "fspro"); + + if (string.IsNullOrEmpty(newPath)) + { + return false; + } + else + { + hasSourceProject.boolValue = true; + hasPlatforms.boolValue = true; + newPath = MakePathRelative(newPath); + sourceProjectPath.stringValue = newPath; + sourceBankPath.stringValue = GetBankDirectory(serializedObject); + serializedObject.ApplyModifiedProperties(); + EventManager.RefreshBanks(); + return true; + } + } + + public static bool BrowseForSourceBankPath(SerializedObject serializedObject, bool multiPlatform = false) + { + serializedObject.Update(); + var sourceBankPath = serializedObject.FindProperty("sourceBankPath"); + var hasSourceProject = serializedObject.FindProperty("HasSourceProject"); + var hasPlatforms = serializedObject.FindProperty("HasPlatforms"); + + string newPath = EditorUtility.OpenFolderPanel("Locate Build Folder", sourceBankPath.stringValue, null); + + if (string.IsNullOrEmpty(newPath)) + { + return false; + } + else + { + hasSourceProject.boolValue = false; + hasPlatforms.boolValue = multiPlatform; + newPath = MakePathRelative(newPath); + sourceBankPath.stringValue = newPath; + serializedObject.ApplyModifiedProperties(); + EventManager.RefreshBanks(); + return true; + } + } + + private static string MakePathRelative(string path) + { + if (string.IsNullOrEmpty(path)) + return ""; + string fullPath = Path.GetFullPath(path); + string fullProjectPath = Path.GetFullPath(Environment.CurrentDirectory + Path.DirectorySeparatorChar); + + // If the path contains the Unity project path remove it and return the result + if (fullPath.Contains(fullProjectPath)) + { + fullPath = fullPath.Replace(fullProjectPath, ""); + } + // If not, attempt to find a relative path on the same drive + else if (Path.GetPathRoot(fullPath) == Path.GetPathRoot(fullProjectPath)) + { + // Remove trailing slash from project path for split count simplicity + if (fullProjectPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.CurrentCulture)) fullProjectPath = fullProjectPath.Substring(0, fullProjectPath.Length - 1); + + string[] fullPathSplit = fullPath.Split(Path.DirectorySeparatorChar); + string[] projectPathSplit = fullProjectPath.Split(Path.DirectorySeparatorChar); + int minNumSplits = Mathf.Min(fullPathSplit.Length, projectPathSplit.Length); + int numCommonElements = 0; + for (int i = 0; i < minNumSplits; i++) + { + if (fullPathSplit[i] == projectPathSplit[i]) + { + numCommonElements++; + } + else + { + break; + } + } + string result = ""; + int fullPathSplitLength = fullPathSplit.Length; + for (int i = numCommonElements; i < fullPathSplitLength; i++) + { + result += fullPathSplit[i]; + if (i < fullPathSplitLength - 1) + { + result += '/'; + } + } + + int numAdditionalElementsInProjectPath = projectPathSplit.Length - numCommonElements; + for (int i = 0; i < numAdditionalElementsInProjectPath; i++) + { + result = "../" + result; + } + + fullPath = result; + } + + return fullPath.Replace(Path.DirectorySeparatorChar, '/'); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs.meta new file mode 100644 index 0000000..9dee342 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 353a9c870c318f74fa5fdcd475129bae +timeCreated: 1432530253 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs b/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs new file mode 100644 index 0000000..4ed4942 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs @@ -0,0 +1,1157 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace FMODUnity +{ + public class SetupWizardWindow : EditorWindow + { + private static SetupWizardWindow instance; + + private static readonly List pageNames = new List + { + "Welcome", + "Updating", + "Linking", + "Listener", + "Unity Audio", + "Unity Sources", + "Source Control", + "End" + }; + + private static readonly List pageComplete = new List(new bool[(int)PAGES.Max]); + + private static readonly List updateTasks = new List() { + UpdateTask.Create( + type: UpdateTaskType.ReorganizePluginFiles, + name: "Reorganize Plugin Files", + description: "Move FMOD for Unity files to match the latest layout.", + execute: FileReorganizer.ShowWindow, + checkComplete: FileReorganizer.IsUpToDate + ), + UpdateTask.Create( + type: UpdateTaskType.UpdateEventReferences, + name: "Update Event References", + description: "Find event references that use the obsolete [EventRef] attribute " + + "and update them to use the EventReference type.", + execute: EventReferenceUpdater.ShowWindow, + checkComplete: EventReferenceUpdater.IsUpToDate + ), + }; + + private static bool updateTaskStatusChecked = false; + + private PAGES currentPage = PAGES.Welcome; + + private AudioListener[] unityListeners; + private StudioListener[] fmodListeners; + private Vector2 scroll1, scroll2; + private Vector2 stagingDetailsScroll; + private bool bFoundUnityListener; + private bool bFoundFmodListener; + + private AudioSource[] unityAudioSources; + + private GUIStyle titleStyle; + private GUIStyle titleLeftStyle; + private GUIStyle bodyStyle; + private GUIStyle buttonStyle; + private GUIStyle navButtonStyle; + private GUIStyle sourceButtonStyle; + private GUIStyle descriptionStyle; + private GUIStyle crumbStyle; + private GUIStyle columnStyle; + private Color crumbDefault; + private Color crumbHighlight; + + private const string logoBlack = "FMODLogoBlack.png"; + private const string logoWhite = "FMODLogoWhite.png"; + + private Texture2D logoTexture; + private Texture2D tickTexture; + private Texture2D crossTexture; + private GUIStyle iconStyle; + + private const string backButtonText = "Back"; + + private SimpleTreeView m_SimpleTreeView; + private TreeViewState m_TreeViewState; + + private bool bStudioLinked; + + private static StagingSystem.UpdateStep nextStagingStep; + + private static bool IsStagingUpdateInProgress => nextStagingStep != null; + + private const string IgnoreFileText = +@"# Never ignore DLLs in the FMOD subfolder. +!/[Aa]ssets/Plugins/FMOD/**/lib/* + +# Don't ignore images and gizmos used by FMOD in the Unity Editor. +!/[Aa]ssets/Gizmos/FMOD/* +!/[Aa]ssets/Editor Default Resources/FMOD/* + +# Ignore the Cache folder since it is updated locally. +/[Aa]ssets/Plugins/FMOD/Cache/* + +# Ignore bank files in the StreamingAssets folder. +/[Aa]ssets/StreamingAssets/**/*.bank +/[Aa]ssets/StreamingAssets/**/*.bank.meta + +# If the source bank files are kept outside of the StreamingAssets folder then these can be ignored. +# Log files can be ignored. +fmod_editor.log"; + + private enum PAGES : int + { + Welcome = 0, + Updating, + Linking, + Listener, + UnityAudio, + UnitySources, + SourceControl, + End, + Max + } + + public enum UpdateTaskType + { + ReorganizePluginFiles, + UpdateEventReferences, + } + + private class UpdateTask + { + public UpdateTaskType Type; + public string Name; + public string Description; + public bool IsComplete; + public Action Execute; + public Func CheckComplete; + + public static UpdateTask Create(UpdateTaskType type, string name, string description, + Action execute, Func checkComplete) + { + return new UpdateTask() { + Type = type, + Name = name, + Description = description, + Execute = execute, + CheckComplete = checkComplete + }; + } + } + + public static void SetUpdateTaskComplete(UpdateTaskType type) + { + foreach (UpdateTask task in updateTasks.Where(t => t.Type == type)) + { + task.IsComplete = true; + } + } + + private static void CheckUpdateTaskStatus() + { + if (!updateTaskStatusChecked) + { + updateTaskStatusChecked = true; + + foreach (UpdateTask task in updateTasks) + { + task.IsComplete = task.CheckComplete(); + } + } + } + + private static void DoNextStagingStep() + { + nextStagingStep.Execute(); + nextStagingStep = StagingSystem.GetNextUpdateStep(); + } + + public static void Startup() + { + if (EditorApplication.isPlayingOrWillChangePlaymode) + return; + + Settings settings = Settings.Instance; + + if (settings.CurrentVersion != FMOD.VERSION.number) + { + // We're updating an existing installation; unhide the setup wizard if needed + + CheckUpdateTaskStatus(); + + if (settings.HideSetupWizard && updateTasks.Any(t => !t.IsComplete)) + { + settings.HideSetupWizard = false; + } + + settings.CurrentVersion = FMOD.VERSION.number; + EditorUtility.SetDirty(settings); + } + + nextStagingStep = StagingSystem.Startup(); + + if (!settings.HideSetupWizard || IsStagingUpdateInProgress) + { + ShowAssistant(); + } + } + + [MenuItem("FMOD/Setup Wizard")] + public static void ShowAssistant() + { + instance = (SetupWizardWindow)GetWindow(typeof(SetupWizardWindow), true, "FMOD Setup Wizard"); + instance.ShowUtility(); + instance.minSize = new Vector2(750, 500); + instance.maxSize = instance.minSize; + var position = new Rect(Vector2.zero, instance.minSize); + Vector2 screenCenter = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height) / 2; + position.center = screenCenter / EditorGUIUtility.pixelsPerPoint; + instance.position = position; + } + + private void OnEnable() + { + CheckUpdateTaskStatus(); + + logoTexture = EditorUtils.LoadImage(EditorGUIUtility.isProSkin ? logoWhite : logoBlack); + + crossTexture = EditorUtils.LoadImage("CrossYellow.png"); + tickTexture = EditorUtils.LoadImage("TickGreen.png"); + + titleStyle = new GUIStyle(); + titleStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; + titleStyle.wordWrap = true; + titleStyle.fontStyle = FontStyle.Bold; + titleStyle.alignment = TextAnchor.MiddleCenter; + + bodyStyle = new GUIStyle(titleStyle); + crumbStyle = new GUIStyle(titleStyle); + crumbDefault = EditorGUIUtility.isProSkin ? Color.gray : Color.gray; + crumbHighlight = EditorGUIUtility.isProSkin ? Color.white : Color.black; + + scroll1 = scroll2 = new Vector2(); + + iconStyle = new GUIStyle(); + iconStyle.alignment = TextAnchor.MiddleCenter; + + CheckUpdatesComplete(); + CheckStudioLinked(); + CheckListeners(); + CheckSources(); + CheckUnityAudio(); + } + + private void OnGUI() + { + if (buttonStyle == null) + { + buttonStyle = new GUIStyle("Button"); + buttonStyle.fixedHeight = 30; + + sourceButtonStyle = new GUIStyle("button"); + sourceButtonStyle.fixedWidth = 150; + sourceButtonStyle.fixedHeight = 35; + sourceButtonStyle.margin = new RectOffset(); + + descriptionStyle = new GUIStyle(titleStyle); + descriptionStyle.fontStyle = FontStyle.Normal; + descriptionStyle.alignment = TextAnchor.MiddleLeft; + descriptionStyle.margin = new RectOffset(5,0,0,0); + + titleLeftStyle = new GUIStyle(descriptionStyle); + titleLeftStyle.fontStyle = FontStyle.Bold; + + columnStyle = new GUIStyle(); + columnStyle.margin.left = 50; + columnStyle.margin.right = 50; + } + + // Draw Header + EditorGUILayout.Space(); + GUILayout.Box(logoTexture, titleStyle); + EditorGUILayout.Space(); + + if (IsStagingUpdateInProgress) + { + StagingUpdatePage(); + return; + } + + using (new EditorGUILayout.HorizontalScope()) + { + Breadcrumbs(); + + // Draw Body + using (new EditorGUILayout.VerticalScope("box", GUILayout.ExpandHeight(true))) + { + EditorGUILayout.Space(); + EditorGUILayout.Space(); + EditorGUILayout.Space(); + + switch (currentPage) + { + case PAGES.Welcome: WelcomePage(); break; + case PAGES.Updating: UpdatingPage(); break; + case PAGES.Linking: LinkingPage(); break; + case PAGES.Listener: ListenerPage(); break; + case PAGES.UnityAudio: DisableUnityAudioPage(); break; + case PAGES.UnitySources: UnitySources(); break; + case PAGES.SourceControl: SourceControl(); break; + case PAGES.End: EndPage(); break; + } + + Buttons(); + + if (currentPage == PAGES.Welcome) + { + EditorGUILayout.Space(); + EditorGUILayout.Space(); + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + + using (var check = new EditorGUI.ChangeCheckScope()) + { + bool hide = Settings.Instance.HideSetupWizard; + + hide = EditorGUILayout.Toggle("Do not display this again", hide); + + if (check.changed) + { + Settings.Instance.HideSetupWizard = hide; + EditorUtility.SetDirty(Settings.Instance); + } + } + GUILayout.FlexibleSpace(); + } + } + else + { + EditorGUILayout.Space(); + EditorGUILayout.Space(); + } + EditorGUILayout.Space(); + EditorGUILayout.Space(); + } + } + } + + private void OnInspectorUpdate() + { + switch (currentPage) + { + case PAGES.Welcome: break; + case PAGES.Updating: CheckUpdatesComplete();break; + case PAGES.Linking: CheckStudioLinked();break; + case PAGES.Listener: CheckListeners(); break; + case PAGES.UnityAudio: break; + case PAGES.UnitySources:CheckSources(); break; + case PAGES.SourceControl: break; + case PAGES.End: break; + case PAGES.Max: break; + default: break; + } + } + + private void CheckUpdatesComplete() + { + pageComplete[(int)PAGES.Updating] = updateTasks.All(t => t.IsComplete); + } + + private void CheckStudioLinked() + { + pageComplete[(int)PAGES.Linking] = IsStudioLinked(); + } + + private bool IsStudioLinked() + { + return !string.IsNullOrEmpty(Settings.Instance.SourceBankPath); + } + + private void CheckListeners() + { + var UListeners = Resources.FindObjectsOfTypeAll(); + var FListeners = Resources.FindObjectsOfTypeAll(); + if ((unityListeners == null || fmodListeners == null) || (!unityListeners.SequenceEqual(UListeners) || !fmodListeners.SequenceEqual(FListeners))) + { + unityListeners = UListeners; + bFoundUnityListener = unityListeners.Length > 0; + fmodListeners = FListeners; + bFoundFmodListener = fmodListeners.Length > 0; + Repaint(); + } + pageComplete[(int)PAGES.Listener] = (!bFoundUnityListener && bFoundFmodListener); + } + + private void CheckSources() + { + var ASources = Resources.FindObjectsOfTypeAll(); + if (unityAudioSources == null || !ASources.SequenceEqual(unityAudioSources)) + { + unityAudioSources = ASources; + if (m_SimpleTreeView != null && unityAudioSources.Length > 0) + { + m_SimpleTreeView.Reload(); + } + } + pageComplete[(int)PAGES.UnitySources] = ASources != null ? (ASources.Length == 0) : true; + } + + private void CheckUnityAudio() + { + var audioManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/AudioManager.asset")[0]; + var serializedManager = new SerializedObject(audioManager); + var prop = serializedManager.FindProperty("m_DisableAudio"); + pageComplete[(int)PAGES.UnityAudio] = prop.boolValue; + } + + private void WelcomePage() + { + GUILayout.FlexibleSpace(); + + string message = string.Format("Welcome to FMOD for Unity {0}.", + EditorUtils.VersionString(FMOD.VERSION.number)); + + EditorGUILayout.LabelField(message, titleStyle); + + EditorGUILayout.Space(); + + EditorGUILayout.LabelField("This setup wizard will help you configure your project to use FMOD.", titleStyle); + + GUILayout.FlexibleSpace(); + } + + private void Breadcrumbs() + { + using (new EditorGUILayout.VerticalScope("box", GUILayout.Width(150))) + { + crumbStyle.alignment = TextAnchor.MiddleCenter; + Color oldColor = GUI.backgroundColor; + EditorGUILayout.Space(); + + for (int i = 0; i < pageNames.Count; i++) + { + if (i > 0 && i < pageNames.Count - 1) + { + GUI.backgroundColor = (pageComplete[i] ? Color.green : Color.yellow); + } + crumbStyle.normal.textColor = (i == (int)currentPage ? crumbHighlight : crumbDefault); + using (var b = new EditorGUILayout.HorizontalScope("button", GUILayout.Height(22))) + { + if (GUI.Button(b.rect, pageNames[i], crumbStyle)) + { + currentPage = (PAGES)i; + } + EditorGUILayout.Space(); + } + GUI.backgroundColor = oldColor; + } + GUILayout.FlexibleSpace(); + } + } + + private void UpdatingPage() + { + EditorGUILayout.LabelField("If you are updating an existing FMOD installation, you may need to " + + "perform some update tasks.", titleLeftStyle); + + GUILayout.FlexibleSpace(); + + EditorGUILayout.LabelField("Choose an update task to perform:", titleStyle); + + EditorGUILayout.Space(); + + using (new EditorGUILayout.VerticalScope("box")) + { + float buttonWidth = 0; + + foreach (UpdateTask task in updateTasks) + { + buttonWidth = Math.Max(buttonWidth, buttonStyle.CalcSize(new GUIContent(task.Name)).x); + } + + float buttonHeight = buttonStyle.CalcSize(GUIContent.none).y; + + foreach (UpdateTask task in updateTasks) + { + using (new GUILayout.HorizontalScope()) + { + EditorGUILayout.Space(); + + GUILayout.Label(task.IsComplete ? tickTexture : crossTexture, iconStyle, + GUILayout.Height(buttonHeight)); + + if (GUILayout.Button(task.Name, buttonStyle, GUILayout.Width(buttonWidth))) + { + task.Execute(); + } + + GUILayout.Label(task.Description, descriptionStyle, GUILayout.MinHeight(buttonHeight)); + + GUILayout.FlexibleSpace(); + } + EditorGUILayout.Space(); + } + } + + GUILayout.FlexibleSpace(); + } + + private void LinkingPage() + { + EditorGUILayout.LabelField("In order to access your FMOD Studio content you need to locate the FMOD Studio Project" + + " or the .bank files that FMOD Studio produces, and configure a few other settings.", titleLeftStyle); + GUILayout.FlexibleSpace(); + + EditorGUILayout.LabelField("Choose how to access your FMOD Studio content:", titleLeftStyle); + + EditorGUILayout.Space(); + using (new GUILayout.HorizontalScope()) + { + using (new GUILayout.VerticalScope("box")) + { + float indent = 5; + var serializedObject = new SerializedObject(Settings.Instance); + + var boxStyle = new GUIStyle(); + boxStyle.fixedHeight = 10; + using (new GUILayout.HorizontalScope()) + { + GUILayout.Space(indent); + if (GUILayout.Button("FMOD Studio Project", sourceButtonStyle)) + { + SettingsEditor.BrowseForSourceProjectPath(serializedObject); + } + GUILayout.Label("If you have the complete FMOD Studio Project.", + descriptionStyle, GUILayout.Height(sourceButtonStyle.fixedHeight)); + } + EditorGUILayout.Space(); + using (new GUILayout.HorizontalScope()) + { + GUILayout.Space(indent); + if (GUILayout.Button("Single Platform Build", sourceButtonStyle)) + { + SettingsEditor.BrowseForSourceBankPath(serializedObject); + } + EditorGUILayout.LabelField("If you have the contents of the Build folder for a single platform.", + descriptionStyle, GUILayout.Height(sourceButtonStyle.fixedHeight)); + GUILayout.FlexibleSpace(); + } + EditorGUILayout.Space(); + using (new GUILayout.HorizontalScope()) + { + GUILayout.Space(indent); + if (GUILayout.Button("Multiple Platform Build", sourceButtonStyle)) + { + SettingsEditor.BrowseForSourceBankPath(serializedObject, true); + } + EditorGUILayout.LabelField("If you have the contents of the Build folder for multiple platforms, " + + "with each platform in its own subdirectory.", + descriptionStyle, GUILayout.Height(sourceButtonStyle.fixedHeight)); + } + } + } + + if (IsStudioLinked()) + { + EditorGUILayout.Space(); + + Color oldColor = GUI.backgroundColor; + GUI.backgroundColor = Color.green; + + using (new GUILayout.HorizontalScope("box")) + { + GUILayout.FlexibleSpace(); + + GUILayout.Label(tickTexture, iconStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight * 2)); + + EditorGUILayout.Space(); + + using (new GUILayout.VerticalScope()) + { + Settings settings = Settings.Instance; + + if (settings.HasSourceProject) + { + EditorGUILayout.LabelField("Using the FMOD Studio project at:", descriptionStyle); + EditorGUILayout.LabelField(settings.SourceProjectPath, descriptionStyle); + } + else if (settings.HasPlatforms) + { + EditorGUILayout.LabelField("Using the multiple platform build at:", descriptionStyle); + EditorGUILayout.LabelField(settings.SourceBankPath, descriptionStyle); + } + else + { + EditorGUILayout.LabelField("Using the single platform build at:", descriptionStyle); + EditorGUILayout.LabelField(settings.SourceBankPath, descriptionStyle); + } + } + + GUILayout.FlexibleSpace(); + } + + GUI.backgroundColor = oldColor; + } + + GUILayout.FlexibleSpace(); + } + + private void ListenerPage() + { + EditorGUILayout.LabelField("If you do not intend to use the built in Unity audio, you can choose to replace the Audio Listener with the FMOD Studio Listener.\n", titleLeftStyle); + EditorGUILayout.LabelField("Adding the FMOD Studio Listener component to the main camera provides the FMOD Engine with the information it needs to play 3D events correctly.", titleLeftStyle); + EditorGUILayout.Space(); + GUILayout.FlexibleSpace(); + + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + + // Display found objects containing Unity listeners + DisplayListeners(unityListeners, ref scroll1); + + // Show FMOD Listeners + DisplayListeners(fmodListeners, ref scroll2); + + GUILayout.FlexibleSpace(); + } + + using (new EditorGUILayout.HorizontalScope()) + { + using (new EditorGUI.DisabledGroupScope(!bFoundUnityListener)) + { + GUILayout.FlexibleSpace(); + + if (GUILayout.Button("Replace Unity " + ((unityListeners != null && unityListeners.Length > 1) ? "Listeners" : "Listener") + " with FMOD Audio Listener.", buttonStyle)) + { + for (int i = 0; i < unityListeners.Length; i++) + { + var listener = unityListeners[i]; + if (listener) + { + RuntimeUtils.DebugLog("[FMOD Assistant] Replacing Unity Listener with FMOD Listener on " + listener.gameObject.name); + if (listener.GetComponent() == null) + { + listener.gameObject.AddComponent(typeof(StudioListener)); + } + DestroyImmediate(unityListeners[i]); + EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); + Repaint(); + } + } + } + } + GUILayout.FlexibleSpace(); + } + } + + private void DisplayListeners(T[] listeners, ref Vector2 scrollPos) + { + using (new EditorGUILayout.VerticalScope("box")) + { + bool bUnityListenerType = false; + if (typeof(T) == typeof(AudioListener)) + { + bUnityListenerType = true; + } + + if (listeners != null && listeners.Length > 0) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField(listeners.Length + " " + (bUnityListenerType ? "Unity" : "FMOD") + " " + (listeners.Length > 1 ? "Listeners" : "Listener") + " found.", titleStyle, GUILayout.ExpandWidth(true)); + GUILayout.FlexibleSpace(); + } + + using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.ExpandWidth(true))) + { + scrollPos = scrollView.scrollPosition; + foreach (T l in listeners) + { + var listener = l as Component; + if (listener != null && GUILayout.Button(listener.gameObject.name, GUILayout.ExpandWidth(true))) + { + Selection.activeGameObject = listener.gameObject; + EditorGUIUtility.PingObject(listener); + } + } + } + GUILayout.FlexibleSpace(); + } + else + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField("No " + (bUnityListenerType ? "Unity" : "FMOD") + " Listeners found.", titleStyle); + GUILayout.FlexibleSpace(); + } + GUILayout.FlexibleSpace(); + } + } + } + + private void DisableUnityAudioPage() + { + EditorGUILayout.LabelField("We recommend that you disable the built-in Unity audio for all platforms, to prevent it from consuming system audio resources that the FMOD Engine needs.", titleStyle); + GUILayout.FlexibleSpace(); + + var audioManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/AudioManager.asset")[0]; + var serializedManager = new SerializedObject(audioManager); + var prop = serializedManager.FindProperty("m_DisableAudio"); + + using (new EditorGUILayout.HorizontalScope()) + { + using (new EditorGUI.DisabledGroupScope(prop.boolValue)) + { + GUILayout.FlexibleSpace(); + if (GUILayout.Button(prop.boolValue ? "Built in audio has been disabled" : "Disable built in audio", buttonStyle)) + { + prop.boolValue = true; + serializedManager.ApplyModifiedProperties(); + RuntimeUtils.DebugLog("[FMOD Assistant] Built in Unity audio has been disabled."); + Repaint(); + } + + } + GUILayout.FlexibleSpace(); + } + pageComplete[(int)PAGES.UnityAudio] = prop.boolValue; + + GUILayout.FlexibleSpace(); + } + + private void UnitySources() + { + if (unityAudioSources != null && unityAudioSources.Length > 0) + { + EditorGUILayout.LabelField("Listed below are all the Unity Audio Sources found in the currently loaded scenes and the Assets directory.\nSelect an Audio Source and replace it with an FMOD Studio Event Emitter.", titleStyle); + EditorGUILayout.Space(); + + if (m_SimpleTreeView == null) + { + if (m_TreeViewState == null) + { + m_TreeViewState = new TreeViewState(); + } + m_SimpleTreeView = new SimpleTreeView(m_TreeViewState); + } + + m_SimpleTreeView.Drawlayout(); + } + else + { + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField("No Unity Audio Sources have been found!", titleStyle); + GUILayout.FlexibleSpace(); + } + } + + private void SourceControl() + { + EditorGUILayout.LabelField("There are a number of files produced by FMOD for Unity that should be ignored by source control. " + + "Here is an example of what you should add to your source control ignore file:", titleLeftStyle); + GUILayout.FlexibleSpace(); + + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + using (new EditorGUILayout.VerticalScope("box")) + { + EditorGUILayout.TextArea(IgnoreFileText); + } + GUILayout.FlexibleSpace(); + } + pageComplete[(int)PAGES.SourceControl] = true; + } + + private void EndPage() + { + GUILayout.FlexibleSpace(); + bool completed = true; + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + using (new EditorGUILayout.VerticalScope()) + { + for (int i = 1; i < pageNames.Count - 1; i++) + { + using (new EditorGUILayout.HorizontalScope()) + { + EditorGUILayout.LabelField(pageNames[i], titleStyle); + EditorGUILayout.Space(); + GUILayout.Label(pageComplete[i] ? tickTexture : crossTexture, iconStyle, GUILayout.ExpandWidth(false)); + + if (pageComplete[i] == false) + { + completed = false; + } + } + GUILayout.Space(8); + } + } + GUILayout.FlexibleSpace(); + } + + string msg = ""; + if (completed) + { + // All complete + msg = "FMOD for Unity has been set up successfully!"; + } + // Essential + else if (pageComplete[(int)PAGES.Linking]) + { + // Partial complete (linking done) + msg = "FMOD for Unity has been partially set up."; + } + else + { + // Linking not done + msg = "FMOD for Unity has not finished being set up.\nLinking to a project or banks is required."; + } + + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField(msg, titleStyle); + GUILayout.FlexibleSpace(); + + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + + if (GUILayout.Button(" Integration Manual ", buttonStyle)) + { + EditorUtils.OnlineManual(); + } + + GUILayout.FlexibleSpace(); + } + + GUILayout.Space(20); + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + + if (GUILayout.Button(" FMOD Settings ", buttonStyle)) + { + EditorSettings.EditSettings(); + } + + GUILayout.FlexibleSpace(); + } + + if (completed) + { + Settings.Instance.HideSetupWizard = true; + } + } + + private void Buttons() + { + GUILayout.FlexibleSpace(); + using (new EditorGUILayout.HorizontalScope()) + { + navButtonStyle = new GUIStyle("Button"); + navButtonStyle.fixedHeight = 45; + navButtonStyle.fixedWidth = 75; + + GUILayout.FlexibleSpace(); + if (currentPage != 0) + { + if (GUILayout.Button(backButtonText, navButtonStyle)) + { + if (currentPage != 0) + { + currentPage--; + } + } + } + + string button2Text = "Next"; + if (currentPage == 0) button2Text = "Start"; + else if (currentPage == PAGES.End) button2Text = "Close"; + else button2Text = "Next"; + + EditorGUILayout.Space(); + if (GUILayout.Button(button2Text, navButtonStyle)) + { + if (currentPage == PAGES.End) + { + this.Close(); + } + currentPage++; + } + + GUILayout.FlexibleSpace(); + } + } + + private void StagingUpdatePage() + { + GUILayout.Space(25); + + string message = string.Format("Welcome to FMOD for Unity {0}.", + EditorUtils.VersionString(FMOD.VERSION.number)); + + EditorGUILayout.LabelField(message, titleStyle); + + EditorGUILayout.Space(); + + EditorGUILayout.LabelField( + "To complete the installation, we need to update the FMOD native libraries.\n" + + "This involves a few steps:", titleStyle); + + EditorGUILayout.Space(); + + float nameWidth = 200; + + using (new GUILayout.VerticalScope(columnStyle)) + { + + foreach (StagingSystem.UpdateStep step in StagingSystem.UpdateSteps) + { + bool complete = step.Stage < nextStagingStep.Stage; + + Color oldColor = GUI.backgroundColor; + GUI.backgroundColor = complete ? Color.green : Color.yellow; + + using (new GUILayout.HorizontalScope(GUI.skin.box)) + { + GUILayout.Label(complete ? tickTexture : crossTexture, iconStyle); + + EditorGUILayout.LabelField(step.Name, titleLeftStyle, GUILayout.Width(nameWidth)); + EditorGUILayout.LabelField(step.Description, descriptionStyle); + } + + GUI.backgroundColor = oldColor; + } + + EditorGUILayout.Space(); + + EditorGUILayout.LabelField("Next step:", titleStyle); + + using (new GUILayout.HorizontalScope()) + { + GUILayout.FlexibleSpace(); + + if (GUILayout.Button(nextStagingStep.Name, buttonStyle, GUILayout.ExpandWidth(false))) + { + EditorApplication.delayCall += DoNextStagingStep; + } + + GUILayout.FlexibleSpace(); + } + + EditorGUILayout.Space(); + + using (var scope = new EditorGUILayout.ScrollViewScope(stagingDetailsScroll)) + { + stagingDetailsScroll = scope.scrollPosition; + EditorGUILayout.LabelField(nextStagingStep.Details, descriptionStyle); + } + } + } + } + + public class SimpleTreeView : TreeView + { + private const float BodyHeight = 200; + + public SimpleTreeView(TreeViewState state) : base(state) + { + Reload(); + Repaint(); + ExpandAll(); + } + + protected override bool CanMultiSelect(TreeViewItem item) + { + return false; + } + + protected override bool CanChangeExpandedState(TreeViewItem item) + { + return !(item is AudioSourceItem); + } + + protected override void SelectionChanged(IList selectedIds) + { + base.SelectionChanged(selectedIds); + + if (selectedIds.Count > 0) + { + var item = FindItem(selectedIds[0], rootItem); + GameObject go = null; + if (item.hasChildren) + { + if (item is ParentItem) + { + go = ((ParentItem)item).gameObject; + } + } + else + { + go = ((ParentItem)((AudioSourceItem)item).parent).gameObject; + } + Selection.activeGameObject = go; + } + } + + protected override TreeViewItem BuildRoot() + { + var root = new TreeViewItem (-1, -1); + + CreateItems(root, Resources.FindObjectsOfTypeAll()); + showAlternatingRowBackgrounds = true; + showBorder = true; + SetupDepthsFromParentsAndChildren(root); + + return root; + } + + private class AudioSourceItem : TreeViewItem + { + const string audioIcon = "AudioSource Icon"; + public AudioSourceItem(AudioSource source) : base(source.GetHashCode()) + { + displayName = (source.clip ? source.clip.name : "None"); + icon = (Texture2D)EditorGUIUtility.IconContent(audioIcon).image; + } + } + + private class ParentItem : TreeViewItem + { + public GameObject gameObject; + const string goIcon = "GameObject Icon"; + const string prefabIcon = "Prefab Icon"; + const string prefabModelIcon = "PrefabModel Icon"; + const string prefabVariantIcon = "PrefabVariant Icon"; + + public ParentItem(GameObject go) : base(go.GetHashCode(), 0, go.name) + { + gameObject = go; + var foundAudio = gameObject.GetComponents(); + for (int i = 0; i < foundAudio.Length; i++) + { + AddChild(new AudioSourceItem(foundAudio[i])); + } + + switch (PrefabUtility.GetPrefabAssetType(go)) + { + case PrefabAssetType.NotAPrefab: + icon = (Texture2D)EditorGUIUtility.IconContent(goIcon).image; + break; + case PrefabAssetType.Regular: + icon = (Texture2D)EditorGUIUtility.IconContent(prefabIcon).image; + break; + case PrefabAssetType.Model: + icon = (Texture2D)EditorGUIUtility.IconContent(prefabModelIcon).image; + break; + case PrefabAssetType.Variant: + icon = (Texture2D)EditorGUIUtility.IconContent(prefabVariantIcon).image; + break; + } + } + } + + private class SceneItem : TreeViewItem + { + public Scene m_scene; + const string sceneIcon = "SceneAsset Icon"; + const string folderIcon = "Folder Icon"; + + public SceneItem(Scene scene) : base (scene.GetHashCode()) + { + m_scene = scene; + if (m_scene.IsValid()) + { + displayName = m_scene.name; + icon = (Texture2D)EditorGUIUtility.IconContent(sceneIcon).image; + } + else + { + displayName = "Assets"; + icon = (Texture2D)EditorGUIUtility.IconContent(folderIcon).image; + } + } + } + + private void CreateItems(TreeViewItem root, AudioSource[] audioSources) + { + for(int i = 0; i < audioSources.Length; i++) + { + AudioSource audioSource = audioSources[i]; + + GameObject obj = audioSource.gameObject; + var sourceItem = FindItem(obj.GetHashCode(), root); + if (sourceItem == null) + { + List gameObjects = new List(); + gameObjects.Add(obj); + while (obj.transform.parent != null) + { + obj = obj.transform.parent.gameObject; + gameObjects.Add(obj); + } + gameObjects.Reverse(); + + var parentItem = FindItem(obj.scene.GetHashCode(), root); + if (parentItem == null) + { + parentItem = new SceneItem(obj.scene); + root.AddChild(parentItem); + } + + foreach (var go in gameObjects) + { + var objItem = FindItem(go.GetHashCode(), root); + if (objItem == null) + { + objItem = new ParentItem(go); + parentItem.AddChild(objItem); + } + parentItem = objItem; + } + } + } + } + + public void Drawlayout() + { + Rect rect = EditorGUILayout.GetControlRect(false, BodyHeight); + rect = EditorGUI.IndentedRect(rect); + + OnGUI(rect); + Toolbar(); + } + + public void Toolbar() + { + using (new EditorGUILayout.HorizontalScope()) + { + var style = "miniButton"; + if (GUILayout.Button("Expand All", style)) + { + ExpandAll(); + } + + if (GUILayout.Button("Collapse All", style)) + { + CollapseAll(); + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs.meta b/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs.meta new file mode 100644 index 0000000..d26e2f0 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/SetupWizard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa9a0c70fef01fb43b8eff668bfa0e9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs b/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs new file mode 100644 index 0000000..18b5887 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs @@ -0,0 +1,101 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomEditor(typeof(StudioBankLoader))] + [CanEditMultipleObjects] + public class StudioBankLoaderEditor : Editor + { + public override void OnInspectorGUI() + { + var load = serializedObject.FindProperty("LoadEvent"); + var unload = serializedObject.FindProperty("UnloadEvent"); + var tag = serializedObject.FindProperty("CollisionTag"); + var banks = serializedObject.FindProperty("Banks"); + var preload = serializedObject.FindProperty("PreloadSamples"); + + EditorGUILayout.PropertyField(load, new GUIContent("Load")); + EditorGUILayout.PropertyField(unload, new GUIContent("Unload")); + + if ((load.enumValueIndex >= 3 && load.enumValueIndex <= 6) || + (unload.enumValueIndex >= 3 && unload.enumValueIndex <= 6)) + { + tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue); + } + + EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data")); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PrefixLabel("Banks"); + EditorGUILayout.BeginVertical(); + if (GUILayout.Button("Add Bank", GUILayout.ExpandWidth(false))) + { + banks.InsertArrayElementAtIndex(banks.arraySize); + SerializedProperty newBank = banks.GetArrayElementAtIndex(banks.arraySize - 1); + newBank.stringValue = ""; + + EventBrowser browser = CreateInstance(); + + browser.titleContent = new GUIContent("Select FMOD Bank"); + + browser.ChooseBank(newBank); + browser.ShowUtility(); + } + + Texture deleteTexture = EditorUtils.LoadImage("Delete.png"); + GUIContent deleteContent = new GUIContent(deleteTexture, "Delete Bank"); + + var buttonStyle = new GUIStyle(GUI.skin.button); + buttonStyle.padding.top = buttonStyle.padding.bottom = 1; + buttonStyle.margin.top = 2; + buttonStyle.padding.left = buttonStyle.padding.right = 4; + buttonStyle.fixedHeight = GUI.skin.textField.CalcSize(new GUIContent()).y; + + for (int i = 0; i < banks.arraySize; i++) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PropertyField(banks.GetArrayElementAtIndex(i), GUIContent.none); + + if (GUILayout.Button(deleteContent, buttonStyle, GUILayout.ExpandWidth(false))) + { + banks.DeleteArrayElementAtIndex(i); + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.EndHorizontal(); + + Event e = Event.current; + if (e.type == EventType.DragPerform) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) + { + int pos = banks.arraySize; + banks.InsertArrayElementAtIndex(pos); + var pathProperty = banks.GetArrayElementAtIndex(pos); + + pathProperty.stringValue = ((EditorBankRef)DragAndDrop.objectReferences[0]).Name; + + e.Use(); + } + } + if (e.type == EventType.DragUpdated) + { + if (DragAndDrop.objectReferences.Length > 0 && + DragAndDrop.objectReferences[0] != null && + DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Move; + DragAndDrop.AcceptDrag(); + e.Use(); + } + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs.meta new file mode 100644 index 0000000..1447d46 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioBankLoaderEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f7f61e03a350e1e428dba6c562f3d64a +timeCreated: 1434691856 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs new file mode 100644 index 0000000..b55da7c --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs @@ -0,0 +1,532 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomEditor(typeof(StudioEventEmitter))] + [CanEditMultipleObjects] + public class StudioEventEmitterEditor : Editor + { + private ParameterValueView parameterValueView; + + public void OnEnable() + { + parameterValueView = new ParameterValueView(serializedObject); + } + + public void OnSceneGUI() + { + var emitter = target as StudioEventEmitter; + + EditorEventRef editorEvent = EventManager.EventFromGUID(emitter.EventReference.Guid); + if (editorEvent != null && editorEvent.Is3D) + { + EditorGUI.BeginChangeCheck(); + float minDistance = emitter.OverrideAttenuation ? emitter.OverrideMinDistance : editorEvent.MinDistance; + float maxDistance = emitter.OverrideAttenuation ? emitter.OverrideMaxDistance : editorEvent.MaxDistance; + minDistance = Handles.RadiusHandle(Quaternion.identity, emitter.transform.position, minDistance); + maxDistance = Handles.RadiusHandle(Quaternion.identity, emitter.transform.position, maxDistance); + if (EditorGUI.EndChangeCheck() && emitter.OverrideAttenuation) + { + Undo.RecordObject(emitter, "Change Emitter Bounds"); + emitter.OverrideMinDistance = Mathf.Clamp(minDistance, 0, emitter.OverrideMaxDistance); + emitter.OverrideMaxDistance = Mathf.Max(emitter.OverrideMinDistance, maxDistance); + } + } + } + + public override void OnInspectorGUI() + { + var begin = serializedObject.FindProperty("PlayEvent"); + var end = serializedObject.FindProperty("StopEvent"); + var tag = serializedObject.FindProperty("CollisionTag"); + var eventReference = serializedObject.FindProperty("EventReference"); + var eventPath = eventReference.FindPropertyRelative("Path"); + var fadeout = serializedObject.FindProperty("AllowFadeout"); + var once = serializedObject.FindProperty("TriggerOnce"); + var preload = serializedObject.FindProperty("Preload"); + var allowNonRigidbodyDoppler = serializedObject.FindProperty("AllowNonRigidbodyDoppler"); + var overrideAtt = serializedObject.FindProperty("OverrideAttenuation"); + var minDistance = serializedObject.FindProperty("OverrideMinDistance"); + var maxDistance = serializedObject.FindProperty("OverrideMaxDistance"); + + EditorGUILayout.PropertyField(begin, new GUIContent("Play Event")); + EditorGUILayout.PropertyField(end, new GUIContent("Stop Event")); + + if ((begin.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && begin.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D) || + (end.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && end.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D)) + { + tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue); + } + + EditorGUI.BeginChangeCheck(); + + const string EventReferenceLabel = "Event"; + + EditorUtils.DrawLegacyEvent(serializedObject.FindProperty("Event"), EventReferenceLabel); + + EditorGUILayout.PropertyField(eventReference, new GUIContent(EventReferenceLabel)); + + EditorEventRef editorEvent = EventManager.EventFromPath(eventPath.stringValue); + + if (EditorGUI.EndChangeCheck()) + { + EditorUtils.UpdateParamsOnEmitter(serializedObject, eventPath.stringValue); + } + + // Attenuation + if (editorEvent != null) + { + { + EditorGUI.BeginDisabledGroup(editorEvent == null || !editorEvent.Is3D); + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(overrideAtt); + if (EditorGUI.EndChangeCheck() || + (minDistance.floatValue == -1 && maxDistance.floatValue == -1) || // never been initialiased + !overrideAtt.boolValue && + (minDistance.floatValue != editorEvent.MinDistance || maxDistance.floatValue != editorEvent.MaxDistance) + ) + { + minDistance.floatValue = editorEvent.MinDistance; + maxDistance.floatValue = editorEvent.MaxDistance; + } + EditorGUI.BeginDisabledGroup(!overrideAtt.boolValue); + EditorGUIUtility.labelWidth = 30; + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(minDistance, new GUIContent("Min")); + if (EditorGUI.EndChangeCheck()) + { + minDistance.floatValue = Mathf.Clamp(minDistance.floatValue, 0, maxDistance.floatValue); + } + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(maxDistance, new GUIContent("Max")); + if (EditorGUI.EndChangeCheck()) + { + maxDistance.floatValue = Mathf.Max(minDistance.floatValue, maxDistance.floatValue); + } + EditorGUIUtility.labelWidth = 0; + EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + EditorGUI.EndDisabledGroup(); + } + + parameterValueView.OnGUI(editorEvent, !eventReference.hasMultipleDifferentValues); + + fadeout.isExpanded = EditorGUILayout.Foldout(fadeout.isExpanded, "Advanced Controls"); + if (fadeout.isExpanded) + { + EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data")); + EditorGUILayout.PropertyField(fadeout, new GUIContent("Allow Fadeout When Stopping")); + EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once")); + EditorGUILayout.PropertyField(allowNonRigidbodyDoppler, new GUIContent("Allow Non-Rigidbody Doppler")); + } + } + + serializedObject.ApplyModifiedProperties(); + } + + private class ParameterValueView + { + // The "Params" property from the SerializedObject we're editing in the inspector, + // so we can expand/collapse it or revert to prefab. + private SerializedProperty paramsProperty; + + // This holds one SerializedObject for each object in the current selection. + private List serializedTargets = new List(); + + // Mappings from EditorParamRef to initial parameter value property for all properties + // found in the current selection. + private List propertyRecords = new List(); + + // Any parameters that are in the current event but are missing from some objects in + // the current selection, so we can put them in the "Add" menu. + private List missingParameters = new List(); + + // A mapping from EditorParamRef to the initial parameter value properties in the + // current selection that have the same name. + // We need this because some objects may be missing some properties, and properties with + // the same name may be at different array indices in different objects. + private class PropertyRecord + { + public string name { get { return paramRef.Name; } } + public EditorParamRef paramRef; + public List valueProperties; + } + + public ParameterValueView(SerializedObject serializedObject) + { + paramsProperty = serializedObject.FindProperty("Params"); + + foreach (UnityEngine.Object target in serializedObject.targetObjects) + { + serializedTargets.Add(new SerializedObject(target)); + } + } + + // Rebuilds the propertyRecords and missingParameters collections. + private void RefreshPropertyRecords(EditorEventRef eventRef) + { + propertyRecords.Clear(); + + foreach (SerializedObject serializedTarget in serializedTargets) + { + SerializedProperty paramsProperty = serializedTarget.FindProperty("Params"); + + foreach (SerializedProperty parameterProperty in paramsProperty) + { + string name = parameterProperty.FindPropertyRelative("Name").stringValue; + SerializedProperty valueProperty = parameterProperty.FindPropertyRelative("Value"); + + PropertyRecord record = propertyRecords.Find(r => r.name == name); + + if (record != null) + { + record.valueProperties.Add(valueProperty); + } + else + { + EditorParamRef paramRef = eventRef.LocalParameters.Find(p => p.Name == name); + + if (paramRef != null) + { + propertyRecords.Add( + new PropertyRecord() { + paramRef = paramRef, + valueProperties = new List() { valueProperty }, + }); + } + } + } + } + + // Only sort if there is a multi-selection. If there is only one object selected, + // the user can revert to prefab, and the behaviour depends on the array order, + // so it's helpful to show the true order. + if (serializedTargets.Count > 1) + { + propertyRecords.Sort((a, b) => EditorUtility.NaturalCompare(a.name, b.name)); + } + + missingParameters.Clear(); + missingParameters.AddRange(eventRef.LocalParameters.Where( + p => { + PropertyRecord record = propertyRecords.Find(r => r.name == p.Name); + return record == null || record.valueProperties.Count < serializedTargets.Count; + })); + } + + public void OnGUI(EditorEventRef eventRef, bool matchingEvents) + { + foreach (SerializedObject serializedTarget in serializedTargets) + { + serializedTarget.Update(); + } + + if (Event.current.type == EventType.Layout) + { + RefreshPropertyRecords(eventRef); + } + + DrawHeader(matchingEvents); + + if (paramsProperty.isExpanded) + { + if (matchingEvents) + { + DrawValues(); + } + else + { + GUILayout.Box("Cannot change parameters when different events are selected", GUILayout.ExpandWidth(true)); + } + } + + foreach (SerializedObject serializedTarget in serializedTargets) + { + serializedTarget.ApplyModifiedProperties(); + } + } + + private void DrawHeader(bool enableAddButton) + { + Rect controlRect = EditorGUILayout.GetControlRect(); + + Rect titleRect = controlRect; + titleRect.width = EditorGUIUtility.labelWidth; + + // Let the user revert the whole Params array to prefab by context-clicking the title. + EditorGUI.BeginProperty(titleRect, GUIContent.none, paramsProperty); + + paramsProperty.isExpanded = EditorGUI.Foldout(titleRect, paramsProperty.isExpanded, + "Initial Parameter Values"); + + EditorGUI.EndProperty(); + + Rect buttonRect = controlRect; + buttonRect.xMin = titleRect.xMax; + + EditorGUI.BeginDisabledGroup(!enableAddButton); + + DrawAddButton(buttonRect); + + EditorGUI.EndDisabledGroup(); + } + + private void DrawAddButton(Rect position) + { + EditorGUI.BeginDisabledGroup(missingParameters.Count == 0); + + if (EditorGUI.DropdownButton(position, new GUIContent("Add"), FocusType.Passive)) + { + GenericMenu menu = new GenericMenu(); + menu.AddItem(new GUIContent("All"), false, () => + { + foreach (EditorParamRef parameter in missingParameters) + { + AddParameter(parameter); + } + }); + + menu.AddSeparator(string.Empty); + + foreach (EditorParamRef parameter in missingParameters) + { + menu.AddItem(new GUIContent(parameter.Name), false, + (userData) => + { + AddParameter(userData as EditorParamRef); + }, + parameter); + } + + menu.DropDown(position); + } + + EditorGUI.EndDisabledGroup(); + } + + private void DrawValues() + { + // We use this to defer deletion so we don't mess with arrays while using + // SerializedProperties that refer to array elements, as this can throw exceptions. + string parameterToDelete = null; + + foreach (PropertyRecord record in propertyRecords) + { + if (record.valueProperties.Count == serializedTargets.Count) + { + bool delete; + DrawValue(record, out delete); + + if (delete) + { + parameterToDelete = record.name; + } + } + } + + if (parameterToDelete != null) + { + DeleteParameter(parameterToDelete); + } + } + + private void DrawValue(PropertyRecord record, out bool delete) + { + delete = false; + + GUIContent removeLabel = new GUIContent("Remove"); + + Rect position = EditorGUILayout.GetControlRect(); + + Rect nameLabelRect = position; + nameLabelRect.width = EditorGUIUtility.labelWidth; + + Rect removeButtonRect = position; + removeButtonRect.width = EditorStyles.miniButton.CalcSize(removeLabel).x; + removeButtonRect.x = position.xMax - removeButtonRect.width; + + Rect sliderRect = position; + sliderRect.xMin = nameLabelRect.xMax; + sliderRect.xMax = removeButtonRect.xMin - EditorStyles.miniButton.margin.left; + + GUIContent nameLabel = new GUIContent(record.name); + + float value = 0; + bool mixedValues = false; + + // We use EditorGUI.BeginProperty when there is a single object selected, so + // the user can revert the value to prefab by context-clicking the name. + // We handle multi-selections ourselves, so that we can deal with + // mismatched arrays nicely. + if (record.valueProperties.Count == 1) + { + value = record.valueProperties[0].floatValue; + EditorGUI.BeginProperty(position, nameLabel, record.valueProperties[0]); + } + else + { + bool first = true; + + foreach (SerializedProperty property in record.valueProperties) + { + if (first) + { + value = property.floatValue; + first = false; + } + else if (property.floatValue != value) + { + mixedValues = true; + break; + } + } + } + + EditorGUI.LabelField(nameLabelRect, nameLabel); + + if (record.paramRef.Type == ParameterType.Labeled) + { + EditorGUI.BeginChangeCheck(); + + EditorGUI.showMixedValue = mixedValues; + + int newValue = EditorGUI.Popup(sliderRect, (int)value, record.paramRef.Labels); + + EditorGUI.showMixedValue = false; + + if (EditorGUI.EndChangeCheck()) + { + foreach (SerializedProperty property in record.valueProperties) + { + property.floatValue = newValue; + } + } + } + else if (record.paramRef.Type == ParameterType.Discrete) + { + EditorGUI.BeginChangeCheck(); + + EditorGUI.showMixedValue = mixedValues; + + int newValue = EditorGUI.IntSlider(sliderRect, (int)value, (int)record.paramRef.Min, (int)record.paramRef.Max); + + EditorGUI.showMixedValue = false; + + if (EditorGUI.EndChangeCheck()) + { + foreach (SerializedProperty property in record.valueProperties) + { + property.floatValue = newValue; + } + } + } + else + { + EditorGUI.BeginChangeCheck(); + + EditorGUI.showMixedValue = mixedValues; + + float newValue = EditorGUI.Slider(sliderRect, value, record.paramRef.Min, record.paramRef.Max); + + EditorGUI.showMixedValue = false; + + if (EditorGUI.EndChangeCheck()) + { + foreach (SerializedProperty property in record.valueProperties) + { + property.floatValue = newValue; + } + } + } + + delete = GUI.Button(removeButtonRect, removeLabel, EditorStyles.miniButton); + + if (record.valueProperties.Count == 1) + { + EditorGUI.EndProperty(); + } + else + { + // Context menu to set all values from one object in the multi-selection. + if (mixedValues && Event.current.type == EventType.ContextClick + && nameLabelRect.Contains(Event.current.mousePosition)) + { + GenericMenu menu = new GenericMenu(); + + foreach (SerializedProperty sourceProperty in record.valueProperties) + { + UnityEngine.Object targetObject = sourceProperty.serializedObject.targetObject; + + menu.AddItem(new GUIContent(string.Format("Set to Value of '{0}'", targetObject.name)), false, + (userData) => CopyValueToAll(userData as SerializedProperty, record.valueProperties), + sourceProperty); + } + + menu.DropDown(position); + + } + } + } + + // Copy the value from the source property to all target properties. + private void CopyValueToAll(SerializedProperty sourceProperty, List targetProperties) + { + foreach (SerializedProperty targetProperty in targetProperties) + { + if (targetProperty != sourceProperty) + { + targetProperty.floatValue = sourceProperty.floatValue; + targetProperty.serializedObject.ApplyModifiedProperties(); + } + } + } + + // Add an initial value for the given parameter to all selected objects that don't have one. + private void AddParameter(EditorParamRef parameter) + { + foreach (SerializedObject serializedTarget in serializedTargets) + { + StudioEventEmitter emitter = serializedTarget.targetObject as StudioEventEmitter; + + if (Array.FindIndex(emitter.Params, p => p.Name == parameter.Name) < 0) + { + SerializedProperty paramsProperty = serializedTarget.FindProperty("Params"); + + int index = paramsProperty.arraySize; + paramsProperty.InsertArrayElementAtIndex(index); + + SerializedProperty arrayElement = paramsProperty.GetArrayElementAtIndex(index); + + arrayElement.FindPropertyRelative("Name").stringValue = parameter.Name; + arrayElement.FindPropertyRelative("Value").floatValue = parameter.Default; + + serializedTarget.ApplyModifiedProperties(); + } + } + } + + // Delete initial parameter values for the given name from all selected objects. + private void DeleteParameter(string name) + { + foreach (SerializedObject serializedTarget in serializedTargets) + { + SerializedProperty paramsProperty = serializedTarget.FindProperty("Params"); + + foreach (SerializedProperty child in paramsProperty) + { + if (child.FindPropertyRelative("Name").stringValue == name) + { + child.DeleteCommand(); + break; + } + } + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs.meta new file mode 100644 index 0000000..af0b511 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2b044fd4ebf2c42468e1f41d5e2b879c +timeCreated: 1434696182 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs new file mode 100644 index 0000000..7fde703 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using UnityEditor; + +namespace FMODUnity +{ + public class StudioEventEmitterGizoDrawer + { + [DrawGizmo(GizmoType.Selected | GizmoType.Active | GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)] + private static void DrawGizmo(StudioEventEmitter studioEmitter, GizmoType gizmoType) + { + Gizmos.DrawIcon(studioEmitter.transform.position, "AudioSource Gizmo", true, Color.yellow); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs.meta new file mode 100644 index 0000000..ca5da8f --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioEventEmitterGizmoDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f09ba26caab55e048a2e596ff75b3eab +timeCreated: 1433142677 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs b/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs new file mode 100644 index 0000000..eabc0f7 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomEditor(typeof(StudioGlobalParameterTrigger))] + public class StudioGlobalParameterTriggerEditor : Editor + { + private SerializedProperty param; + private SerializedProperty trigger; + private SerializedProperty tag; + private SerializedProperty value; + + private SerializedProperty data1, data2; + + private static GUIContent NotFoundWarning; + + private string currentPath; + + [SerializeField] + private EditorParamRef editorParamRef; + + private void OnEnable() + { + param = serializedObject.FindProperty("Parameter"); + trigger = serializedObject.FindProperty("TriggerEvent"); + tag = serializedObject.FindProperty("CollisionTag"); + value = serializedObject.FindProperty("Value"); + } + + public override void OnInspectorGUI() + { + if (NotFoundWarning == null) + { + Texture warningIcon = EditorUtils.LoadImage("NotFound.png"); + NotFoundWarning = new GUIContent("Parameter Not Found", warningIcon); + } + + EditorGUILayout.PropertyField(trigger, new GUIContent("Trigger")); + if (trigger.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && trigger.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D) + { + tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue); + } + + EditorGUILayout.PropertyField(param, new GUIContent("Parameter")); + + if (param.stringValue != currentPath) + { + currentPath = param.stringValue; + + if (string.IsNullOrEmpty(param.stringValue)) + { + editorParamRef = null; + } + else + { + editorParamRef = EventManager.ParamFromPath(param.stringValue); + value.floatValue = Mathf.Clamp(value.floatValue, editorParamRef.Min, editorParamRef.Max); + } + } + + if (editorParamRef != null) + { + using (new EditorGUILayout.HorizontalScope()) + { + EditorGUILayout.PrefixLabel("Override Value"); + value.floatValue = EditorUtils.DrawParameterValueLayout(value.floatValue, editorParamRef); + } + } + else + { + Rect rect = EditorGUILayout.GetControlRect(); + rect.xMin += EditorGUIUtility.labelWidth; + + GUI.Label(rect, NotFoundWarning); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs.meta new file mode 100644 index 0000000..7728f87 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioGlobalParameterTriggerEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a901681b5558f247b4c227fb425c010 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs b/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs new file mode 100644 index 0000000..6d4064f --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs @@ -0,0 +1,29 @@ +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomEditor(typeof(StudioListener))] + [CanEditMultipleObjects] + public class StudioListenerEditor : Editor + { + public SerializedProperty attenuationObject; + + private void OnEnable() + { + attenuationObject = serializedObject.FindProperty("attenuationObject"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUI.BeginDisabledGroup(true); + int index = ((StudioListener)serializedObject.targetObject).ListenerNumber; + EditorGUILayout.IntSlider("Listener Index", index, 0, FMOD.CONSTANTS.MAX_LISTENERS - 1); + EditorGUI.EndDisabledGroup(); + + EditorGUILayout.PropertyField(attenuationObject); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs.meta new file mode 100644 index 0000000..31b3e9a --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioListenerEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 847f8505c25f5cf42adba68a26f2cda6 +timeCreated: 1445576758 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs b/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs new file mode 100644 index 0000000..a9e6477 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs @@ -0,0 +1,153 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace FMODUnity +{ + [CustomEditor(typeof(StudioParameterTrigger))] + public class StudioParameterTriggerEditor : Editor + { + private StudioEventEmitter targetEmitter; + private SerializedProperty emitters; + private SerializedProperty trigger; + private SerializedProperty tag; + + private bool[] expanded; + + private void OnEnable() + { + emitters = serializedObject.FindProperty("Emitters"); + trigger = serializedObject.FindProperty("TriggerEvent"); + tag = serializedObject.FindProperty("CollisionTag"); + targetEmitter = null; + for (int i = 0; i < emitters.arraySize; i++) + { + targetEmitter = emitters.GetArrayElementAtIndex(i).FindPropertyRelative("Target").objectReferenceValue as StudioEventEmitter; + if (targetEmitter != null) + { + expanded = new bool[targetEmitter.GetComponents().Length]; + break; + } + } + } + + public override void OnInspectorGUI() + { + var newTargetEmitter = EditorGUILayout.ObjectField("Target", targetEmitter, typeof(StudioEventEmitter), true) as StudioEventEmitter; + if (newTargetEmitter != targetEmitter) + { + emitters.ClearArray(); + targetEmitter = newTargetEmitter; + + if (targetEmitter == null) + { + serializedObject.ApplyModifiedProperties(); + return; + } + + List newEmitters = new List(); + targetEmitter.GetComponents(newEmitters); + expanded = new bool[newEmitters.Count]; + foreach (var emitter in newEmitters) + { + emitters.InsertArrayElementAtIndex(0); + emitters.GetArrayElementAtIndex(0).FindPropertyRelative("Target").objectReferenceValue = emitter; + } + } + + if (targetEmitter == null) + { + return; + } + + EditorGUILayout.PropertyField(trigger, new GUIContent("Trigger")); + + if (trigger.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && trigger.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D) + { + tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue); + } + + var localEmitters = new List(); + targetEmitter.GetComponents(localEmitters); + + int emitterIndex = 0; + foreach (var emitter in localEmitters) + { + SerializedProperty emitterProperty = null; + for(int i = 0; i < emitters.arraySize; i++) + { + if (emitters.GetArrayElementAtIndex(i).FindPropertyRelative("Target").objectReferenceValue == emitter) + { + emitterProperty = emitters.GetArrayElementAtIndex(i); + break; + } + } + + // New emitter component added to game object since we last looked + if (emitterProperty == null) + { + emitters.InsertArrayElementAtIndex(0); + emitterProperty = emitters.GetArrayElementAtIndex(0); + emitterProperty.FindPropertyRelative("Target").objectReferenceValue = emitter; + } + + if (!emitter.EventReference.IsNull) + { + expanded[emitterIndex] = EditorGUILayout.Foldout(expanded[emitterIndex], emitter.EventReference.Path); + if (expanded[emitterIndex]) + { + var eventRef = EventManager.EventFromGUID(emitter.EventReference.Guid); + + foreach (var paramRef in eventRef.LocalParameters) + { + bool set = false; + int index = -1; + for (int i = 0; i < emitterProperty.FindPropertyRelative("Params").arraySize; i++) + { + if (emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(i).FindPropertyRelative("Name").stringValue == paramRef.Name) + { + index = i; + set = true; + break; + } + } + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PrefixLabel(paramRef.Name); + bool newSet = GUILayout.Toggle(set, ""); + if (!set && newSet) + { + index = 0; + emitterProperty.FindPropertyRelative("Params").InsertArrayElementAtIndex(0); + emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(0).FindPropertyRelative("Name").stringValue = paramRef.Name; + emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(0).FindPropertyRelative("Value").floatValue = 0; + } + if (set && !newSet) + { + emitterProperty.FindPropertyRelative("Params").DeleteArrayElementAtIndex(index); + } + set = newSet; + + if (set) + { + var valueProperty = emitterProperty.FindPropertyRelative("Params") + .GetArrayElementAtIndex(index).FindPropertyRelative("Value"); + valueProperty.floatValue = + EditorUtils.DrawParameterValueLayout(valueProperty.floatValue, paramRef); + } + else + { + using (new EditorGUI.DisabledScope(true)) + { + EditorUtils.DrawParameterValueLayout(0, paramRef); + } + } + EditorGUILayout.EndHorizontal(); + } + } + } + emitterIndex++; + } + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs.meta b/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs.meta new file mode 100644 index 0000000..e54da36 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Editor/StudioParameterTriggerEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dc94d213814ef1a42b0ca8ee00dd4728 +timeCreated: 1451968823 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/EventHandler.cs b/Assets/Plugins/FMOD/src/EventHandler.cs new file mode 100644 index 0000000..8a379a4 --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventHandler.cs @@ -0,0 +1,127 @@ +using UnityEngine; +using UnityEngine.EventSystems; + +namespace FMODUnity +{ + public abstract class EventHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler + { + public string CollisionTag = ""; + + protected virtual void Start() + { + HandleGameEvent(EmitterGameEvent.ObjectStart); + } + + protected virtual void OnDestroy() + { + HandleGameEvent(EmitterGameEvent.ObjectDestroy); + } + + private void OnEnable() + { + HandleGameEvent(EmitterGameEvent.ObjectEnable); + } + + private void OnDisable() + { + HandleGameEvent(EmitterGameEvent.ObjectDisable); + } + + #if UNITY_PHYSICS_EXIST + private void OnTriggerEnter(Collider other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag) || (other.attachedRigidbody && other.attachedRigidbody.CompareTag(CollisionTag))) + { + HandleGameEvent(EmitterGameEvent.TriggerEnter); + } + } + + private void OnTriggerExit(Collider other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag) || (other.attachedRigidbody && other.attachedRigidbody.CompareTag(CollisionTag))) + { + HandleGameEvent(EmitterGameEvent.TriggerExit); + } + } + #endif + + #if UNITY_PHYSICS2D_EXIST + private void OnTriggerEnter2D(Collider2D other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(EmitterGameEvent.TriggerEnter2D); + } + } + + private void OnTriggerExit2D(Collider2D other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(EmitterGameEvent.TriggerExit2D); + } + } + #endif + + private void OnCollisionEnter() + { + HandleGameEvent(EmitterGameEvent.CollisionEnter); + } + + private void OnCollisionExit() + { + HandleGameEvent(EmitterGameEvent.CollisionExit); + } + + private void OnCollisionEnter2D() + { + HandleGameEvent(EmitterGameEvent.CollisionEnter2D); + } + + private void OnCollisionExit2D() + { + HandleGameEvent(EmitterGameEvent.CollisionExit2D); + } + + private void OnMouseEnter() + { + HandleGameEvent(EmitterGameEvent.ObjectMouseEnter); + } + + private void OnMouseExit() + { + HandleGameEvent(EmitterGameEvent.ObjectMouseExit); + } + + private void OnMouseDown() + { + HandleGameEvent(EmitterGameEvent.ObjectMouseDown); + } + + private void OnMouseUp() + { + HandleGameEvent(EmitterGameEvent.ObjectMouseUp); + } + + public void OnPointerEnter(PointerEventData eventData) + { + HandleGameEvent(EmitterGameEvent.UIMouseEnter); + } + + public void OnPointerExit(PointerEventData eventData) + { + HandleGameEvent(EmitterGameEvent.UIMouseExit); + } + public void OnPointerDown(PointerEventData eventData) + { + HandleGameEvent(EmitterGameEvent.UIMouseDown); + } + + public void OnPointerUp(PointerEventData eventData) + { + HandleGameEvent(EmitterGameEvent.UIMouseUp); + } + + protected abstract void HandleGameEvent(EmitterGameEvent gameEvent); + } +} diff --git a/Assets/Plugins/FMOD/src/EventHandler.cs.meta b/Assets/Plugins/FMOD/src/EventHandler.cs.meta new file mode 100644 index 0000000..5ceb10f --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a28d1e1a42561ed4f8d44293dab99079 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/EventRefAttribute.cs b/Assets/Plugins/FMOD/src/EventRefAttribute.cs new file mode 100644 index 0000000..bb11a3f --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventRefAttribute.cs @@ -0,0 +1,11 @@ +using System; +using UnityEngine; + +namespace FMODUnity +{ + [Obsolete("Use the EventReference struct instead")] + public class EventRefAttribute : PropertyAttribute + { + public string MigrateTo = null; + } +} diff --git a/Assets/Plugins/FMOD/src/EventRefAttribute.cs.meta b/Assets/Plugins/FMOD/src/EventRefAttribute.cs.meta new file mode 100644 index 0000000..69907ee --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventRefAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1b29a1189268c3b47aa2ec4b96a9e7ef +timeCreated: 1445311748 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/EventReference.cs b/Assets/Plugins/FMOD/src/EventReference.cs new file mode 100644 index 0000000..b317f52 --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventReference.cs @@ -0,0 +1,53 @@ +using System; +using UnityEngine; + +namespace FMODUnity +{ + [Serializable] + public struct EventReference + { + public FMOD.GUID Guid; + +#if UNITY_EDITOR + public string Path; + + public static Func GuidLookupDelegate; + + public override string ToString() + { + return string.Format("{0} ({1})", Guid, Path); + } + + public bool IsNull + { + get + { + return string.IsNullOrEmpty(Path) && Guid.IsNull; + } + } + + public static EventReference Find(string path) + { + if (GuidLookupDelegate == null) + { + throw new InvalidOperationException("EventReference.Find called before EventManager was initialized"); + } + + return new EventReference { Path = path, Guid = GuidLookupDelegate(path) }; + } +#else + public override string ToString() + { + return Guid.ToString(); + } + + public bool IsNull + { + get + { + return Guid.IsNull; + } + } +#endif + } +} diff --git a/Assets/Plugins/FMOD/src/EventReference.cs.meta b/Assets/Plugins/FMOD/src/EventReference.cs.meta new file mode 100644 index 0000000..008d9b6 --- /dev/null +++ b/Assets/Plugins/FMOD/src/EventReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b1e4da3fb15e7a45a8f104b7d0fd6d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/FMODEventPlayable.cs b/Assets/Plugins/FMOD/src/FMODEventPlayable.cs new file mode 100644 index 0000000..64447e8 --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODEventPlayable.cs @@ -0,0 +1,360 @@ +#if UNITY_TIMELINE_EXIST + +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; +using UnityEngine.Serialization; + +namespace FMODUnity +{ + [System.Serializable] + public class FMODEventPlayable : PlayableAsset, ITimelineClipAsset + { + [FormerlySerializedAs("template")] + public FMODEventPlayableBehavior Template = new FMODEventPlayableBehavior(); + + [FormerlySerializedAs("eventLength")] + public float EventLength; //In seconds. + + [Obsolete("Use the eventReference field instead")] + [SerializeField] + public string eventName; + + [FormerlySerializedAs("eventReference")] + [SerializeField] + public EventReference EventReference; + + [FormerlySerializedAs("stopType")] + [SerializeField] + public STOP_MODE StopType; + + [FormerlySerializedAs("parameters")] + [SerializeField] + public ParamRef[] Parameters = new ParamRef[0]; + + [NonSerialized] + public bool CachedParameters = false; + + public static event System.EventHandler OnCreatePlayable; + + private FMODEventPlayableBehavior behavior; + + public GameObject TrackTargetObject { get; set; } + + public override double duration + { + get + { + if (EventReference.IsNull) + { + return base.duration; + } + else + { + return EventLength; + } + } + } + + public ClipCaps clipCaps + { + get { return ClipCaps.None; } + } + + public TimelineClip OwningClip { get; set; } + + public void LinkParameters(FMOD.Studio.EventDescription eventDescription) + { +#if UNITY_EDITOR + if (!EventReference.IsNull) +#else + if (!CachedParameters && !EventReference.IsNull) +#endif + { + for (int i = 0; i < Parameters.Length; i++) + { + FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription; + eventDescription.getParameterDescriptionByName(Parameters[i].Name, out parameterDescription); + Parameters[i].ID = parameterDescription.id; + } + + List parameterLinks = Template.ParameterLinks; + + for (int i = 0; i < parameterLinks.Count; i++) + { + FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription; + eventDescription.getParameterDescriptionByName(parameterLinks[i].Name, out parameterDescription); + parameterLinks[i].ID = parameterDescription.id; + } + + CachedParameters = true; + } + } + + public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) + { + if (Application.isPlaying) + { + LinkParameters(RuntimeManager.GetEventDescription(EventReference)); + } + else + { + // Handled by the editor auditioning system. + EventArgs args = new EventArgs(); + OnCreatePlayable.Invoke(this, args); + } + + var playable = ScriptPlayable.Create(graph, Template); + behavior = playable.GetBehaviour(); + + behavior.TrackTargetObject = TrackTargetObject; + behavior.EventReference = EventReference; + behavior.StopType = StopType; + behavior.Parameters = Parameters; + behavior.OwningClip = OwningClip; + + return playable; + } + +#if UNITY_EDITOR + public void UpdateEventDuration(float duration) + { + EventLength = duration / 1000f; + } + + public void OnValidate() + { + if (OwningClip != null) + { + if (EventReference.IsNull) + { + OwningClip.displayName = "FMODEventPlayable"; + } + else + { + int index = EventReference.Path.LastIndexOf("/"); + OwningClip.displayName = EventReference.Path.Substring(index + 1); + } + } + if (behavior != null) + { + behavior.EventReference = EventReference; + } + } +#endif //UNITY_EDITOR + } + + public enum STOP_MODE : int + { + AllowFadeout, + Immediate, + None + } + + [Serializable] + public class ParameterAutomationLink + { + public string Name; + public FMOD.Studio.PARAMETER_ID ID; + public int Slot; + } + + [Serializable] + public class FMODEventPlayableBehavior : PlayableBehaviour + { + public FMODEventPlayableBehavior() + { + CurrentVolume = 1; + } + + public class EventArgs : System.EventArgs + { + public FMOD.Studio.EventInstance eventInstance { get; set; } + } + + public static event System.EventHandler Enter; + public static event System.EventHandler Exit; + public static event System.EventHandler GraphStop; + + [FormerlySerializedAs("eventReference")] + public EventReference EventReference; + + [FormerlySerializedAs("stopType")] + public STOP_MODE StopType = STOP_MODE.AllowFadeout; + + [FormerlySerializedAs("parameters")] + [NotKeyable] + public ParamRef[] Parameters = new ParamRef[0]; + + [FormerlySerializedAs("parameterLinks")] + public List ParameterLinks = new List(); + + [NonSerialized] + public GameObject TrackTargetObject; + + [NonSerialized] + public TimelineClip OwningClip; + + [FormerlySerializedAs("parameterAutomation")] + public AutomatableSlots ParameterAutomation; + + private bool isPlayheadInside = false; + + private FMOD.Studio.EventInstance eventInstance; + + public float ClipStartTime { get; private set; } = 0.0f; + + public float CurrentVolume { get; private set; } + + protected void PlayEvent() + { + if (!EventReference.IsNull) + { + eventInstance = RuntimeManager.CreateInstance(EventReference); + + // Only attach to object if the game is actually playing, not auditioning. + if (Application.isPlaying && TrackTargetObject) + { +#if UNITY_PHYSICS_EXIST + if (TrackTargetObject.GetComponent()) + { + RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent()); + } + else +#endif +#if UNITY_PHYSICS2D_EXIST + if (TrackTargetObject.GetComponent()) + { + RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent()); + } + else +#endif + { + RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform); + } + } + else + { + eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(Vector3.zero)); + } + + foreach (var param in Parameters) + { + eventInstance.setParameterByID(param.ID, param.Value); + } + + eventInstance.setVolume(CurrentVolume); + eventInstance.setTimelinePosition((int)(ClipStartTime * 1000.0f)); + eventInstance.start(); + } + } + + protected virtual void OnEnter() + { + if (!isPlayheadInside) + { + isPlayheadInside = true; + + if (Application.isPlaying) + { + PlayEvent(); + } + else + { + // Handled by the editor auditioning system. + EventArgs args = new EventArgs(); + Enter.Invoke(this, args); + eventInstance = args.eventInstance; + } + } + } + + protected virtual void OnExit() + { + if (isPlayheadInside) + { + isPlayheadInside = false; + + if (Application.isPlaying) + { + if (eventInstance.isValid()) + { + if (StopType != STOP_MODE.None) + { + eventInstance.stop(StopType == STOP_MODE.Immediate ? FMOD.Studio.STOP_MODE.IMMEDIATE : FMOD.Studio.STOP_MODE.ALLOWFADEOUT); + } + eventInstance.release(); + eventInstance.clearHandle(); + } + } + else + { + // Handled by the editor auditioning system. + EventArgs args = new EventArgs(); + args.eventInstance = eventInstance; + Exit.Invoke(this, args); + } + } + } + + public override void ProcessFrame(Playable playable, FrameData info, object playerData) + { + if (eventInstance.isValid()) + { + foreach (ParameterAutomationLink link in ParameterLinks) + { + float value = ParameterAutomation.GetValue(link.Slot); + eventInstance.setParameterByID(link.ID, value); + } + } + } + + public void UpdateBehavior(float time, float volume) + { + if (volume != CurrentVolume) + { + CurrentVolume = volume; + + if (eventInstance.isValid()) + { + eventInstance.setVolume(volume); + } + } + + if ((time >= OwningClip.start) && (time < OwningClip.end)) + { + ClipStartTime = time - (float)OwningClip.start; + OnEnter(); + } + else + { + OnExit(); + } + } + + public override void OnGraphStop(Playable playable) + { + isPlayheadInside = false; + + if (Application.isPlaying) + { + if (eventInstance.isValid()) + { + eventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); + eventInstance.release(); + RuntimeManager.StudioSystem.update(); + } + } + else + { + // Handled by the editor auditioning system. + EventArgs args = new EventArgs(); + args.eventInstance = eventInstance; + GraphStop.Invoke(this, args); + } + } + } +} +#endif diff --git a/Assets/Plugins/FMOD/src/FMODEventPlayable.cs.meta b/Assets/Plugins/FMOD/src/FMODEventPlayable.cs.meta new file mode 100644 index 0000000..2886889 --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODEventPlayable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 987a467495df9d942b56b1b51381d095 +timeCreated: 1523230466 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 392af304825cbe847bbf4e603852e4dd, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/FMODEventTrack.cs b/Assets/Plugins/FMOD/src/FMODEventTrack.cs new file mode 100644 index 0000000..aabc4ec --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODEventTrack.cs @@ -0,0 +1,73 @@ +#if UNITY_TIMELINE_EXIST + +using System; +using System.ComponentModel; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace FMODUnity +{ + [TrackColor(0.066f, 0.134f, 0.244f)] + [TrackClipType(typeof(FMODEventPlayable))] + [TrackBindingType(typeof(GameObject))] + [DisplayName("FMOD/Event Track")] + public class FMODEventTrack : TrackAsset + { + public FMODEventMixerBehaviour template = new FMODEventMixerBehaviour(); + + public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) + { + var director = go.GetComponent(); + var trackTargetObject = director.GetGenericBinding(this) as GameObject; + + foreach (var clip in GetClips()) + { + var playableAsset = clip.asset as FMODEventPlayable; + + if (playableAsset) + { + playableAsset.TrackTargetObject = trackTargetObject; + playableAsset.OwningClip = clip; + } + } + + var scriptPlayable = ScriptPlayable.Create(graph, template, inputCount); + return scriptPlayable; + } + } + + [Serializable] + public class FMODEventMixerBehaviour : PlayableBehaviour + { + [Range(0, 1)] + public float volume = 1; + + public override void ProcessFrame(Playable playable, FrameData info, object playerData) + { +#if UNITY_EDITOR + /* + * Process frame is called from OnGUI() when auditioning. + * Check playing to avoid retriggering sounds while scrubbing or repainting. + */ + bool playing = playable.GetGraph().IsPlaying(); + if (!playing) + { + return; + } +#endif //UNITY_EDITOR + + int inputCount = playable.GetInputCount(); + float time = (float)playable.GetGraph().GetRootPlayable(0).GetTime(); + + for (int i = 0; i < inputCount; i++) + { + ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); + FMODEventPlayableBehavior input = inputPlayable.GetBehaviour(); + + input.UpdateBehavior(time, volume); + } + } + } +} +#endif diff --git a/Assets/Plugins/FMOD/src/FMODEventTrack.cs.meta b/Assets/Plugins/FMOD/src/FMODEventTrack.cs.meta new file mode 100644 index 0000000..74e0546 --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODEventTrack.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 133253f56854570409c222a87786b263 +timeCreated: 1523230466 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: a4edfa5854cdec34b98b1c55f0562bdd, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs b/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs new file mode 100644 index 0000000..a2518db --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace FMODUnity +{ + public class FMODRuntimeManagerOnGUIHelper : MonoBehaviour + { + public RuntimeManager TargetRuntimeManager = null; + + private void OnGUI() + { + if (TargetRuntimeManager) + { + TargetRuntimeManager.ExecuteOnGUI(); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs.meta b/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs.meta new file mode 100644 index 0000000..f2b59e1 --- /dev/null +++ b/Assets/Plugins/FMOD/src/FMODRuntimeManagerOnGUIHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4417faacebce0de4fbde25ec23055cf4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/ParamRef.cs b/Assets/Plugins/FMOD/src/ParamRef.cs new file mode 100644 index 0000000..0d0927f --- /dev/null +++ b/Assets/Plugins/FMOD/src/ParamRef.cs @@ -0,0 +1,12 @@ +using System; + +namespace FMODUnity +{ + [Serializable] + public class ParamRef + { + public string Name; + public float Value; + public FMOD.Studio.PARAMETER_ID ID; + } +} diff --git a/Assets/Plugins/FMOD/src/ParamRef.cs.meta b/Assets/Plugins/FMOD/src/ParamRef.cs.meta new file mode 100644 index 0000000..11ab43e --- /dev/null +++ b/Assets/Plugins/FMOD/src/ParamRef.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 00e1a9817a5d9844796d7c313b1ab197 +timeCreated: 1444192631 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/ParamRefAttribute.cs b/Assets/Plugins/FMOD/src/ParamRefAttribute.cs new file mode 100644 index 0000000..0ffb2a0 --- /dev/null +++ b/Assets/Plugins/FMOD/src/ParamRefAttribute.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace FMODUnity +{ + public class ParamRefAttribute : PropertyAttribute + { + } +} diff --git a/Assets/Plugins/FMOD/src/ParamRefAttribute.cs.meta b/Assets/Plugins/FMOD/src/ParamRefAttribute.cs.meta new file mode 100644 index 0000000..1704608 --- /dev/null +++ b/Assets/Plugins/FMOD/src/ParamRefAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ae6224668d1647429723f89e10d593f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Platform.cs b/Assets/Plugins/FMOD/src/Platform.cs new file mode 100644 index 0000000..5c1ed5c --- /dev/null +++ b/Assets/Plugins/FMOD/src/Platform.cs @@ -0,0 +1,1035 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Serialization; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMOD +{ + public partial class VERSION + { +#if DEVELOPMENT_BUILD + public const string dllSuffix = "L"; +#else + public const string dllSuffix = ""; +#endif + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { +#if DEVELOPMENT_BUILD + public const string dllSuffix = "L"; +#else + public const string dllSuffix = ""; +#endif + } +} + +namespace FMODUnity +{ + public class PlatformCallbackHandler : ScriptableObject + { + // A hook for custom initialization logic. RuntimeManager.Initialize calls this + // just before calling system.Initialize. + // Call reportResult() with the result of each FMOD call to use FMOD's error handling logic. + public virtual void PreInitialize(FMOD.Studio.System system, Action reportResult) + { + } + } + + // This class holds per-platform settings and provides hooks for platform-specific behaviour. + // Each platform has a parent platform, forming a hierarchy that is rooted at PlatformDefault. + // By default a platform inherits all of its properties from its parent platform; this behaviour + // can be overridden for each property. + // + // There is at least one concrete derived class for each supported platform; these classes use + // [InitializeOnLoad] and a static constructor to register themselves as supported platforms by + // calling Settings.AddPlatformTemplate. The user can also create instances of the PlatformGroup + // class and use them to group platforms that have settings in common. + public abstract class Platform : ScriptableObject + { + internal const float DefaultPriority = 0; + +#if UNITY_EDITOR + internal const int MaximumCoreCount = 16; + + internal static readonly FileLayout[] OldFileLayouts = { + FileLayout.Release_1_10, + FileLayout.Release_2_0, + FileLayout.Release_2_1, + }; +#endif + + // These need to match the function called by LoadStaticPlugins + internal const string RegisterStaticPluginsClassName = "StaticPluginManager"; + internal const string RegisterStaticPluginsFunctionName = "Register"; + + // This is a persistent identifier. It is used: + // * To link platforms together at load time + // * To avoid creating duplicate platforms from templates (in Settings.OnEnable) + // * As a key for SettingsEditor UI state + // It should be kept stable for concrete platforms (like PlatformWindows) to support + // settings migration in the future. + [SerializeField] + private string identifier; + + [SerializeField] + private string parentIdentifier; + + [SerializeField] + private bool active = false; + + [SerializeField] + protected PropertyStorage Properties = new PropertyStorage(); + + [SerializeField] + [FormerlySerializedAs("outputType")] + internal string OutputTypeName; + + private static List StaticThreadAffinities = new List(); + + [SerializeField] + private PropertyThreadAffinityList threadAffinities = new PropertyThreadAffinityList(); + +#if UNITY_EDITOR + [SerializeField] + private float displaySortOrder; + + [SerializeField] + private List childIdentifiers = new List(); +#else + // The parent platform from which this platform inherits its property values. + [NonSerialized] + public Platform Parent; +#endif + + internal string Identifier + { + get + { + return identifier; + } + + set + { + identifier = value; + } + } + + // The display name to show for this platform in the UI. + internal abstract string DisplayName { get; } + + // Declares the Unity RuntimePlatforms this platform implements. + internal abstract void DeclareRuntimePlatforms(Settings settings); + +#if UNITY_EDITOR + // The Unity BuildTargets this platform implements. + // Returns BuildTarget.NoTarget if the correct value is not defined, as some BuildTarget + // values are only defined in specific circumstances (e.g. Stadia required Unity 2019.3). + internal abstract IEnumerable GetBuildTargets(); + + // The old FMOD platform identifier that this platform corresponds to, for settings migration. + internal abstract Legacy.Platform LegacyIdentifier { get; } +#endif + + // The priority to use when finding a platform to support the current Unity runtime + // platform (higher priorities are tried first). + internal virtual float Priority { get { return DefaultPriority; } } + + // Determines whether this platform matches the current environment. When more than one + // platform implements the current Unity runtime platform, FMOD for Unity will use the + // highest-priority platform that returns true from MatchesCurrentEnvironment. + internal virtual bool MatchesCurrentEnvironment { get { return true; } } + + // Whether this platform is a fixed part of the FMOD for Unity settings, or can be + // added/removed by the user. + internal virtual bool IsIntrinsic { get { return false; } } + + // A hook for platform-specific initialization logic. RuntimeManager.Initialize calls this + // before calling FMOD.Studio.System.create. + internal virtual void PreSystemCreate(Action reportResult) + { + } + + // A hook for platform-specific initialization logic. RuntimeManager.Initialize calls this + // just before calling studioSystem.Initialize. + internal virtual void PreInitialize(FMOD.Studio.System studioSystem) + { + } + + // The folder in which FMOD .bank files are stored. Used when loading banks. + internal virtual string GetBankFolder() + { + return Application.streamingAssetsPath; + } + +#if UNITY_EDITOR + [Flags] + public enum BinaryType + { + Release = 1, + Logging = 2, + Optional = 4, + AllVariants = 8, + All = Release | Logging | Optional | AllVariants + } + + protected virtual IEnumerable GetBinaryPaths(BuildTarget buildTarget, BinaryType binaryType, string prefix) + { + foreach (BinaryFileInfo info in GetBinaryFileInfo(buildTarget, binaryType)) + { + yield return info.LatestLocation(); + } + } + + internal abstract class FileInfo + { + public FileInfo(FileRecord fileRecord, BinaryType type) + { + this.fileRecord = fileRecord; + this.type = type; + } + + public readonly BinaryType type; + + private readonly FileRecord fileRecord; + + public string LatestLocation() + { + return GetLocation(FileLayout.Latest); + } + + public IEnumerable OldLocations() + { + foreach (FileLayout layout in OldFileLayouts) + { + string location = GetLocation(layout); + + if (location != null) + { + yield return location; + } + } + } + + private string GetLocation(FileLayout layout) + { + string basePath = GetBasePath(layout); + + if (basePath == null) + { + return null; + } + + bool absolute; + string path; + fileRecord.GetPath(layout, out path, out absolute); + + if (absolute) + { + return path; + } + else + { + return string.Format("{0}/{1}", basePath, path); + } + } + + protected abstract string GetBasePath(FileLayout layout); + } + + internal class BinaryFileInfo : FileInfo + { + public BinaryFileInfo(Platform platform, FileRecord fileRecord, BuildTarget buildTarget, BinaryType type) + : base(fileRecord, type) + { + this.platform = platform; + this.buildTarget = buildTarget; + } + + private readonly Platform platform; + private readonly BuildTarget buildTarget; + + protected override string GetBasePath(FileLayout layout) + { + BinaryAssetFolderInfo info = platform.GetBinaryAssetFolder(buildTarget); + + if (layout < info.oldestLayout) + { + return null; + } + + switch (layout) + { + case FileLayout.Release_1_10: + return info.path_1_10; + case FileLayout.Release_2_0: + return string.Format("Plugins/FMOD/lib/{0}", info.baseName); + case FileLayout.Release_2_1: + case FileLayout.Release_2_2: + return $"{RuntimeUtils.PluginBasePath}/platforms/{info.baseName}/lib"; + default: + throw new ArgumentException("Unrecognised file layout: " + layout); + } + } + } + + public struct FileRecord + { + public FileRecord(string latestPath) + { + this.latestPath = latestPath; + pathVersions = null; + } + + public FileRecord WithAbsoluteVersion(FileLayout layout, string path) + { + AddVersion(layout, path, true); + return this; + } + + public FileRecord WithRelativeVersion(FileLayout layout, string path) + { + AddVersion(layout, path, false); + return this; + } + + private void AddVersion(FileLayout layout, string path, bool absolute) + { + if (pathVersions == null) + { + pathVersions = new Dictionary(); + } + + pathVersions.Add(layout, new PathInfo() { path = path, absolute = absolute }); + } + + public void GetPath(FileLayout layout, out string path, out bool absolute) + { + if (pathVersions != null) + { + PathInfo pathForLayout; + + if (pathVersions.TryGetValue(layout, out pathForLayout)) + { + absolute = pathForLayout.absolute; + path = pathForLayout.path; + return; + } + } + + absolute = false; + path = latestPath; + } + + private struct PathInfo + { + public string path; + public bool absolute; + } + + private readonly string latestPath; + private Dictionary pathVersions; + } + + internal IEnumerable GetBinaryFileInfo(BuildTarget buildTarget, BinaryType binaryType) + { + bool allVariants = (binaryType & BinaryType.AllVariants) == BinaryType.AllVariants; + + if ((binaryType & BinaryType.Release) == BinaryType.Release) + { + foreach (FileRecord record in GetBinaryFiles(buildTarget, allVariants, "")) + { + yield return CreateFileInfo(record, buildTarget, BinaryType.Release); + } + } + + if ((binaryType & BinaryType.Logging) == BinaryType.Logging) + { + foreach (FileRecord record in GetBinaryFiles(buildTarget, allVariants, "L")) + { + yield return CreateFileInfo(record, buildTarget, BinaryType.Logging); + } + } + + if ((binaryType & BinaryType.Optional) == BinaryType.Optional) + { + foreach (FileRecord record in GetOptionalBinaryFiles(buildTarget, allVariants)) + { + yield return CreateFileInfo(record, buildTarget, BinaryType.Optional); + } + } + } + + internal class SourceFileInfo : FileInfo + { + public SourceFileInfo(Platform platform, FileRecord fileRecord) + : base(fileRecord, BinaryType.Optional) + { + this.platform = platform; + } + + private readonly Platform platform; + + protected override string GetBasePath(FileLayout layout) + { + BinaryAssetFolderInfo info = platform.GetBinaryAssetFolder(platform.GetBuildTargets().First()); + + if (layout < info.oldestLayout) + { + return null; + } + + switch (layout) + { + case FileLayout.Release_1_10: + return "Plugins/FMOD/Wrapper"; + case FileLayout.Release_2_0: + return "Plugins/FMOD/src/Runtime/wrapper"; + case FileLayout.Release_2_1: + case FileLayout.Release_2_2: + return $"{RuntimeUtils.PluginBasePath}/platforms/{info.baseName}/src"; + default: + throw new ArgumentException("Unrecognised file layout: " + layout); + } + } + } + + internal IEnumerable GetSourceFileInfo() + { + foreach (FileRecord record in GetSourceFiles()) + { + yield return new SourceFileInfo(this, record); + } + } + + internal BinaryFileInfo CreateFileInfo(FileRecord record, BuildTarget buildTarget, BinaryType binaryType) + { + return new BinaryFileInfo(this, record, buildTarget, binaryType); + } + + internal virtual IEnumerable GetObsoleteAssetPaths() + { + foreach (string path in GetObsoleteFiles()) + { + yield return $"{RuntimeUtils.PluginBasePath}/{path}"; + } + } + + // Called by Settings.CanBuildTarget to get the required binaries for the current + // build target and logging state. + internal virtual IEnumerable GetBinaryFilePaths(BuildTarget buildTarget, BinaryType binaryType) + { + return GetBinaryPaths(buildTarget, binaryType, RuntimeUtils.PluginBasePath); + } + + // Called by Settings.SelectBinaries to get: + // * The required and optional binaries for the current build target and logging state; + // these get enabled. + // * All binaries; any that weren't enabled in the previous step get disabled. + internal virtual IEnumerable GetBinaryAssetPaths(BuildTarget buildTarget, BinaryType binaryType) + { + return GetBinaryPaths(buildTarget, binaryType, RuntimeUtils.PluginBasePath); + } + + public enum FileLayout : uint + { + Release_1_10, + Release_2_0, + Release_2_1, + Release_2_2, + Latest = Release_2_2, + } + + protected class BinaryAssetFolderInfo + { + public BinaryAssetFolderInfo(string baseName, string path_1_10) + { + this.baseName = baseName; + this.path_1_10 = path_1_10; + this.oldestLayout = FileLayout.Release_1_10; + } + + public BinaryAssetFolderInfo(string baseName, FileLayout oldestLayout) + { + this.baseName = baseName; + this.path_1_10 = null; + this.oldestLayout = oldestLayout; + } + + public string baseName { get; private set; } + public string path_1_10 { get; private set; } + public FileLayout oldestLayout { get; private set; } + } + + protected abstract BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget); + + protected abstract IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix); + + protected virtual IEnumerable GetOptionalBinaryFiles(BuildTarget buildTarget, bool allVariants) + { + yield break; + } + + protected virtual IEnumerable GetSourceFiles() + { + yield break; + } + + protected virtual IEnumerable GetObsoleteFiles() + { + yield break; + } + + internal virtual bool IsFMODStaticallyLinked { get { return false; } } + + internal virtual bool SupportsAdditionalCPP(BuildTarget target) + { + return true; + } +#endif + + // The base path for FMOD plugins when in a standalone player. + protected virtual string GetPluginBasePath() + { + return string.Format("{0}/Plugins", Application.dataPath); + } + + // Returns the full path for an FMOD plugin. + internal virtual string GetPluginPath(string pluginName) + { + throw new NotImplementedException(string.Format("Plugins are not implemented on platform {0}", Identifier)); + } + + // Loads static and dynamic FMOD plugins for this platform. + internal virtual void LoadPlugins(FMOD.System coreSystem, Action reportResult) + { + LoadDynamicPlugins(coreSystem, reportResult); + LoadStaticPlugins(coreSystem, reportResult); + } + + // Loads dynamic FMOD plugins for this platform. + internal virtual void LoadDynamicPlugins(FMOD.System coreSystem, Action reportResult) + { + List pluginNames = Plugins; + + if (pluginNames == null) + { + return; + } + + foreach (string pluginName in pluginNames) + { + if (string.IsNullOrEmpty(pluginName)) + { + continue; + } + + string pluginPath = GetPluginPath(pluginName); + uint handle; + + FMOD.RESULT result = coreSystem.loadPlugin(pluginPath, out handle); + +#if UNITY_64 || UNITY_EDITOR_64 + // Add a "64" suffix and try again + if (result == FMOD.RESULT.ERR_FILE_BAD || result == FMOD.RESULT.ERR_FILE_NOTFOUND) + { + string pluginPath64 = GetPluginPath(pluginName + "64"); + result = coreSystem.loadPlugin(pluginPath64, out handle); + } +#endif + + reportResult(result, string.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath)); + } + } + + // Loads static FMOD plugins for this platform. + internal virtual void LoadStaticPlugins(FMOD.System coreSystem, Action reportResult) + { + if (StaticPlugins.Count > 0) + { +#if !UNITY_EDITOR && ENABLE_IL2CPP + // We use reflection here to avoid compile errors if the plugin registration code doesn't exist. + // It should be generated by Settings.PreprocessStaticPlugins(), which is called from + // IPreprocessBuildWithReport.OnPreprocessBuild(). However, some compilation scenarios + // (such as AddressableAssetSettings.BuildPlayerContent()) don't call OnPreprocessBuild(), + // so we can't generate the plugin registration code. + + string className = string.Format("FMODUnity.{0}", RegisterStaticPluginsClassName); + Type type = Type.GetType(className); + + if (type == null) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: {0} static plugins specified, but the {1} class was not found.", + StaticPlugins.Count, className); + return; + } + + MethodInfo method = type.GetMethod(RegisterStaticPluginsFunctionName, + BindingFlags.Public | BindingFlags.Static); + + if (method == null) + { + RuntimeUtils.DebugLogWarningFormat( + "FMOD: {0} static plugins specified, but the {1}.{2} method was not found.", + StaticPlugins.Count, className, RegisterStaticPluginsFunctionName); + return; + } + + method.Invoke(null, new object[] { coreSystem, reportResult }); +#else + RuntimeUtils.DebugLogWarningFormat( + "FMOD: {0} static plugins specified, but static plugins are only supported on the IL2CPP scripting backend", + StaticPlugins.Count); +#endif + } + } + + // Ensures that this platform has properties. + internal void AffirmProperties() + { + if (!active) + { + Properties = new PropertyStorage(); + InitializeProperties(); + active = true; + } + } + + // Clears this platform's properties. + internal void ClearProperties() + { + if (active) + { + Properties = new PropertyStorage(); + active = false; +#if UNITY_EDITOR + DisplaySortOrder = 0; +#endif + } + } + + // Initializes this platform's properties to their default values. + internal virtual void InitializeProperties() + { + if (!IsIntrinsic) + { + ParentIdentifier = PlatformDefault.ConstIdentifier; + } + } + + // Ensures that this platform's properties are valid after loading from file. + internal virtual void EnsurePropertiesAreValid() + { + if (!IsIntrinsic && string.IsNullOrEmpty(ParentIdentifier)) + { + ParentIdentifier = PlatformDefault.ConstIdentifier; + } + } + + internal string ParentIdentifier + { + get + { + return parentIdentifier; + } + + set + { + parentIdentifier = value; + } + } + +#if UNITY_EDITOR + internal float DisplaySortOrder + { + get + { + return displaySortOrder; + } + + set + { + displaySortOrder = value; + } + } +#endif + + internal bool IsLiveUpdateEnabled + { + get + { +#if DEVELOPMENT_BUILD || UNITY_EDITOR + return LiveUpdate != TriStateBool.Disabled; +#else + return LiveUpdate == TriStateBool.Enabled; +#endif + } + } + + internal bool IsOverlayEnabled + { + get + { +#if DEVELOPMENT_BUILD || UNITY_EDITOR + return Overlay != TriStateBool.Disabled; +#else + return Overlay == TriStateBool.Enabled; +#endif + } + } + + // A property value that can be inherited from the parent or overridden. + public class Property + { + public T Value; + public bool HasValue; + } + + // These stub classes are needed because Unity can't serialize generic classes + [Serializable] + public class PropertyBool : Property + { + } + + [Serializable] + public class PropertyScreenPosition : Property + { + } + + [Serializable] + public class PropertyInt : Property + { + } + + [Serializable] + public class PropertySpeakerMode : Property + { + } + + [Serializable] + public class PropertyString : Property + { + } + + [Serializable] + public class PropertyStringList : Property> + { + } + + [Serializable] + public class PropertyCallbackHandler : Property + { + } + + internal interface PropertyOverrideControl + { + bool HasValue(Platform platform); + void Clear(Platform platform); + } + + // This class provides access to a specific property on any Platform object; the property to + // operate on is determined by the Getter function. This allows client code to operate on + // platform properties in a generic manner. + internal struct PropertyAccessor : PropertyOverrideControl + { + private readonly Func> Getter; + private readonly T DefaultValue; + + public PropertyAccessor(Func> getter, T defaultValue) + { + Getter = getter; + DefaultValue = defaultValue; + } + + // Determine whether the property has a value in the given platform, or is inherited + // from the parent. + public bool HasValue(Platform platform) + { + return platform.Active && Getter(platform.Properties).HasValue; + } + + // Get the (possibly inherited) value of the property for the given platform. + public T Get(Platform platform) + { + for (Platform current = platform; current != null; current = current.Parent) + { + if (current.Active) + { + Property property = Getter(current.Properties); + + if (property.HasValue) + { + return property.Value; + } + } + } + +#if UNITY_EDITOR + if (platform is PlatformPlayInEditor) + { + return Get(Settings.EditorSettings.CurrentEditorPlatform); + } +#endif + + return DefaultValue; + } + + // Set the value of the property in the given platform, so it is not inherited from the + // platform's parent. + public void Set(Platform platform, T value) + { + Property property = Getter(platform.Properties); + + property.Value = value; + property.HasValue = true; + } + + // Clear the value of the property in the given platform, so it is inherited from the + // platform's parent. + public void Clear(Platform platform) + { + Getter(platform.Properties).HasValue = false; + } + } + + // This class stores all of the inheritable properties for a platform. + [Serializable] + public class PropertyStorage + { + public PropertyBool LiveUpdate = new PropertyBool(); + public PropertyInt LiveUpdatePort = new PropertyInt(); + public PropertyBool Overlay = new PropertyBool(); + public PropertyScreenPosition OverlayPosition = new PropertyScreenPosition(); + public PropertyInt OverlayFontSize = new PropertyInt(); + public PropertyBool Logging = new PropertyBool(); + public PropertyInt SampleRate = new PropertyInt(); + public PropertyString BuildDirectory = new PropertyString(); + public PropertySpeakerMode SpeakerMode = new PropertySpeakerMode(); + public PropertyInt VirtualChannelCount = new PropertyInt(); + public PropertyInt RealChannelCount = new PropertyInt(); + public PropertyInt DSPBufferLength = new PropertyInt(); + public PropertyInt DSPBufferCount = new PropertyInt(); + public PropertyStringList Plugins = new PropertyStringList(); + public PropertyStringList StaticPlugins = new PropertyStringList(); + public PropertyCallbackHandler CallbackHandler = new PropertyCallbackHandler(); + } + + // Whether this platform is active in the settings UI. + internal bool Active { get { return active; } } + + // Whether this platform has any properties that are not inherited from the parent. + internal bool HasAnyOverriddenProperties + { + get + { + return active && + ( + Properties.LiveUpdate.HasValue + || Properties.LiveUpdatePort.HasValue + || Properties.Overlay.HasValue + || Properties.OverlayPosition.HasValue + || Properties.OverlayFontSize.HasValue + || Properties.Logging.HasValue + || Properties.SampleRate.HasValue + || Properties.BuildDirectory.HasValue + || Properties.SpeakerMode.HasValue + || Properties.VirtualChannelCount.HasValue + || Properties.RealChannelCount.HasValue + || Properties.DSPBufferLength.HasValue + || Properties.DSPBufferCount.HasValue + || Properties.Plugins.HasValue + || Properties.StaticPlugins.HasValue + ); + } + } + + // These accessors provide (possibly inherited) property values. + public TriStateBool LiveUpdate { get { return PropertyAccessors.LiveUpdate.Get(this); } } + public int LiveUpdatePort { get { return PropertyAccessors.LiveUpdatePort.Get(this); } } + public TriStateBool Overlay { get { return PropertyAccessors.Overlay.Get(this); } } + public ScreenPosition OverlayRect { get { return PropertyAccessors.OverlayPosition.Get(this); } } + public int OverlayFontSize { get { return PropertyAccessors.OverlayFontSize.Get(this); } } + public void SetOverlayFontSize(int size) { PropertyAccessors.OverlayFontSize.Set(this, size); } + public TriStateBool Logging { get { return PropertyAccessors.Logging.Get(this); } } + public int SampleRate { get { return PropertyAccessors.SampleRate.Get(this); } } + public string BuildDirectory { get { return PropertyAccessors.BuildDirectory.Get(this); } } + public FMOD.SPEAKERMODE SpeakerMode { get { return PropertyAccessors.SpeakerMode.Get(this); } } + public int VirtualChannelCount { get { return PropertyAccessors.VirtualChannelCount.Get(this); } } + public int RealChannelCount { get { return PropertyAccessors.RealChannelCount.Get(this); } } + public int DSPBufferLength { get { return PropertyAccessors.DSPBufferLength.Get(this); } } + public int DSPBufferCount { get { return PropertyAccessors.DSPBufferCount.Get(this); } } + public List Plugins { get { return PropertyAccessors.Plugins.Get(this); } } + public List StaticPlugins { get { return PropertyAccessors.StaticPlugins.Get(this); } } + public PlatformCallbackHandler CallbackHandler { get { return PropertyAccessors.CallbackHandler.Get(this); } } + + // These accessors provide full access to properties. + internal static class PropertyAccessors + { + public static readonly PropertyAccessor LiveUpdate + = new PropertyAccessor(properties => properties.LiveUpdate, TriStateBool.Disabled); + + public static readonly PropertyAccessor LiveUpdatePort + = new PropertyAccessor(properties => properties.LiveUpdatePort, 9264); + + public static readonly PropertyAccessor Overlay + = new PropertyAccessor(properties => properties.Overlay, TriStateBool.Disabled); + + public static readonly PropertyAccessor OverlayPosition = new PropertyAccessor(properties => properties.OverlayPosition, ScreenPosition.TopLeft); + + public static readonly PropertyAccessor OverlayFontSize = new PropertyAccessor(properties => properties.OverlayFontSize, 14); + + public static readonly PropertyAccessor Logging + = new PropertyAccessor(properties => properties.Logging, TriStateBool.Disabled); + + public static readonly PropertyAccessor SampleRate + = new PropertyAccessor(properties => properties.SampleRate, 0); + + public static readonly PropertyAccessor BuildDirectory + = new PropertyAccessor(properties => properties.BuildDirectory, "Desktop"); + + public static readonly PropertyAccessor SpeakerMode + = new PropertyAccessor(properties => properties.SpeakerMode, FMOD.SPEAKERMODE.STEREO); + + public static readonly PropertyAccessor VirtualChannelCount + = new PropertyAccessor(properties => properties.VirtualChannelCount, 128); + + public static readonly PropertyAccessor RealChannelCount + = new PropertyAccessor(properties => properties.RealChannelCount, 32); + + public static readonly PropertyAccessor DSPBufferLength + = new PropertyAccessor(properties => properties.DSPBufferLength, 0); + + public static readonly PropertyAccessor DSPBufferCount + = new PropertyAccessor(properties => properties.DSPBufferCount, 0); + + public static readonly PropertyAccessor> Plugins + = new PropertyAccessor>(properties => properties.Plugins, null); + + public static readonly PropertyAccessor> StaticPlugins + = new PropertyAccessor>(properties => properties.StaticPlugins, null); + + public static readonly PropertyAccessor CallbackHandler + = new PropertyAccessor(properties => properties.CallbackHandler, null); + } + +#if UNITY_EDITOR + // The parent platform from which this platform inherits its property values. + internal Platform Parent + { + get + { + return (ParentIdentifier != null) ? Settings.Instance.FindPlatform(ParentIdentifier) : null; + } + } + + // The platforms which inherit their property values from this platform. + internal List ChildIdentifiers { get { return childIdentifiers; } } +#endif + + // Checks whether this platform inherits from the given platform, so we can avoid creating + // inheritance loops. + internal bool InheritsFrom(Platform platform) + { + if (platform == this) + { + return true; + } + else if (Parent != null) + { + return Parent.InheritsFrom(platform); + } + else + { + return false; + } + } + + internal FMOD.OUTPUTTYPE GetOutputType() + { + if (Enum.IsDefined(typeof(FMOD.OUTPUTTYPE), OutputTypeName)) + { + return (FMOD.OUTPUTTYPE)Enum.Parse(typeof(FMOD.OUTPUTTYPE), OutputTypeName); + } + return FMOD.OUTPUTTYPE.AUTODETECT; + } + +#if UNITY_EDITOR + public struct OutputType + { + public string displayName; + public FMOD.OUTPUTTYPE outputType; + } + + internal abstract OutputType[] ValidOutputTypes { get; } + + internal virtual int CoreCount { get { return 0; } } +#endif + + internal virtual List DefaultThreadAffinities { get { return StaticThreadAffinities; } } + + [Serializable] + public class PropertyThreadAffinityList : Property> + { + } + + public IEnumerable ThreadAffinities + { + get + { + if (threadAffinities.HasValue) + { + return threadAffinities.Value; + } + else + { + return DefaultThreadAffinities; + } + } + } + + internal PropertyThreadAffinityList ThreadAffinitiesProperty { get { return threadAffinities; } } + + internal virtual List DefaultCodecChannels { get { return staticCodecChannels; } } + + private static List staticCodecChannels = new List() + { + new CodecChannelCount { format = CodecType.FADPCM, channels = 32 }, + new CodecChannelCount { format = CodecType.Vorbis, channels = 0 }, + }; + + [Serializable] + internal class PropertyCodecChannels : Property> + { + } + + [SerializeField] + private PropertyCodecChannels codecChannels = new PropertyCodecChannels(); + + internal List CodecChannels + { + get + { + if (codecChannels.HasValue) + { + return codecChannels.Value; + } + else + { + return DefaultCodecChannels; + } + } + } + + internal PropertyCodecChannels CodecChannelsProperty { get { return codecChannels; } } + } +} diff --git a/Assets/Plugins/FMOD/src/Platform.cs.meta b/Assets/Plugins/FMOD/src/Platform.cs.meta new file mode 100644 index 0000000..d3f401f --- /dev/null +++ b/Assets/Plugins/FMOD/src/Platform.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e7df340ba8041134888b271ea2124fcd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/PlatformDefault.cs b/Assets/Plugins/FMOD/src/PlatformDefault.cs new file mode 100644 index 0000000..588ef22 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformDefault.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMODUnity +{ + public class PlatformDefault : Platform + { + public const string ConstIdentifier = "default"; + + public PlatformDefault() + { + Identifier = ConstIdentifier; + } + + internal override string DisplayName { get { return "Default"; } } + internal override void DeclareRuntimePlatforms(Settings settings) { } +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield break; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.Default; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return null; + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield break; + } +#endif + + internal override bool IsIntrinsic { get { return true; } } + + internal override void InitializeProperties() + { + base.InitializeProperties(); + + PropertyAccessors.Plugins.Set(this, new List()); + PropertyAccessors.StaticPlugins.Set(this, new List()); + } + + internal override void EnsurePropertiesAreValid() + { + base.EnsurePropertiesAreValid(); + + if (StaticPlugins == null) + { + PropertyAccessors.StaticPlugins.Set(this, new List()); + } + } + + // null means no valid output types - don't display the field in the UI +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes { get { return null; } } +#endif + } +} diff --git a/Assets/Plugins/FMOD/src/PlatformDefault.cs.meta b/Assets/Plugins/FMOD/src/PlatformDefault.cs.meta new file mode 100644 index 0000000..e5e09f9 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformDefault.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9587379c972e4a54da1949613f11e1c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/PlatformGroup.cs b/Assets/Plugins/FMOD/src/PlatformGroup.cs new file mode 100644 index 0000000..4cae656 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformGroup.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMODUnity +{ + public class PlatformGroup : Platform + { + [SerializeField] + private string displayName; + + [SerializeField] + private Legacy.Platform legacyIdentifier; + + internal override string DisplayName { get { return displayName; } } + internal override void DeclareRuntimePlatforms(Settings settings) { } +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield break; + } + + internal override Legacy.Platform LegacyIdentifier { get { return legacyIdentifier; } } + + internal static PlatformGroup Create(string displayName, Legacy.Platform legacyIdentifier) + { + PlatformGroup group = CreateInstance(); + group.Identifier = GUID.Generate().ToString(); + group.displayName = displayName; + group.legacyIdentifier = legacyIdentifier; + group.AffirmProperties(); + + return group; + } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return null; + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield break; + } + + internal override OutputType[] ValidOutputTypes { get { return null; } } +#endif + } +} diff --git a/Assets/Plugins/FMOD/src/PlatformGroup.cs.meta b/Assets/Plugins/FMOD/src/PlatformGroup.cs.meta new file mode 100644 index 0000000..c928a3b --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformGroup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6d049eb0281db9c4abd635ba1c79cb7b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs b/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs new file mode 100644 index 0000000..f42291d --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformMobileHigh : PlatformMobileLow + { + static PlatformMobileHigh() + { + Settings.AddPlatformTemplate("fd7c55dab0fce234b8c25f6ffca523c1"); + } + + internal override string DisplayName { get { return "High-End Mobile"; } } +#if UNITY_EDITOR + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.MobileHigh; } } +#endif + + internal override float Priority { get { return base.Priority + 1; } } + + internal override bool MatchesCurrentEnvironment + { + get + { + if (!Active) + { + return false; + } + +#if UNITY_IOS + switch (UnityEngine.iOS.Device.generation) + { + case UnityEngine.iOS.DeviceGeneration.iPad1Gen: + case UnityEngine.iOS.DeviceGeneration.iPad2Gen: + case UnityEngine.iOS.DeviceGeneration.iPad3Gen: + case UnityEngine.iOS.DeviceGeneration.iPadMini1Gen: + case UnityEngine.iOS.DeviceGeneration.iPhone: + case UnityEngine.iOS.DeviceGeneration.iPhone3G: + case UnityEngine.iOS.DeviceGeneration.iPhone3GS: + case UnityEngine.iOS.DeviceGeneration.iPhone4: + case UnityEngine.iOS.DeviceGeneration.iPhone4S: + return false; + default: + return true; + } +#elif UNITY_ANDROID + if (SystemInfo.processorCount <= 2) + { + return false; + } + else if (SystemInfo.processorCount >= 8) + { + return true; + } + else + { + // check the clock rate on quad core systems + string freqinfo = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; + try + { + using (System.IO.TextReader reader = new System.IO.StreamReader(freqinfo)) + { + string line = reader.ReadLine(); + int khz = int.Parse(line) / 1000; + if (khz >= 1600) + { + return true; + } + else + { + return false; + } + } + } + catch + { + return false; + } + } +#else + return false; +#endif + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs.meta b/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs.meta new file mode 100644 index 0000000..b486913 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformMobileHigh.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 93a382382f106584e8f8f62412fee177 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/PlatformMobileLow.cs b/Assets/Plugins/FMOD/src/PlatformMobileLow.cs new file mode 100644 index 0000000..7fe5352 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformMobileLow.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMODUnity +{ +#if UNITY_EDITOR + [InitializeOnLoad] +#endif + public class PlatformMobileLow : Platform + { + static PlatformMobileLow() + { + Settings.AddPlatformTemplate("c88d16e5272a4e241b0ef0ac2e53b73d"); + } + + internal override string DisplayName { get { return "Low-End Mobile"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.IPhonePlayer, this); + settings.DeclareRuntimePlatform(RuntimePlatform.Android, this); + } + +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield break; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.MobileLow; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return null; + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield break; + } + + internal override bool SupportsAdditionalCPP(BuildTarget target) + { + if (target == BuildTarget.iOS) + { + return PlatformIOS.StaticSupportsAdditionalCpp(); + } + else + { + return base.SupportsAdditionalCPP(target); + } + } +#endif + + internal override float Priority { get { return DefaultPriority + 1; } } + + internal override bool MatchesCurrentEnvironment + { + get + { + return Active; + } + } + +#if UNITY_IOS + internal override void LoadPlugins(FMOD.System coreSystem, Action reportResult) + { + PlatformIOS.StaticLoadPlugins(this, coreSystem, reportResult); + } +#elif UNITY_ANDROID + internal override string GetBankFolder() + { + return PlatformAndroid.StaticGetBankFolder(); + } + + internal override string GetPluginPath(string pluginName) + { + return PlatformAndroid.StaticGetPluginPath(pluginName); + } +#endif + +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes { get { return null; } } +#endif + } +} diff --git a/Assets/Plugins/FMOD/src/PlatformMobileLow.cs.meta b/Assets/Plugins/FMOD/src/PlatformMobileLow.cs.meta new file mode 100644 index 0000000..717ce98 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformMobileLow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3abeb1429547a134480f4f2f1efc7e21 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs b/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs new file mode 100644 index 0000000..3554dcb --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +#if UNITY_EDITOR +namespace FMOD +{ + public partial class VERSION + { + public const string dll = "fmodstudioL"; + } +} + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { + public const string dll = "fmodstudioL"; + } +} +#endif + +namespace FMODUnity +{ + public class PlatformPlayInEditor : Platform + { + public PlatformPlayInEditor() + { + Identifier = "playInEditor"; + } + + internal override string DisplayName { get { return "Editor"; } } + internal override void DeclareRuntimePlatforms(Settings settings) + { + settings.DeclareRuntimePlatform(RuntimePlatform.OSXEditor, this); + settings.DeclareRuntimePlatform(RuntimePlatform.WindowsEditor, this); + settings.DeclareRuntimePlatform(RuntimePlatform.LinuxEditor, this); + } +#if UNITY_EDITOR + internal override IEnumerable GetBuildTargets() + { + yield break; + } + + internal override Legacy.Platform LegacyIdentifier { get { return Legacy.Platform.PlayInEditor; } } + + protected override BinaryAssetFolderInfo GetBinaryAssetFolder(BuildTarget buildTarget) + { + return null; + } + + protected override IEnumerable GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) + { + yield break; + } +#endif + + internal override bool IsIntrinsic { get { return true; } } + + internal override string GetBankFolder() + { + // Use original asset location because streaming asset folder will contain platform specific banks + Settings globalSettings = Settings.Instance; + + string bankFolder = globalSettings.SourceBankPath; + if (globalSettings.HasPlatforms) + { + bankFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(bankFolder, BuildDirectory)); + } + + return bankFolder; + } + +#if UNITY_EDITOR + internal override string GetPluginPath(string pluginName) + { + string platformsFolder = Path.GetFullPath($"{RuntimeUtils.PluginBasePath}/platforms"); + +#if UNITY_EDITOR_WIN && UNITY_EDITOR_64 + return string.Format("{0}/win/lib/x86_64/{1}.dll", platformsFolder, pluginName); +#elif UNITY_EDITOR_WIN + return string.Format("{0}/win/lib/x86/{1}.dll", platformsFolder, pluginName); +#elif UNITY_EDITOR_OSX + string pluginPath = string.Format("{0}/mac/lib/{1}.bundle", platformsFolder, pluginName); + if (System.IO.Directory.Exists(pluginPath)) + { + return pluginPath; + } + else + { + return string.Format("{0}/mac/lib/{1}.dylib", platformsFolder, pluginName); + } +#elif UNITY_EDITOR_LINUX && UNITY_EDITOR_64 + return string.Format("{0}/linux/lib/x86_64/lib{1}.so", platformsFolder, pluginName); +#elif UNITY_EDITOR_LINUX + return string.Format("{0}/linux/lib/x86/lib{1}.so", platformsFolder, pluginName); +#endif + } +#endif + + internal override void LoadStaticPlugins(FMOD.System coreSystem, Action reportResult) + { + // Ignore static plugins when playing in the editor + } + + internal override void InitializeProperties() + { + base.InitializeProperties(); + + PropertyAccessors.LiveUpdate.Set(this, TriStateBool.Enabled); + PropertyAccessors.Overlay.Set(this, TriStateBool.Enabled); + PropertyAccessors.SampleRate.Set(this, 48000); + PropertyAccessors.RealChannelCount.Set(this, 256); + PropertyAccessors.VirtualChannelCount.Set(this, 1024); + } +#if UNITY_EDITOR + internal override OutputType[] ValidOutputTypes { get { return null; } } +#endif + + internal override List DefaultCodecChannels { get { return staticCodecChannels; } } + + private static List staticCodecChannels = new List() + { + new CodecChannelCount { format = CodecType.FADPCM, channels = 0 }, + new CodecChannelCount { format = CodecType.Vorbis, channels = 256 }, + }; + } +} diff --git a/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs.meta b/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs.meta new file mode 100644 index 0000000..692ee07 --- /dev/null +++ b/Assets/Plugins/FMOD/src/PlatformPlayInEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 335f0a4b26fb46942858ea029e030d2a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/RuntimeManager.cs b/Assets/Plugins/FMOD/src/RuntimeManager.cs new file mode 100644 index 0000000..6955a94 --- /dev/null +++ b/Assets/Plugins/FMOD/src/RuntimeManager.cs @@ -0,0 +1,1561 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using UnityEngine; + +#if UNITY_URP_EXIST +using UnityEngine.Rendering.Universal; +using UnityEngine.UI; +#endif + +#if UNITY_ADDRESSABLES_EXIST +using UnityEngine.AddressableAssets; +#endif + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMODUnity +{ + [AddComponentMenu("")] + public class RuntimeManager : MonoBehaviour + { + public const string BankStubPrefix = "bank stub:"; + + private static SystemNotInitializedException initException = null; + private static RuntimeManager instance; + + private Platform currentPlatform; + private FMOD.DEBUG_CALLBACK debugCallback; + private FMOD.SYSTEM_CALLBACK errorCallback; + + private FMOD.Studio.System studioSystem; + private FMOD.System coreSystem; + private FMOD.DSP mixerHead; + + private bool isMuted = false; + + private Dictionary cachedDescriptions = new Dictionary(new GuidComparer()); + + private Dictionary loadedBanks = new Dictionary(); + private List sampleLoadRequests = new List(); + + private List attachedInstances = new List(128); + +#if UNITY_EDITOR + private List eventPositionWarnings = new List(); +#endif + + private bool listenerWarningIssued = false; + + protected bool isOverlayEnabled = false; + private FMODRuntimeManagerOnGUIHelper overlayDrawer = null; + private Rect windowRect = new Rect(10, 10, 300, 100); + + private string lastDebugText; + private float lastDebugUpdate = 0; + + private int loadingBanksRef = 0; + + private static byte[] masterBusPrefix; + private static byte[] eventSet3DAttributes; + private static byte[] systemGetBus; + +#if UNITY_URP_EXIST + private GameObject vrDebugOverlay; + private RectTransform vrDebugRectTransform; + private Text vrDebugText; + private Camera vrDebugCamera; + private string GUIText; +#endif + + static RuntimeManager() + { + UTF8Encoding encoding = new UTF8Encoding(); + + masterBusPrefix = encoding.GetBytes("bus:/, "); + eventSet3DAttributes = encoding.GetBytes("EventInstance::set3DAttributes"); + systemGetBus = encoding.GetBytes("System::getBus"); + } + + + public static bool IsMuted + { + get + { + return Instance.isMuted; + } + } + + [AOT.MonoPInvokeCallback(typeof(FMOD.DEBUG_CALLBACK))] + private static FMOD.RESULT DEBUG_CALLBACK(FMOD.DEBUG_FLAGS flags, IntPtr filePtr, int line, IntPtr funcPtr, IntPtr messagePtr) + { + FMOD.StringWrapper file = new FMOD.StringWrapper(filePtr); + FMOD.StringWrapper func = new FMOD.StringWrapper(funcPtr); + FMOD.StringWrapper message = new FMOD.StringWrapper(messagePtr); + + if (flags == FMOD.DEBUG_FLAGS.ERROR) + { + RuntimeUtils.DebugLogError(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message)); + } + else if (flags == FMOD.DEBUG_FLAGS.WARNING) + { + RuntimeUtils.DebugLogWarning(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message)); + } + else if (flags == FMOD.DEBUG_FLAGS.LOG) + { + RuntimeUtils.DebugLog(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message)); + } + return FMOD.RESULT.OK; + } + + [AOT.MonoPInvokeCallback(typeof(FMOD.SYSTEM_CALLBACK))] + private static FMOD.RESULT ERROR_CALLBACK(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata) + { + FMOD.ERRORCALLBACK_INFO callbackInfo = (FMOD.ERRORCALLBACK_INFO)FMOD.MarshalHelper.PtrToStructure(commanddata1, typeof(FMOD.ERRORCALLBACK_INFO)); + + // Filter out benign expected errors. + if ((callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNEL || callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNELCONTROL) + && callbackInfo.result == FMOD.RESULT.ERR_INVALID_HANDLE) + { + return FMOD.RESULT.OK; + } + if (callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.STUDIO_EVENTINSTANCE + && callbackInfo.functionname.Equals(eventSet3DAttributes) + && callbackInfo.result == FMOD.RESULT.ERR_INVALID_HANDLE) + { + return FMOD.RESULT.OK; + } + if (callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.STUDIO_SYSTEM + && callbackInfo.functionname.Equals(systemGetBus) + && callbackInfo.result == FMOD.RESULT.ERR_EVENT_NOTFOUND + && callbackInfo.functionparams.StartsWith(masterBusPrefix)) + { + return FMOD.RESULT.OK; + } + + RuntimeUtils.DebugLogError(string.Format("[FMOD] {0}({1}) returned {2} for {3} (0x{4}).", + (string)callbackInfo.functionname, (string)callbackInfo.functionparams, callbackInfo.result, callbackInfo.instancetype, callbackInfo.instance.ToString("X"))); + return FMOD.RESULT.OK; + } + + private static RuntimeManager Instance + { + get + { + if (initException != null) + { + throw initException; + } + + + if (instance == null) + { + if (!Application.isPlaying) + { + Debug.LogError("[FMOD] RuntimeManager accessed outside of runtime. Do not use RuntimeManager for Editor-only functionality, create your own System objects instead."); + return null; + } + + FMOD.RESULT initResult = FMOD.RESULT.OK; // Initialize can return an error code if it falls back to NO_SOUND, throw it as a non-cached exception + + // When reloading scripts the static instance pointer will be cleared, find the old manager and clean it up + foreach (RuntimeManager manager in Resources.FindObjectsOfTypeAll()) + { + DestroyImmediate(manager.gameObject); + } + + var gameObject = new GameObject("FMOD.UnityIntegration.RuntimeManager"); + instance = gameObject.AddComponent(); + + if (Application.isPlaying) // This class is used in edit mode by the Timeline auditioning system + { + DontDestroyOnLoad(gameObject); + } + gameObject.hideFlags = HideFlags.HideAndDontSave; + + try + { + RuntimeUtils.EnforceLibraryOrder(); + + #if UNITY_ANDROID && !UNITY_EDITOR + // First, obtain the current activity context + AndroidJavaObject activity = null; + using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + { + activity = activityClass.GetStatic("currentActivity"); + } + + using (var fmodJava = new AndroidJavaClass("org.fmod.FMOD")) + { + if (fmodJava != null) + { + fmodJava.CallStatic("init", activity); + } + else + { + RuntimeUtils.DebugLogWarning("[FMOD] Cannot initialize Java wrapper"); + } + } + #endif + + initResult = instance.Initialize(); + } + catch (Exception e) + { + initException = e as SystemNotInitializedException; + if (initException == null) + { + initException = new SystemNotInitializedException(e); + } + throw initException; + } + } + return instance; + } + } + + public static FMOD.Studio.System StudioSystem + { + get { return Instance.studioSystem; } + } + + public static FMOD.System CoreSystem + { + get { return Instance.coreSystem; } + } + + private struct LoadedBank + { + public FMOD.Studio.Bank Bank; + public int RefCount; + } + + // Explicit comparer to avoid issues on platforms that don't support JIT compilation + private class GuidComparer : IEqualityComparer + { + bool IEqualityComparer.Equals(FMOD.GUID x, FMOD.GUID y) + { + return x.Equals(y); + } + + int IEqualityComparer.GetHashCode(FMOD.GUID obj) + { + return obj.GetHashCode(); + } + } + + private void CheckInitResult(FMOD.RESULT result, string cause) + { + if (result != FMOD.RESULT.OK) + { + ReleaseStudioSystem(); + throw new SystemNotInitializedException(result, cause); + } + } + + private void ReleaseStudioSystem() + { + if (studioSystem.isValid()) + { + studioSystem.release(); + studioSystem.clearHandle(); + } + } + + private FMOD.RESULT Initialize() + { + #if UNITY_EDITOR + EditorApplication.playModeStateChanged += HandlePlayModeStateChange; + AppDomain.CurrentDomain.DomainUnload += HandleDomainUnload; + #endif // UNITY_EDITOR + + FMOD.RESULT result = FMOD.RESULT.OK; + FMOD.RESULT initResult = FMOD.RESULT.OK; + Settings fmodSettings = Settings.Instance; + currentPlatform = fmodSettings.FindCurrentPlatform(); + + int sampleRate = currentPlatform.SampleRate; + int realChannels = Math.Min(currentPlatform.RealChannelCount, 256); + int virtualChannels = currentPlatform.VirtualChannelCount; + uint dspBufferLength = (uint)currentPlatform.DSPBufferLength; + int dspBufferCount = currentPlatform.DSPBufferCount; + FMOD.SPEAKERMODE speakerMode = currentPlatform.SpeakerMode; + FMOD.OUTPUTTYPE outputType = currentPlatform.GetOutputType(); + + FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS(); + advancedSettings.randomSeed = (uint)DateTime.UtcNow.Ticks; + advancedSettings.maxAT9Codecs = GetChannelCountForFormat(CodecType.AT9); + advancedSettings.maxFADPCMCodecs = GetChannelCountForFormat(CodecType.FADPCM); + advancedSettings.maxOpusCodecs = GetChannelCountForFormat(CodecType.Opus); + advancedSettings.maxVorbisCodecs = GetChannelCountForFormat(CodecType.Vorbis); + advancedSettings.maxXMACodecs = GetChannelCountForFormat(CodecType.XMA); + + SetThreadAffinities(currentPlatform); + + currentPlatform.PreSystemCreate(CheckInitResult); + + #if UNITY_EDITOR || DEVELOPMENT_BUILD + debugCallback = new FMOD.DEBUG_CALLBACK(DEBUG_CALLBACK); + result = FMOD.Debug.Initialize(fmodSettings.LoggingLevel, FMOD.DEBUG_MODE.CALLBACK, debugCallback, null); + if(result == FMOD.RESULT.ERR_UNSUPPORTED) + { + RuntimeUtils.DebugLogWarning("[FMOD] Unable to initialize debug logging: Logging will be disabled.\nCheck the Import Settings of the FMOD libs to enable the logging library."); + } + else + { + CheckInitResult(result, "FMOD.Debug.Initialize"); + } + #endif + + FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS; + if (currentPlatform.IsLiveUpdateEnabled) + { + studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE; + advancedSettings.profilePort = (ushort)currentPlatform.LiveUpdatePort; + } + +retry: + result = FMOD.Studio.System.create(out studioSystem); + CheckInitResult(result, "FMOD.Studio.System.create"); + + result = studioSystem.getCoreSystem(out coreSystem); + CheckInitResult(result, "FMOD.Studio.System.getCoreSystem"); + + result = coreSystem.setOutput(outputType); + CheckInitResult(result, "FMOD.System.setOutput"); + + result = coreSystem.setSoftwareChannels(realChannels); + CheckInitResult(result, "FMOD.System.setSoftwareChannels"); + + result = coreSystem.setSoftwareFormat(sampleRate, speakerMode, 0); + CheckInitResult(result, "FMOD.System.setSoftwareFormat"); + + if (dspBufferLength > 0 && dspBufferCount > 0) + { + result = coreSystem.setDSPBufferSize(dspBufferLength, dspBufferCount); + CheckInitResult(result, "FMOD.System.setDSPBufferSize"); + } + + result = coreSystem.setAdvancedSettings(ref advancedSettings); + CheckInitResult(result, "FMOD.System.setAdvancedSettings"); + + if (fmodSettings.EnableErrorCallback) + { + errorCallback = new FMOD.SYSTEM_CALLBACK(ERROR_CALLBACK); + result = coreSystem.setCallback(errorCallback, FMOD.SYSTEM_CALLBACK_TYPE.ERROR); + CheckInitResult(result, "FMOD.System.setCallback"); + } + + if (!string.IsNullOrEmpty(fmodSettings.EncryptionKey)) + { + FMOD.Studio.ADVANCEDSETTINGS studioAdvancedSettings = new FMOD.Studio.ADVANCEDSETTINGS(); + result = studioSystem.setAdvancedSettings(studioAdvancedSettings, Settings.Instance.EncryptionKey); + CheckInitResult(result, "FMOD.Studio.System.setAdvancedSettings"); + } + + if (fmodSettings.EnableMemoryTracking) + { + studioInitFlags |= FMOD.Studio.INITFLAGS.MEMORY_TRACKING; + } + + currentPlatform.PreInitialize(studioSystem); + + PlatformCallbackHandler callbackHandler = currentPlatform.CallbackHandler; + + if (callbackHandler != null) + { + callbackHandler.PreInitialize(studioSystem, CheckInitResult); + } + + result = studioSystem.initialize(virtualChannels, studioInitFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); + if (result != FMOD.RESULT.OK && initResult == FMOD.RESULT.OK) + { + initResult = result; // Save this to throw at the end (we'll attempt NO SOUND to shield ourselves from unexpected device failures) + outputType = FMOD.OUTPUTTYPE.NOSOUND; + RuntimeUtils.DebugLogErrorFormat("[FMOD] Studio::System::initialize returned {0}, defaulting to no-sound mode.", result.ToString()); + + goto retry; + } + CheckInitResult(result, "Studio::System::initialize"); + + // Test network functionality triggered during System::update + if ((studioInitFlags & FMOD.Studio.INITFLAGS.LIVEUPDATE) != 0) + { + studioSystem.flushCommands(); // Any error will be returned through Studio.System.update + + result = studioSystem.update(); + if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR) + { + studioInitFlags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE; + RuntimeUtils.DebugLogWarning("[FMOD] Cannot open network port for Live Update (in-use), restarting with Live Update disabled."); + + result = studioSystem.release(); + CheckInitResult(result, "FMOD.Studio.System.Release"); + + goto retry; + } + } + + currentPlatform.LoadPlugins(coreSystem, CheckInitResult); + LoadBanks(fmodSettings); + + #if (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS) && !UNITY_EDITOR + RegisterSuspendCallback(HandleInterrupt); + #endif + + if (currentPlatform.IsOverlayEnabled) + { + SetOverlayPosition(); + } + return initResult; + } + + private int GetChannelCountForFormat(CodecType format) + { + CodecChannelCount channelCount = currentPlatform.CodecChannels.Find(x => x.format == format); + + return channelCount == null ? 0 : Math.Min(channelCount.channels, 256); + } + + private static void SetThreadAffinities(Platform platform) + { + foreach (ThreadAffinityGroup group in platform.ThreadAffinities) + { + foreach (ThreadType thread in group.threads) + { + FMOD.THREAD_TYPE fmodThread = RuntimeUtils.ToFMODThreadType(thread); + FMOD.THREAD_AFFINITY fmodAffinity = RuntimeUtils.ToFMODThreadAffinity(group.affinity); + + FMOD.Thread.SetAttributes(fmodThread, fmodAffinity); + } + } + } + + private class AttachedInstance + { + public FMOD.Studio.EventInstance instance; + public Transform transform; + #if UNITY_PHYSICS_EXIST + public Rigidbody rigidBody; + #endif + public Vector3 lastFramePosition; + public bool allowNonRigidBodyDoppler; + #if UNITY_PHYSICS2D_EXIST + public Rigidbody2D rigidBody2D; + #endif + } + + private void Update() + { + if (studioSystem.isValid()) + { + if (StudioListener.ListenerCount <= 0 && !listenerWarningIssued) + { + listenerWarningIssued = true; + RuntimeUtils.DebugLogWarning("[FMOD] Please add an 'FMOD Studio Listener' component to your camera in the scene for correct 3D positioning of sounds."); + } + + StudioEventEmitter.UpdateActiveEmitters(); + + for (int i = 0; i < attachedInstances.Count; i++) + { + FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; + if (attachedInstances[i].instance.isValid()) + { + attachedInstances[i].instance.getPlaybackState(out playbackState); + } + + if (playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || + attachedInstances[i].transform == null // destroyed game object + ) + { + attachedInstances[i] = attachedInstances[attachedInstances.Count - 1]; + attachedInstances.RemoveAt(attachedInstances.Count - 1); + i--; + continue; + } + + #if UNITY_PHYSICS_EXIST + if (attachedInstances[i].rigidBody) + { + attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); + } + else + #endif + #if UNITY_PHYSICS2D_EXIST + if (attachedInstances[i].rigidBody2D) + { + attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody2D)); + } + else + #endif + { + if (!attachedInstances[i].allowNonRigidBodyDoppler) + { + attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform)); + } + else + { + var position = attachedInstances[i].transform.position; + var velocity = Vector3.zero; + if (Time.deltaTime != 0) + { + velocity = (position - attachedInstances[i].lastFramePosition) / Time.deltaTime; + velocity = Vector3.ClampMagnitude(velocity, 20.0f); // Stops pitch fluttering when moving too quickly + } + attachedInstances[i].lastFramePosition = position; + attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, velocity)); + } + } + } + + #if UNITY_EDITOR + ApplyMuteState(); + + for (int i = eventPositionWarnings.Count - 1; i >= 0; i--) + { + if (eventPositionWarnings[i].isValid()) + { + FMOD.ATTRIBUTES_3D attribs; + eventPositionWarnings[i].get3DAttributes(out attribs); + if (attribs.position.x == 1e+18F && + attribs.position.y == 1e+18F && + attribs.position.z == 1e+18F) + { + string path; + FMOD.Studio.EventDescription desc; + eventPositionWarnings[i].getDescription(out desc); + desc.getPath(out path); + RuntimeUtils.DebugLogWarningFormat("[FMOD] Instance of Event {0} has not had EventInstance.set3DAttributes() called on it yet!", path); + } + } + eventPositionWarnings.RemoveAt(i); + } + + isOverlayEnabled = currentPlatform.IsOverlayEnabled; + #endif + + if (isOverlayEnabled) + { + if (!overlayDrawer) + { + overlayDrawer = Instance.gameObject.AddComponent(); + overlayDrawer.TargetRuntimeManager = this; + } + else + { + overlayDrawer.gameObject.SetActive(true); + } + } + else + { + if (overlayDrawer != null && overlayDrawer.gameObject.activeSelf) + { + overlayDrawer.gameObject.SetActive(false); + } + } + + studioSystem.update(); + } + } + + private static AttachedInstance FindOrAddAttachedInstance(FMOD.Studio.EventInstance instance, Transform transform, FMOD.ATTRIBUTES_3D attributes) + { + AttachedInstance attachedInstance = Instance.attachedInstances.Find(x => x.instance.handle == instance.handle); + if (attachedInstance == null) + { + attachedInstance = new AttachedInstance(); + Instance.attachedInstances.Add(attachedInstance); + } + attachedInstance.instance = instance; + attachedInstance.transform = transform; + attachedInstance.instance.set3DAttributes(attributes); + return attachedInstance; + } + + public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, bool allowNonRigidBodyDoppler = false) + { + AttachedInstance attachedInstance = FindOrAddAttachedInstance(instance, transform, RuntimeUtils.To3DAttributes(transform)); + + if (allowNonRigidBodyDoppler) + { + attachedInstance.allowNonRigidBodyDoppler = allowNonRigidBodyDoppler; + attachedInstance.lastFramePosition = transform.position; + } + } + +#if UNITY_PHYSICS_EXIST + public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, Rigidbody rigidBody) + { + AttachedInstance attachedInstance = FindOrAddAttachedInstance(instance, transform, RuntimeUtils.To3DAttributes(transform, rigidBody)); + + attachedInstance.rigidBody = rigidBody; + } +#endif + +#if UNITY_PHYSICS2D_EXIST + public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, Rigidbody2D rigidBody2D) + { + AttachedInstance attachedInstance = FindOrAddAttachedInstance(instance, transform, RuntimeUtils.To3DAttributes(transform, rigidBody2D)); + + attachedInstance.rigidBody2D = rigidBody2D; + } +#endif + + public static void DetachInstanceFromGameObject(FMOD.Studio.EventInstance instance) + { + var manager = Instance; + for (int i = 0; i < manager.attachedInstances.Count; i++) + { + if (manager.attachedInstances[i].instance.handle == instance.handle) + { + manager.attachedInstances[i] = manager.attachedInstances[manager.attachedInstances.Count - 1]; + manager.attachedInstances.RemoveAt(manager.attachedInstances.Count - 1); + return; + } + } + } + + internal void ExecuteOnGUI() + { + if (currentPlatform.OverlayRect != ScreenPosition.VR) + { + GUIStyle debugStyle = GUI.skin.GetStyle("window"); + debugStyle.fontSize = currentPlatform.OverlayFontSize; + if (studioSystem.isValid() && isOverlayEnabled) + { + windowRect = GUI.Window(GetInstanceID(), windowRect, DrawDebugOverlay, "FMOD Studio Debug", debugStyle); + } + } + else + { +#if UNITY_URP_EXIST + if (vrDebugOverlay != null && vrDebugText != null) + { + UpdateDebugText(); + vrDebugText.text = lastDebugText; + } +#endif + } + } + +#if !UNITY_EDITOR + private void Start() + { + isOverlayEnabled = currentPlatform.IsOverlayEnabled; + } +#endif + + private void UpdateDebugText() + { + if (lastDebugUpdate + 0.25f < Time.unscaledTime) + { + if (initException != null) + { + lastDebugText = initException.Message; + } + else + { + if (!mixerHead.hasHandle()) + { + FMOD.ChannelGroup master; + coreSystem.getMasterChannelGroup(out master); + master.getDSP(0, out mixerHead); + mixerHead.setMeteringEnabled(false, true); + } + + StringBuilder debug = new StringBuilder(); + + FMOD.Studio.CPU_USAGE cpuUsage; + FMOD.CPU_USAGE cpuUsage_core; + studioSystem.getCPUUsage(out cpuUsage, out cpuUsage_core); + debug.AppendFormat("CPU: dsp = {0:F1}%, studio = {1:F1}%\n", cpuUsage_core.dsp, cpuUsage.update); + + int currentAlloc, maxAlloc; + FMOD.Memory.GetStats(out currentAlloc, out maxAlloc); + debug.AppendFormat("MEMORY: cur = {0}MB, max = {1}MB\n", currentAlloc >> 20, maxAlloc >> 20); + + int realchannels, channels; + coreSystem.getChannelsPlaying(out channels, out realchannels); + debug.AppendFormat("CHANNELS: real = {0}, total = {1}\n", realchannels, channels); + + FMOD.DSP_METERING_INFO outputMetering; + mixerHead.getMeteringInfo(IntPtr.Zero, out outputMetering); + float rms = 0; + for (int i = 0; i < outputMetering.numchannels; i++) + { + rms += outputMetering.rmslevel[i] * outputMetering.rmslevel[i]; + } + rms = Mathf.Sqrt(rms / (float)outputMetering.numchannels); + + float db = rms > 0 ? 20.0f * Mathf.Log10(rms * Mathf.Sqrt(2.0f)) : -80.0f; + if (db > 10.0f) db = 10.0f; + + debug.AppendFormat("VOLUME: RMS = {0:f2}db\n", db); + lastDebugText = debug.ToString(); + lastDebugUpdate = Time.unscaledTime; + } + } + } + + private void DrawDebugOverlay(int windowID) + { + UpdateDebugText(); + + GUIStyle debugStyle = GUI.skin.GetStyle("label"); + + debugStyle.fontSize = currentPlatform.OverlayFontSize; + float width = currentPlatform.OverlayFontSize * 20; + float height = currentPlatform.OverlayFontSize * 7; + GUI.Label(new Rect(30, 20, width, height), lastDebugText, debugStyle); + GUI.DragWindow(); + } + + private void OnDestroy() + { + coreSystem.setCallback(null, 0); + ReleaseStudioSystem(); + + initException = null; + instance = null; + +#if UNITY_EDITOR + AppDomain.CurrentDomain.DomainUnload -= HandleDomainUnload; + EditorApplication.playModeStateChanged -= HandlePlayModeStateChange; +#endif + } + +#if UNITY_EDITOR + private static void Destroy() + { + if (instance) + { + DestroyImmediate(instance.gameObject); + } + } + + private void HandleDomainUnload(object sender, EventArgs args) + { + ReleaseStudioSystem(); + } + + private void HandlePlayModeStateChange(PlayModeStateChange state) + { + if (state == PlayModeStateChange.ExitingEditMode || state == PlayModeStateChange.EnteredEditMode) + { + if (state == PlayModeStateChange.ExitingEditMode && EditorSettings.enterPlayModeOptionsEnabled && + (EditorSettings.enterPlayModeOptions | EnterPlayModeOptions.DisableDomainReload) != 0) + { + OnDestroy(); // When domain reload is disabled, OnDestroy is not called when entering play mode, breaking live update. + } + Destroy(); + } + } +#endif + + #if (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS) && !UNITY_EDITOR + [AOT.MonoPInvokeCallback(typeof(Action))] + private static void HandleInterrupt(bool began) + { + if (Instance.studioSystem.isValid()) + { + // Strings bank is always loaded + if (Instance.loadedBanks.Count > 1) + PauseAllEvents(began); + + if (began) + { + Instance.coreSystem.mixerSuspend(); + } + else + { + Instance.coreSystem.mixerResume(); + } + } + } + #else + private void OnApplicationPause(bool pauseStatus) + { + if (studioSystem.isValid()) + { + PauseAllEvents(pauseStatus); + + if (pauseStatus) + { + coreSystem.mixerSuspend(); + } + else + { + coreSystem.mixerResume(); + } + } + } + #endif + + private static void ReferenceLoadedBank(string bankName, bool loadSamples) + { + LoadedBank loadedBank = Instance.loadedBanks[bankName]; + loadedBank.RefCount++; + + if (loadSamples) + { + loadedBank.Bank.loadSampleData(); + } + + Instance.loadedBanks[bankName] = loadedBank; // Save the incremented reference count + } + + private void RegisterLoadedBank(LoadedBank loadedBank, string bankPath, string bankName, bool loadSamples, FMOD.RESULT loadResult) + { + if (loadResult == FMOD.RESULT.OK) + { + loadedBank.RefCount = 1; + + if (loadSamples) + { + loadedBank.Bank.loadSampleData(); + } + + Instance.loadedBanks.Add(bankName, loadedBank); + } + else if (loadResult == FMOD.RESULT.ERR_EVENT_ALREADY_LOADED) + { + RuntimeUtils.DebugLogWarningFormat("[FMOD] Unable to load {0} - bank already loaded. This may occur when attempting to load another localized bank before the first is unloaded, or if a bank has been loaded via the API.", bankName); + } + else + { + throw new BankLoadException(bankPath, loadResult); + } + + ExecuteSampleLoadRequestsIfReady(); + } + + private void ExecuteSampleLoadRequestsIfReady() + { + if (sampleLoadRequests.Count > 0) + { + foreach (string bankName in sampleLoadRequests) + { + if (!loadedBanks.ContainsKey(bankName)) + { + // Not ready + return; + } + } + + // All requested banks are loaded, so we can now load sample data + foreach (string bankName in sampleLoadRequests) + { + LoadedBank loadedBank = loadedBanks[bankName]; + CheckInitResult(loadedBank.Bank.loadSampleData(), + string.Format("Loading sample data for bank: {0}", bankName)); + } + + sampleLoadRequests.Clear(); + } + } + +#if UNITY_ANDROID || UNITY_WEBGL + private IEnumerator loadFromWeb(string bankPath, string bankName, bool loadSamples) + { + byte[] loadWebResult; + FMOD.RESULT loadResult; + + UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(bankPath); + yield return www.SendWebRequest(); + loadWebResult = www.downloadHandler.data; + + LoadedBank loadedBank = new LoadedBank(); + loadResult = Instance.studioSystem.loadBankMemory(loadWebResult, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank.Bank); + if (loadResult != FMOD.RESULT.OK) + { + RuntimeUtils.DebugLogWarningFormat("[FMOD] loadFromWeb. Path = {0}, result = {1}.", bankPath, loadResult); + } + RegisterLoadedBank(loadedBank, bankPath, bankName, loadSamples, loadResult); + loadingBanksRef--; + + RuntimeUtils.DebugLogFormat("[FMOD] Finished loading {0}", bankPath); + } +#endif // UNITY_ANDROID || UNITY_WEBGL + + public static void LoadBank(string bankName, bool loadSamples = false) + { + LoadBank(bankName, loadSamples, bankName); + } + + private static void LoadBank(string bankName, bool loadSamples, string bankId) + { + if (Instance.loadedBanks.ContainsKey(bankId)) + { + ReferenceLoadedBank(bankId, loadSamples); + } + else + { + string bankFolder = Instance.currentPlatform.GetBankFolder(); + +#if !UNITY_EDITOR + if (!string.IsNullOrEmpty(Settings.Instance.TargetSubFolder)) + { + bankFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(bankFolder, Settings.Instance.TargetSubFolder)); + } +#endif + + const string BankExtension = ".bank"; + + string bankPath; + + if (System.IO.Path.GetExtension(bankName) != BankExtension) + { + bankPath = string.Format("{0}/{1}{2}", bankFolder, bankName, BankExtension); + } + else + { + bankPath = string.Format("{0}/{1}", bankFolder, bankName); + } + Instance.loadingBanksRef++; +#if UNITY_ANDROID && !UNITY_EDITOR + if (Settings.Instance.AndroidUseOBB) + { + Instance.StartCoroutine(Instance.loadFromWeb(bankPath, bankName, loadSamples)); + } + else +#elif UNITY_WEBGL && !UNITY_EDITOR + if (true) + { + Instance.StartCoroutine(Instance.loadFromWeb(bankPath, bankName, loadSamples)); + } + else +#endif // (UNITY_ANDROID || UNITY_WEBGL) && !UNITY_EDITOR + { + LoadedBank loadedBank = new LoadedBank(); + FMOD.RESULT loadResult = Instance.studioSystem.loadBankFile(bankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank.Bank); + Instance.RegisterLoadedBank(loadedBank, bankPath, bankId, loadSamples, loadResult); + Instance.loadingBanksRef--; + } + } + + } + + public static void LoadBank(TextAsset asset, bool loadSamples = false) + { + LoadBank(asset, loadSamples, asset.name); + } + + private static void LoadBank(TextAsset asset, bool loadSamples, string bankId) + { + if (Instance.loadedBanks.ContainsKey(bankId)) + { + ReferenceLoadedBank(bankId, loadSamples); + } + else + { +#if UNITY_EDITOR + if (asset.text.StartsWith(BankStubPrefix)) + { + string name = asset.text.Substring(BankStubPrefix.Length); + LoadBank(name, loadSamples, bankId); + return; + } +#endif + + LoadedBank loadedBank = new LoadedBank(); + FMOD.RESULT loadResult = Instance.studioSystem.loadBankMemory(asset.bytes, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank.Bank); + Instance.RegisterLoadedBank(loadedBank, bankId, bankId, loadSamples, loadResult); + } + } + +#if UNITY_ADDRESSABLES_EXIST + public static void LoadBank(AssetReference assetReference, bool loadSamples = false, System.Action completionCallback = null) + { + if (Instance.loadedBanks.ContainsKey(assetReference.AssetGUID)) + { + ReferenceLoadedBank(assetReference.AssetGUID, loadSamples); + } + else + { + Instance.loadingBanksRef++; + assetReference.LoadAssetAsync().Completed += (obj) => + { + if (!obj.IsValid()) + { + RuntimeUtils.DebugLogError("[FMOD] Unable to load AssetReference: " + obj.OperationException); + return; + } + + TextAsset bank = obj.Result; + LoadBank(bank, loadSamples, assetReference.AssetGUID); + + Instance.loadingBanksRef--; + + if (completionCallback != null) + { + completionCallback(); + } + + assetReference.ReleaseAsset(); + }; + + } + } +#endif + + private void LoadBanks(Settings fmodSettings) + { + if (fmodSettings.ImportType == ImportType.StreamingAssets) + { + if (fmodSettings.AutomaticSampleLoading) + { + sampleLoadRequests.AddRange(BanksToLoad(fmodSettings)); + } + + try + { + foreach (string bankName in BanksToLoad(fmodSettings)) + { + LoadBank(bankName); + } + + WaitForAllSampleLoading(); + } + catch (BankLoadException e) + { + RuntimeUtils.DebugLogException(e); + } + } + } + + private IEnumerable BanksToLoad(Settings fmodSettings) + { + switch (fmodSettings.BankLoadType) + { + case BankLoadType.All: + foreach (string masterBankFileName in fmodSettings.MasterBanks) + { + yield return masterBankFileName + ".strings"; + yield return masterBankFileName; + } + + foreach (var bank in fmodSettings.Banks) + { + yield return bank; + } + break; + case BankLoadType.Specified: + foreach (var bank in fmodSettings.BanksToLoad) + { + if (!string.IsNullOrEmpty(bank)) + { + yield return bank; + } + } + break; + case BankLoadType.None: + break; + default: + break; + } + } + + public static void UnloadBank(string bankName) + { + LoadedBank loadedBank; + if (Instance.loadedBanks.TryGetValue(bankName, out loadedBank)) + { + loadedBank.RefCount--; + if (loadedBank.RefCount == 0) + { + loadedBank.Bank.unload(); + Instance.loadedBanks.Remove(bankName); + Instance.sampleLoadRequests.Remove(bankName); + return; + } + Instance.loadedBanks[bankName] = loadedBank; + } + } + + public static void UnloadBank(TextAsset asset) + { + UnloadBank(asset.name); + } + +#if UNITY_ADDRESSABLES_EXIST + public static void UnloadBank(AssetReference assetReference) + { + UnloadBank(assetReference.AssetGUID); + } +#endif + + [Obsolete("[FMOD] Deprecated. Use AnySampleDataLoading instead.")] + public static bool AnyBankLoading() + { + return AnySampleDataLoading(); + } + + public static bool AnySampleDataLoading() + { + bool loading = false; + foreach (LoadedBank bank in Instance.loadedBanks.Values) + { + FMOD.Studio.LOADING_STATE loadingState; + bank.Bank.getSampleLoadingState(out loadingState); + loading |= (loadingState == FMOD.Studio.LOADING_STATE.LOADING); + } + return loading; + } + + [Obsolete("[FMOD] Deprecated. Use WaitForAllSampleLoading instead.")] + public static void WaitForAllLoads() + { + WaitForAllSampleLoading(); + } + + public static void WaitForAllSampleLoading() + { + Instance.studioSystem.flushSampleLoading(); + } + + public static FMOD.GUID PathToGUID(string path) + { + FMOD.GUID guid; + if (path.StartsWith("{")) + { + FMOD.Studio.Util.parseID(path, out guid); + } + else + { + var result = Instance.studioSystem.lookupID(path, out guid); + if (result == FMOD.RESULT.ERR_EVENT_NOTFOUND) + { + throw new EventNotFoundException(path); + } + } + return guid; + } + + public static EventReference PathToEventReference(string path) + { + FMOD.GUID guid; + + try + { + guid = PathToGUID(path); + } + catch (EventNotFoundException) + { + guid = new FMOD.GUID(); + } + +#if UNITY_EDITOR + return new EventReference() { Path = path, Guid = guid }; +#else + return new EventReference() { Guid = guid }; +#endif + } + + public static FMOD.Studio.EventInstance CreateInstance(EventReference eventReference) + { + try + { + return CreateInstance(eventReference.Guid); + } + catch (EventNotFoundException) + { + throw new EventNotFoundException(eventReference); + } + } + + public static FMOD.Studio.EventInstance CreateInstance(string path) + { + try + { + return CreateInstance(PathToGUID(path)); + } + catch(EventNotFoundException) + { + // Switch from exception with GUID to exception with path + throw new EventNotFoundException(path); + } + } + + public static FMOD.Studio.EventInstance CreateInstance(FMOD.GUID guid) + { + FMOD.Studio.EventDescription eventDesc = GetEventDescription(guid); + FMOD.Studio.EventInstance newInstance; + eventDesc.createInstance(out newInstance); + + #if UNITY_EDITOR + bool is3D = false; + eventDesc.is3D(out is3D); + if (is3D) + { + // Set position to 1e+18F, set3DAttributes should be called by the dev after this. + newInstance.set3DAttributes(RuntimeUtils.To3DAttributes(new Vector3(1e+18F, 1e+18F, 1e+18F))); + instance.eventPositionWarnings.Add(newInstance); + } + #endif + + return newInstance; + } + + public static void PlayOneShot(EventReference eventReference, Vector3 position = new Vector3()) + { + try + { + PlayOneShot(eventReference.Guid, position); + } + catch (EventNotFoundException) + { + RuntimeUtils.DebugLogWarning("[FMOD] Event not found: " + eventReference); + } + } + + public static void PlayOneShot(string path, Vector3 position = new Vector3()) + { + try + { + PlayOneShot(PathToGUID(path), position); + } + catch (EventNotFoundException) + { + RuntimeUtils.DebugLogWarning("[FMOD] Event not found: " + path); + } + } + + public static void PlayOneShot(FMOD.GUID guid, Vector3 position = new Vector3()) + { + var instance = CreateInstance(guid); + instance.set3DAttributes(RuntimeUtils.To3DAttributes(position)); + instance.start(); + instance.release(); + } + + public static void PlayOneShotAttached(EventReference eventReference, GameObject gameObject) + { + try + { + PlayOneShotAttached(eventReference.Guid, gameObject); + } + catch (EventNotFoundException) + { + RuntimeUtils.DebugLogWarning("[FMOD] Event not found: " + eventReference); + } + } + + public static void PlayOneShotAttached(string path, GameObject gameObject) + { + try + { + PlayOneShotAttached(PathToGUID(path), gameObject); + } + catch (EventNotFoundException) + { + RuntimeUtils.DebugLogWarning("[FMOD] Event not found: " + path); + } + } + + public static void PlayOneShotAttached(FMOD.GUID guid, GameObject gameObject) + { + var instance = CreateInstance(guid); + #if UNITY_PHYSICS_EXIST + AttachInstanceToGameObject(instance, gameObject.transform, gameObject.GetComponent()); + #elif UNITY_PHYSICS2D_EXIST + AttachInstanceToGameObject(instance, gameObject.transform, gameObject.GetComponent()); + #else + AttachInstanceToGameObject(instance, gameObject.transform); + #endif + instance.start(); + instance.release(); + } + + public static FMOD.Studio.EventDescription GetEventDescription(EventReference eventReference) + { + try + { + return GetEventDescription(eventReference.Guid); + } + catch (EventNotFoundException) + { + throw new EventNotFoundException(eventReference); + } + } + + public static FMOD.Studio.EventDescription GetEventDescription(string path) + { + try + { + return GetEventDescription(PathToGUID(path)); + } + catch (EventNotFoundException) + { + throw new EventNotFoundException(path); + } + } + + public static FMOD.Studio.EventDescription GetEventDescription(FMOD.GUID guid) + { + FMOD.Studio.EventDescription eventDesc; + if (Instance.cachedDescriptions.ContainsKey(guid) && Instance.cachedDescriptions[guid].isValid()) + { + eventDesc = Instance.cachedDescriptions[guid]; + } + else + { + var result = Instance.studioSystem.getEventByID(guid, out eventDesc); + + if (result != FMOD.RESULT.OK) + { + throw new EventNotFoundException(guid); + } + + if (eventDesc.isValid()) + { + Instance.cachedDescriptions[guid] = eventDesc; + } + } + return eventDesc; + } + +#if UNITY_PHYSICS_EXIST + public static void SetListenerLocation(GameObject gameObject, Rigidbody rigidBody, GameObject attenuationObject = null) + { + SetListenerLocation(0, gameObject, rigidBody, attenuationObject); + } + + public static void SetListenerLocation(int listenerIndex, GameObject gameObject, Rigidbody rigidBody, GameObject attenuationObject = null) + { + if(attenuationObject) + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform, rigidBody), RuntimeUtils.ToFMODVector(attenuationObject.transform.position)); + } + else + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform, rigidBody)); + } + } +#endif + +#if UNITY_PHYSICS2D_EXIST + public static void SetListenerLocation(GameObject gameObject, Rigidbody2D rigidBody2D, GameObject attenuationObject = null) + { + SetListenerLocation(0, gameObject, rigidBody2D, attenuationObject); + } + + public static void SetListenerLocation(int listenerIndex, GameObject gameObject, Rigidbody2D rigidBody2D, GameObject attenuationObject = null) + { + if (attenuationObject) + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform, rigidBody2D), RuntimeUtils.ToFMODVector(attenuationObject.transform.position)); + } + else + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform, rigidBody2D)); + } + } +#endif + + public static void SetListenerLocation(GameObject gameObject, GameObject attenuationObject = null) + { + SetListenerLocation(0, gameObject, attenuationObject); + } + + public static void SetListenerLocation(int listenerIndex, GameObject gameObject, GameObject attenuationObject = null) + { + if (attenuationObject) + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform), RuntimeUtils.ToFMODVector(attenuationObject.transform.position)); + } + else + { + Instance.studioSystem.setListenerAttributes(listenerIndex, RuntimeUtils.To3DAttributes(gameObject.transform)); + } + } + + public static FMOD.Studio.Bus GetBus(string path) + { + FMOD.Studio.Bus bus; + if (StudioSystem.getBus(path, out bus) != FMOD.RESULT.OK) + { + throw new BusNotFoundException(path); + } + return bus; + } + + public static FMOD.Studio.VCA GetVCA(string path) + { + FMOD.Studio.VCA vca; + if (StudioSystem.getVCA(path, out vca) != FMOD.RESULT.OK) + { + throw new VCANotFoundException(path); + } + return vca; + } + + public static void PauseAllEvents(bool paused) + { + FMOD.Studio.Bus masterBus; + if (StudioSystem.getBus("bus:/", out masterBus) == FMOD.RESULT.OK) + { + masterBus.setPaused(paused); + } + } + + public static void MuteAllEvents(bool muted) + { + Instance.isMuted = muted; + + ApplyMuteState(); + } + + private static void ApplyMuteState() + { + FMOD.Studio.Bus masterBus; + if (StudioSystem.getBus("bus:/", out masterBus) == FMOD.RESULT.OK) + { +#if UNITY_EDITOR + masterBus.setMute(Instance.isMuted || EditorUtility.audioMasterMute); +#else + masterBus.setMute(Instance.isMuted); +#endif + } + } + + public static bool IsInitialized + { + get + { + return instance != null && instance.studioSystem.isValid(); + } + } + + public static bool HaveAllBanksLoaded + { + get + { + return Instance.loadingBanksRef == 0; + } + } + + public static bool HaveMasterBanksLoaded + { + get + { + var banks = Settings.Instance.MasterBanks; + foreach(var bank in banks) + { + if (!HasBankLoaded(bank)) return false; + } + return true; + } + } + + public static bool HasBankLoaded(string loadedBank) + { + return (Instance.loadedBanks.ContainsKey(loadedBank)); + } + +#if (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS) && !UNITY_EDITOR + [DllImport("__Internal")] + private static extern void RegisterSuspendCallback(Action func); +#endif + + private void SetOverlayPosition() + { + float width = currentPlatform.OverlayFontSize * 20; + float height = currentPlatform.OverlayFontSize * 7; + float margin = 30; + + switch (currentPlatform.OverlayRect) + { + case ScreenPosition.TopLeft: + windowRect = new Rect(margin, margin, width, height); + break; + case ScreenPosition.TopCenter: + windowRect = new Rect((Screen.width / 2) - (width / 2), margin, width, height); + break; + case ScreenPosition.TopRight: + windowRect = new Rect(Screen.width - (width + margin), margin, width, height); + break; + case ScreenPosition.BottomLeft: + windowRect = new Rect(margin, Screen.height - (height + margin), width, height); + break; + case ScreenPosition.BottomCenter: + windowRect = new Rect((Screen.width / 2) - (width / 2), Screen.height - (height + margin), width, height); + break; + case ScreenPosition.BottomRight: + windowRect = new Rect(Screen.width - (width + margin), Screen.height - (height + margin), width, height); + break; + case ScreenPosition.Center: + windowRect = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height / 2), width, height); + break; + case ScreenPosition.VR: +#if UNITY_URP_EXIST + int fmodOverlayLayer = LayerMask.NameToLayer("fmodOverlayLayer"); + UniversalAdditionalCameraData mainCameraData = Camera.main.GetComponent(); + if (fmodOverlayLayer != -1 && mainCameraData != null) + { + vrDebugCamera = Instantiate(Camera.main, Camera.main.transform); + vrDebugCamera.name = "FMOD: UI Camera"; + vrDebugCamera.transform.DetachChildren(); + vrDebugCamera.cullingMask = (1 << fmodOverlayLayer); + Camera.main.cullingMask &= ~(1 << fmodOverlayLayer); + vrDebugCamera.GetComponent().renderType = CameraRenderType.Overlay; + mainCameraData.cameraStack.Add(vrDebugCamera); + vrDebugOverlay = new GameObject(); + vrDebugOverlay.layer = fmodOverlayLayer; + vrDebugOverlay.transform.position = Vector3.zero; + vrDebugOverlay.name = "FMOD: VRDebugOverlay"; + Canvas canvas = vrDebugOverlay.AddComponent(); + vrDebugRectTransform = vrDebugOverlay.GetComponent(); + vrDebugRectTransform.position = new Vector3(0, 0, 500); + vrDebugRectTransform.sizeDelta = new Vector2(300, 100); + vrDebugRectTransform.localScale = new Vector3(-1, 1, 1); + vrDebugText = vrDebugOverlay.AddComponent(); + canvas.renderMode = RenderMode.WorldSpace; + canvas.worldCamera = vrDebugCamera; + vrDebugText.color = Color.black; +#if UNITY_2022_1_OR_NEWER + vrDebugText.font = Resources.GetBuiltinResource(typeof(Font), "LegacyRuntime.ttf") as Font; +#else + vrDebugText.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; +#endif + Quaternion rot = vrDebugCamera.transform.rotation; + rot.z = 0; + Vector3 pos = vrDebugCamera.transform.position + (rot * Vector3.forward * 500); + pos.y = 0; + vrDebugRectTransform.transform.position = pos; + vrDebugRectTransform.transform.LookAt(vrDebugCamera.transform.position); + canvas.transform.SetParent(vrDebugCamera.transform); + } + else + { + if (fmodOverlayLayer == -1) + { + RuntimeUtils.DebugLogWarning("[FMOD] Missing 'fmodOverlayLayer' layer, Cannot display Debug Overlay"); + } + else if (mainCameraData == null) + { + RuntimeUtils.DebugLogWarning("[FMOD] Universal Render Pipeline Required, Cannot display Debug Overlay"); + } + else + { + RuntimeUtils.DebugLogWarning("[FMOD] Unknown Debug Overlay issue. Contact Support"); + } + } + break; +#else + RuntimeUtils.DebugLogWarning("[FMOD] UNITY_URP_EXIST is not defined. The VR debug overlay requires the Universal Render Pipeline."); + break; +#endif + default: + windowRect = new Rect(margin, margin, width, height); + break; + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/RuntimeManager.cs.meta b/Assets/Plugins/FMOD/src/RuntimeManager.cs.meta new file mode 100644 index 0000000..066d7c6 --- /dev/null +++ b/Assets/Plugins/FMOD/src/RuntimeManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5e5fb8ce07f0ce84b9d1852869527ea5 +timeCreated: 1444628977 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 100 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/RuntimeUtils.cs b/Assets/Plugins/FMOD/src/RuntimeUtils.cs new file mode 100644 index 0000000..5266c4d --- /dev/null +++ b/Assets/Plugins/FMOD/src/RuntimeUtils.cs @@ -0,0 +1,614 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace FMOD +{ + [Serializable] + public partial struct GUID : IEquatable + { + public GUID(Guid guid) + { + byte[] bytes = guid.ToByteArray(); + + Data1 = BitConverter.ToInt32(bytes, 0); + Data2 = BitConverter.ToInt32(bytes, 4); + Data3 = BitConverter.ToInt32(bytes, 8); + Data4 = BitConverter.ToInt32(bytes, 12); + } + + public static GUID Parse(string s) + { + return new GUID(new Guid(s)); + } + + public bool IsNull + { + get + { + return Data1 == 0 + && Data2 == 0 + && Data3 == 0 + && Data4 == 0; + } + } + + public override bool Equals(object other) + { + return (other is GUID) && Equals((GUID)other); + } + + public bool Equals(GUID other) + { + return Data1 == other.Data1 + && Data2 == other.Data2 + && Data3 == other.Data3 + && Data4 == other.Data4; + } + + public static bool operator==(GUID a, GUID b) + { + return a.Equals(b); + } + + public static bool operator!=(GUID a, GUID b) + { + return !a.Equals(b); + } + + public override int GetHashCode() + { + return Data1 ^ Data2 ^ Data3 ^ Data4; + } + + public static implicit operator Guid(GUID guid) + { + return new Guid(guid.Data1, + (short) ((guid.Data2 >> 0) & 0xFFFF), + (short) ((guid.Data2 >> 16) & 0xFFFF), + (byte) ((guid.Data3 >> 0) & 0xFF), + (byte) ((guid.Data3 >> 8) & 0xFF), + (byte) ((guid.Data3 >> 16) & 0xFF), + (byte) ((guid.Data3 >> 24) & 0xFF), + (byte) ((guid.Data4 >> 0) & 0xFF), + (byte) ((guid.Data4 >> 8) & 0xFF), + (byte) ((guid.Data4 >> 16) & 0xFF), + (byte) ((guid.Data4 >> 24) & 0xFF) + ); + } + + public override string ToString() + { + return ((Guid)this).ToString("B"); + } + } +} + +namespace FMODUnity +{ + public class EventNotFoundException : Exception + { + public FMOD.GUID Guid; + public string Path; + + public EventNotFoundException(string path) + : base("[FMOD] Event not found: '" + path + "'") + { + Path = path; + } + + public EventNotFoundException(FMOD.GUID guid) + : base("[FMOD] Event not found: " + guid) + { + Guid = guid; + } + + public EventNotFoundException(EventReference eventReference) + : base("[FMOD] Event not found: " + eventReference.ToString()) + { + Guid = eventReference.Guid; + +#if UNITY_EDITOR + Path = eventReference.Path; +#endif + } + } + + public class BusNotFoundException : Exception + { + public string Path; + + public BusNotFoundException(string path) + : base("[FMOD] Bus not found '" + path + "'") + { + Path = path; + } + } + + public class VCANotFoundException : Exception + { + public string Path; + + public VCANotFoundException(string path) + : base("[FMOD] VCA not found '" + path + "'") + { + Path = path; + } + } + + public class BankLoadException : Exception + { + public string Path; + public FMOD.RESULT Result; + + public BankLoadException(string path, FMOD.RESULT result) + : base(string.Format("[FMOD] Could not load bank '{0}' : {1} : {2}", path, result.ToString(), FMOD.Error.String(result))) + { + Path = path; + Result = result; + } + public BankLoadException(string path, string error) + : base(string.Format("[FMOD] Could not load bank '{0}' : {1}", path, error)) + { + Path = path; + Result = FMOD.RESULT.ERR_INTERNAL; + } + } + + public class SystemNotInitializedException : Exception + { + public FMOD.RESULT Result; + public string Location; + + public SystemNotInitializedException(FMOD.RESULT result, string location) + : base(string.Format("[FMOD] Initialization failed : {2} : {0} : {1}", result.ToString(), FMOD.Error.String(result), location)) + { + Result = result; + Location = location; + } + + public SystemNotInitializedException(Exception inner) + : base("[FMOD] Initialization failed", inner) + { + } + } + + public enum EmitterGameEvent : int + { + None, + ObjectStart, + ObjectDestroy, + TriggerEnter, + TriggerExit, + TriggerEnter2D, + TriggerExit2D, + CollisionEnter, + CollisionExit, + CollisionEnter2D, + CollisionExit2D, + ObjectEnable, + ObjectDisable, + ObjectMouseEnter, + ObjectMouseExit, + ObjectMouseDown, + ObjectMouseUp, + UIMouseEnter, + UIMouseExit, + UIMouseDown, + UIMouseUp, + } + + public enum LoaderGameEvent : int + { + None, + ObjectStart, + ObjectDestroy, + TriggerEnter, + TriggerExit, + TriggerEnter2D, + TriggerExit2D, + ObjectEnable, + ObjectDisable, + } + + // We use our own enum to avoid serialization issues if FMOD.THREAD_TYPE changes + public enum ThreadType + { + Mixer, + Feeder, + Stream, + File, + Nonblocking, + Record, + Geometry, + Profiler, + Studio_Update, + Studio_Load_Bank, + Studio_Load_Sample, + Convolution_1, + Convolution_2, + } + + // We use our own enum to avoid serialization issues if FMOD.THREAD_AFFINITY changes + [Flags] + public enum ThreadAffinity : uint + { + Any = 0, + Core0 = 1 << 0, + Core1 = 1 << 1, + Core2 = 1 << 2, + Core3 = 1 << 3, + Core4 = 1 << 4, + Core5 = 1 << 5, + Core6 = 1 << 6, + Core7 = 1 << 7, + Core8 = 1 << 8, + Core9 = 1 << 9, + Core10 = 1 << 10, + Core11 = 1 << 11, + Core12 = 1 << 12, + Core13 = 1 << 13, + Core14 = 1 << 14, + Core15 = 1 << 15, + } + + // Using a separate enum to avoid serialization issues if FMOD.SOUND_TYPE changes. + public enum CodecType : int + { + FADPCM, + Vorbis, + AT9, + XMA, + Opus + } + + [Serializable] + public class ThreadAffinityGroup + { + public List threads = new List(); + public ThreadAffinity affinity = ThreadAffinity.Any; + + public ThreadAffinityGroup() + { + } + + public ThreadAffinityGroup(ThreadAffinityGroup other) + { + threads = new List(other.threads); + affinity = other.affinity; + } + + public ThreadAffinityGroup(ThreadAffinity affinity, params ThreadType[] threads) + { + this.threads = new List(threads); + this.affinity = affinity; + } + } + + [Serializable] + public class CodecChannelCount + { + public CodecType format; + public int channels; + + public CodecChannelCount() { } + + public CodecChannelCount(CodecChannelCount other) + { + format = other.format; + channels = other.channels; + } + } + + public static class RuntimeUtils + { +#if UNITY_EDITOR + private static string pluginBasePath; + + public const string BaseFolderGUID = "06ae579381df01a4a87bb149dec89954"; + public const string PluginBasePathDefault = "Assets/Plugins/FMOD"; + + public static string PluginBasePath + { + get + { + if (pluginBasePath == null) + { + pluginBasePath = AssetDatabase.GUIDToAssetPath(BaseFolderGUID); + + if (string.IsNullOrEmpty(pluginBasePath)) + { + pluginBasePath = PluginBasePathDefault; + + DebugLogWarningFormat("FMOD: Couldn't find base folder with GUID {0}; defaulting to {1}", + BaseFolderGUID, pluginBasePath); + } + } + + return pluginBasePath; + } + } +#endif + + public static string GetCommonPlatformPath(string path) + { + if (string.IsNullOrEmpty(path)) + { + return path; + } + + return path.Replace('\\', '/'); + } + + public static FMOD.VECTOR ToFMODVector(this Vector3 vec) + { + FMOD.VECTOR temp; + temp.x = vec.x; + temp.y = vec.y; + temp.z = vec.z; + + return temp; + } + + public static FMOD.ATTRIBUTES_3D To3DAttributes(this Vector3 pos) + { + FMOD.ATTRIBUTES_3D attributes = new FMOD.ATTRIBUTES_3D(); + attributes.forward = ToFMODVector(Vector3.forward); + attributes.up = ToFMODVector(Vector3.up); + attributes.position = ToFMODVector(pos); + + return attributes; + } + + public static FMOD.ATTRIBUTES_3D To3DAttributes(this Transform transform) + { + FMOD.ATTRIBUTES_3D attributes = new FMOD.ATTRIBUTES_3D(); + attributes.forward = transform.forward.ToFMODVector(); + attributes.up = transform.up.ToFMODVector(); + attributes.position = transform.position.ToFMODVector(); + + return attributes; + } + + public static FMOD.ATTRIBUTES_3D To3DAttributes(this Transform transform, Vector3 velocity) + { + FMOD.ATTRIBUTES_3D attributes = new FMOD.ATTRIBUTES_3D(); + attributes.forward = transform.forward.ToFMODVector(); + attributes.up = transform.up.ToFMODVector(); + attributes.position = transform.position.ToFMODVector(); + attributes.velocity = velocity.ToFMODVector(); + + return attributes; + } + + public static FMOD.ATTRIBUTES_3D To3DAttributes(this GameObject go) + { + return go.transform.To3DAttributes(); + } + +#if UNITY_PHYSICS_EXIST + public static FMOD.ATTRIBUTES_3D To3DAttributes(Transform transform, Rigidbody rigidbody = null) + { + FMOD.ATTRIBUTES_3D attributes = transform.To3DAttributes(); + + if (rigidbody) + { + attributes.velocity = rigidbody.velocity.ToFMODVector(); + } + + return attributes; + } + + public static FMOD.ATTRIBUTES_3D To3DAttributes(GameObject go, Rigidbody rigidbody) + { + FMOD.ATTRIBUTES_3D attributes = go.transform.To3DAttributes(); + + if (rigidbody) + { + attributes.velocity = rigidbody.velocity.ToFMODVector(); + } + + return attributes; + } +#endif + +#if UNITY_PHYSICS2D_EXIST + public static FMOD.ATTRIBUTES_3D To3DAttributes(Transform transform, Rigidbody2D rigidbody) + { + FMOD.ATTRIBUTES_3D attributes = transform.To3DAttributes(); + + if (rigidbody) + { + FMOD.VECTOR vel; + vel.x = rigidbody.velocity.x; + vel.y = rigidbody.velocity.y; + vel.z = 0; + attributes.velocity = vel; + } + + return attributes; + } + + + public static FMOD.ATTRIBUTES_3D To3DAttributes(GameObject go, Rigidbody2D rigidbody) + { + FMOD.ATTRIBUTES_3D attributes = go.transform.To3DAttributes(); + + if (rigidbody) + { + FMOD.VECTOR vel; + vel.x = rigidbody.velocity.x; + vel.y = rigidbody.velocity.y; + vel.z = 0; + attributes.velocity = vel; + } + + return attributes; + } +#endif + + public static FMOD.THREAD_TYPE ToFMODThreadType(ThreadType threadType) + { + switch (threadType) + { + case ThreadType.Mixer: + return FMOD.THREAD_TYPE.MIXER; + case ThreadType.Feeder: + return FMOD.THREAD_TYPE.FEEDER; + case ThreadType.Stream: + return FMOD.THREAD_TYPE.STREAM; + case ThreadType.File: + return FMOD.THREAD_TYPE.FILE; + case ThreadType.Nonblocking: + return FMOD.THREAD_TYPE.NONBLOCKING; + case ThreadType.Record: + return FMOD.THREAD_TYPE.RECORD; + case ThreadType.Geometry: + return FMOD.THREAD_TYPE.GEOMETRY; + case ThreadType.Profiler: + return FMOD.THREAD_TYPE.PROFILER; + case ThreadType.Studio_Update: + return FMOD.THREAD_TYPE.STUDIO_UPDATE; + case ThreadType.Studio_Load_Bank: + return FMOD.THREAD_TYPE.STUDIO_LOAD_BANK; + case ThreadType.Studio_Load_Sample: + return FMOD.THREAD_TYPE.STUDIO_LOAD_SAMPLE; + case ThreadType.Convolution_1: + return FMOD.THREAD_TYPE.CONVOLUTION1; + case ThreadType.Convolution_2: + return FMOD.THREAD_TYPE.CONVOLUTION2; + default: + throw new ArgumentException("Unrecognised thread type '" + threadType.ToString() + "'"); + } + } + + public static string DisplayName(this ThreadType thread) + { + return thread.ToString().Replace('_', ' '); + } + + public static FMOD.THREAD_AFFINITY ToFMODThreadAffinity(ThreadAffinity affinity) + { + FMOD.THREAD_AFFINITY fmodAffinity = FMOD.THREAD_AFFINITY.CORE_ALL; + + SetFMODAffinityBit(affinity, ThreadAffinity.Core0, FMOD.THREAD_AFFINITY.CORE_0, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core1, FMOD.THREAD_AFFINITY.CORE_1, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core2, FMOD.THREAD_AFFINITY.CORE_2, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core3, FMOD.THREAD_AFFINITY.CORE_3, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core4, FMOD.THREAD_AFFINITY.CORE_4, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core5, FMOD.THREAD_AFFINITY.CORE_5, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core6, FMOD.THREAD_AFFINITY.CORE_6, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core7, FMOD.THREAD_AFFINITY.CORE_7, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core8, FMOD.THREAD_AFFINITY.CORE_8, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core9, FMOD.THREAD_AFFINITY.CORE_9, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core10, FMOD.THREAD_AFFINITY.CORE_10, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core11, FMOD.THREAD_AFFINITY.CORE_11, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core12, FMOD.THREAD_AFFINITY.CORE_12, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core13, FMOD.THREAD_AFFINITY.CORE_13, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core14, FMOD.THREAD_AFFINITY.CORE_14, ref fmodAffinity); + SetFMODAffinityBit(affinity, ThreadAffinity.Core15, FMOD.THREAD_AFFINITY.CORE_15, ref fmodAffinity); + + return fmodAffinity; + } + + private static void SetFMODAffinityBit(ThreadAffinity affinity, ThreadAffinity mask, + FMOD.THREAD_AFFINITY fmodMask, ref FMOD.THREAD_AFFINITY fmodAffinity) + { + if ((affinity & mask) != 0) + { + fmodAffinity |= fmodMask; + } + } + + public static void EnforceLibraryOrder() + { +#if UNITY_ANDROID && !UNITY_EDITOR + + AndroidJavaClass jSystem = new AndroidJavaClass("java.lang.System"); + jSystem.CallStatic("loadLibrary", FMOD.VERSION.dll); + jSystem.CallStatic("loadLibrary", FMOD.Studio.STUDIO_VERSION.dll); + +#endif + + // Call a function in fmod.dll to make sure it's loaded before fmodstudio.dll + int temp1, temp2; + FMOD.Memory.GetStats(out temp1, out temp2); + + FMOD.GUID temp3; + FMOD.Studio.Util.parseID("", out temp3); + } + + public static void DebugLog(string message) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel == FMOD.DEBUG_FLAGS.LOG) + { + Debug.Log(message); + } + } + + public static void DebugLogFormat(string format, params object[] args) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel == FMOD.DEBUG_FLAGS.LOG) + { + Debug.LogFormat(format, args); + } + } + + public static void DebugLogWarning(string message) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel >= FMOD.DEBUG_FLAGS.WARNING) + { + Debug.LogWarning(message); + } + } + + public static void DebugLogWarningFormat(string format, params object[] args) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel >= FMOD.DEBUG_FLAGS.WARNING) + { + Debug.LogWarningFormat(format, args); + } + } + + public static void DebugLogError(string message) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel >= FMOD.DEBUG_FLAGS.ERROR) + { + Debug.LogError(message); + } + } + + public static void DebugLogErrorFormat(string format, params object[] args) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel >= FMOD.DEBUG_FLAGS.ERROR) + { + Debug.LogErrorFormat(format, args); + } + } + + public static void DebugLogException(Exception e) + { + if (!Settings.IsInitialized() || Settings.Instance.LoggingLevel >= FMOD.DEBUG_FLAGS.ERROR) + { + Debug.LogException(e); + } + } + +#if UNITY_EDITOR + public static string WritableAssetPath(string subPath) + { + if (RuntimeUtils.PluginBasePath.StartsWith("Assets/")) + { + return $"{RuntimeUtils.PluginBasePath}/{subPath}.asset"; + } + else + { + return $"Assets/Plugins/FMOD/{subPath}.asset"; + } + } +#endif + } +} diff --git a/Assets/Plugins/FMOD/src/RuntimeUtils.cs.meta b/Assets/Plugins/FMOD/src/RuntimeUtils.cs.meta new file mode 100644 index 0000000..95c7587 --- /dev/null +++ b/Assets/Plugins/FMOD/src/RuntimeUtils.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6e349601408e423499e7b9f75216091d +timeCreated: 1433225261 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/Settings.cs b/Assets/Plugins/FMOD/src/Settings.cs new file mode 100644 index 0000000..9a213e8 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Settings.cs @@ -0,0 +1,1020 @@ +using UnityEngine; +using System.Collections.Generic; +using System; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using UnityEngine.Serialization; +using System.Runtime.CompilerServices; +#if UNITY_EDITOR +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +#endif + +[assembly: InternalsVisibleTo("FMODUnityEditor")] +namespace FMODUnity +{ + [Serializable] + public enum ImportType + { + StreamingAssets, + AssetBundle, + } + + [Serializable] + public enum BankLoadType + { + All, + Specified, + None + } + + [Serializable] + public enum MeterChannelOrderingType + { + Standard, + SeparateLFE, + Positional + } + + public enum EventLinkage + { + Path, + GUID, + } + + public enum TriStateBool + { + Disabled, + Enabled, + Development, + } + + public enum ScreenPosition + { + TopLeft, + TopCenter, + TopRight, + BottomLeft, + BottomCenter, + BottomRight, + Center, + VR, + } + + public interface IEditorSettings + { +#if UNITY_EDITOR + Settings RuntimeSettings { get; set; } + bool ForceLoggingBinaries { get; set; } + Platform CurrentEditorPlatform { get; } + void Clear(); + void ResetPlatformSettings(); + void ReimportLegacyPlatforms(); + void CreateSettingsAsset(string assetName); + void AddMissingPlatforms(); + void AddPlatformsToAsset(); + void AddPlatformForBuildTargets(Platform platform); + void UpdateMigratedPlatform(Platform platform); + Platform GetPlatform(BuildTarget buildTarget); + void SetPlatformParent(Platform platform, Platform newParent); + PlatformGroup AddPlatformGroup(string displayName, int sortOrder); + void PreprocessBuild(BuildTarget target, Platform.BinaryType binaryType); + void CleanTemporaryFiles(); + void DeleteTemporaryFile(string assetPath); + bool CanBuildTarget(BuildTarget target, Platform.BinaryType binaryType, out string error); + void CheckActiveBuildTarget(); +#endif + } + + // This class stores all of the FMOD for Unity cross-platform settings, as well as a collection + // of Platform objects that hold the platform-specific settings. The Platform objects are stored + // in the same asset as the Settings object using AssetDatabase.AddObjectToAsset. + public class Settings : ScriptableObject + { +#if UNITY_EDITOR + [FormerlySerializedAs("SwitchSettingsMigration")] + [SerializeField] + private bool switchSettingsMigration = false; +#endif + + internal const string SettingsAssetName = "FMODStudioSettings"; + + private static Settings instance = null; + private static IEditorSettings editorSettings = null; + private static bool isInitializing = false; + + [SerializeField] + public bool HasSourceProject = true; + + [SerializeField] + public bool HasPlatforms = true; + + [SerializeField] + private string sourceProjectPath; + + [SerializeField] + private string sourceBankPath; + + [FormerlySerializedAs("SourceBankPathUnformatted")] + [SerializeField] + private string sourceBankPathUnformatted; // Kept as to not break existing projects + + [SerializeField] + public int BankRefreshCooldown = 5; + + [SerializeField] + public bool ShowBankRefreshWindow = true; + + internal const int BankRefreshPrompt = -1; + internal const int BankRefreshManual = -2; + + [SerializeField] + public bool AutomaticEventLoading; + + [SerializeField] + public BankLoadType BankLoadType; + + [SerializeField] + public bool AutomaticSampleLoading; + + [SerializeField] + public string EncryptionKey; + + [SerializeField] + public ImportType ImportType; + + [SerializeField] + public string TargetAssetPath = "FMODBanks"; + + [SerializeField] + public string TargetBankFolder = ""; + + [SerializeField] + public EventLinkage EventLinkage = EventLinkage.Path; + + [SerializeField] + public FMOD.DEBUG_FLAGS LoggingLevel = FMOD.DEBUG_FLAGS.WARNING; + + [SerializeField] + internal List SpeakerModeSettings; + + [SerializeField] + internal List SampleRateSettings; + + [SerializeField] + internal List LiveUpdateSettings; + + [SerializeField] + internal List OverlaySettings; + + [SerializeField] + internal List BankDirectorySettings; + + [SerializeField] + internal List VirtualChannelSettings; + + [SerializeField] + internal List RealChannelSettings; + + [SerializeField] + internal List Plugins = new List(); + + [SerializeField] + public List MasterBanks; + + [SerializeField] + public List Banks; + + [SerializeField] + public List BanksToLoad; + + [SerializeField] + public ushort LiveUpdatePort = 9264; + + [SerializeField] + public bool EnableMemoryTracking; + + [SerializeField] + public bool AndroidUseOBB = false; + + [SerializeField] + public bool AndroidPatchBuild = false; + + [SerializeField] + public MeterChannelOrderingType MeterChannelOrdering; + + [SerializeField] + public bool StopEventsOutsideMaxDistance = false; + + [SerializeField] + internal bool BoltUnitOptionsBuildPending = false; + + [SerializeField] + public bool EnableErrorCallback = false; + + [SerializeField] + internal SharedLibraryUpdateStages SharedLibraryUpdateStage = SharedLibraryUpdateStages.Start; + + [SerializeField] + internal double SharedLibraryTimeSinceStart = 0.0; + + [SerializeField] + internal int CurrentVersion; + + [SerializeField] + public bool HideSetupWizard; + + [SerializeField] + internal int LastEventReferenceScanVersion; + + // This holds all known platforms, but only those that have settings are shown in the UI. + // It is populated at load time from the Platform objects in the settings asset. + // It is serializable to facilitate undo support. + [SerializeField] + public List Platforms = new List(); + + // This is used to find the platform that matches the current Unity runtime platform. + internal Dictionary> PlatformForRuntimePlatform = new Dictionary>(); + + // Default platform settings. + [NonSerialized] + public Platform DefaultPlatform; + + // Play In Editor platform settings. + [NonSerialized] + public Platform PlayInEditorPlatform; + +#if UNITY_EDITOR + // We store a persistent list so we don't try to re-migrate platforms if the user deletes them. + [SerializeField] + internal List MigratedPlatforms = new List(); +#endif + + // A collection of templates for constructing known platforms. + internal static List PlatformTemplates = new List(); + + [NonSerialized] + private bool hasLoaded = false; + + public static Settings Instance + { + get + { + if (isInitializing) + { + return null; + } + + Initialize(); + + return instance; + } + } + + internal static void Initialize() + { + if (instance == null) + { + isInitializing = true; + + instance = Resources.Load(SettingsAssetName) as Settings; + + if (instance == null) + { + RuntimeUtils.DebugLog("[FMOD] Cannot find integration settings, creating default settings"); + instance = CreateInstance(); + instance.name = "FMOD Studio Integration Settings"; + instance.CurrentVersion = FMOD.VERSION.number; + instance.LastEventReferenceScanVersion = FMOD.VERSION.number; + +#if UNITY_EDITOR + if (editorSettings != null) + { + editorSettings.CreateSettingsAsset(SettingsAssetName); + } + else + { + // editorSettings is populated via the static constructor of FMODUnity.EditorSettings when in the Unity editor. + RuntimeUtils.DebugLogError("[FMOD] Attempted to instantiate Settings before EditorSettings was populated. " + + "Ensure that Settings.Instance is not being called from an InitializeOnLoad method or class."); + } +#endif + } + else + { +#if UNITY_EDITOR + if (AssetDatabase.GetAssetPath(instance).StartsWith("Packages")) + { + RuntimeUtils.DebugLogError($"[FMOD] {SettingsAssetName} initialization failed. {SettingsAssetName} located in \"Packages\" folder. Please delete {SettingsAssetName} in file explorer."); + instance = CreateInstance(); + } +#endif + } + + isInitializing = false; + } + } + + internal static bool IsInitialized() + { + return !(instance == null || isInitializing); + } + + internal static IEditorSettings EditorSettings + { + get + { + return editorSettings; + } + set + { + editorSettings = value; + } + } + + public string SourceProjectPath + { + get + { + return sourceProjectPath; + } + set + { + sourceProjectPath = value; + } + } + + public string SourceBankPath + { + get + { + return sourceBankPath; + } + set + { + sourceBankPath = value; + } + } + + internal string TargetPath + { + get + { + if (ImportType == ImportType.AssetBundle) + { + if (string.IsNullOrEmpty(TargetAssetPath)) + { + return Application.dataPath; + } + else + { + return Application.dataPath + "/" + TargetAssetPath; + } + } + else + { + if (string.IsNullOrEmpty(TargetBankFolder)) + { + return Application.streamingAssetsPath; + } + else + { + return Application.streamingAssetsPath + "/" + TargetBankFolder; + } + } + } + } + + public string TargetSubFolder + { + get + { + if (ImportType == ImportType.AssetBundle) + { + return TargetAssetPath; + } + else + { + return TargetBankFolder; + } + } + set + { + if (ImportType == ImportType.AssetBundle) + { + TargetAssetPath = value; + } + else + { + TargetBankFolder = value; + } + } + } + + internal enum SharedLibraryUpdateStages + { + Start = 0, + DisableExistingLibraries, + RestartUnity, + CopyNewLibraries, + }; + + internal Platform FindPlatform(string identifier) + { + foreach (Platform platform in Platforms) + { + if (platform.Identifier == identifier) + { + return platform; + } + } + + return null; + } + + internal bool PlatformExists(string identifier) + { + return FindPlatform(identifier) != null; + } + + internal void AddPlatform(Platform platform) + { + if (PlatformExists(platform.Identifier)) + { + throw new ArgumentException(string.Format("Duplicate platform identifier: {0}", platform.Identifier)); + } + + Platforms.Add(platform); + } + + internal void RemovePlatform(string identifier) + { + Platforms.RemoveAll(p => p.Identifier == identifier); + } + + // Links the platform to its parent, and to the BuildTargets and RuntimePlatforms it implements. + internal void LinkPlatform(Platform platform) + { + LinkPlatformToParent(platform); + + platform.DeclareRuntimePlatforms(this); + +#if UNITY_EDITOR + if (editorSettings != null) + { + editorSettings.AddPlatformForBuildTargets(platform); + } +#endif + } + + internal void DeclareRuntimePlatform(RuntimePlatform runtimePlatform, Platform platform) + { + List platforms; + + if (!PlatformForRuntimePlatform.TryGetValue(runtimePlatform, out platforms)) + { + platforms = new List(); + PlatformForRuntimePlatform.Add(runtimePlatform, platforms); + } + + platforms.Add(platform); + + // Highest priority goes first + platforms.Sort((a, b) => b.Priority.CompareTo(a.Priority)); + } + + // Links the given platform to its parent, if it has one. + private void LinkPlatformToParent(Platform platform) + { + if (!string.IsNullOrEmpty(platform.ParentIdentifier)) + { + SetPlatformParent(platform, FindPlatform(platform.ParentIdentifier)); + } + } + + // The highest-priority platform that matches the current environment. + internal Platform FindCurrentPlatform() + { + List platforms; + + if (PlatformForRuntimePlatform.TryGetValue(Application.platform, out platforms)) + { + foreach (Platform platform in platforms) + { + if (platform.MatchesCurrentEnvironment) + { + return platform; + } + } + } + + return DefaultPlatform; + } + + private Settings() + { + MasterBanks = new List(); + Banks = new List(); + BanksToLoad = new List(); + RealChannelSettings = new List(); + VirtualChannelSettings = new List(); + LiveUpdateSettings = new List(); + OverlaySettings = new List(); + SampleRateSettings = new List(); + SpeakerModeSettings = new List(); + BankDirectorySettings = new List(); + + ImportType = ImportType.StreamingAssets; + AutomaticEventLoading = true; + AutomaticSampleLoading = false; + EnableMemoryTracking = false; + } + + // Adds properties to a platform, thus revealing it in the UI. + internal void AddPlatformProperties(Platform platform) + { + platform.AffirmProperties(); + LinkPlatformToParent(platform); + } + +#if UNITY_EDITOR + internal void SetPlatformParent(Platform platform, Platform newParent) + { + if (editorSettings != null) + { + editorSettings.SetPlatformParent(platform, newParent); + } + } +#else + public void SetPlatformParent(Platform platform, Platform newParent) + { + platform.Parent = newParent; + } +#endif + + // A template for constructing a platform from an identifier. + internal struct PlatformTemplate + { + public string Identifier; + public Func CreateInstance; + }; + + // Adds a platform to the collection of templates. Platforms register themselves by using + // [InitializeOnLoad] and calling this function from a static constructor. + internal static void AddPlatformTemplate(string identifier) where T : Platform + { + PlatformTemplates.Add(new PlatformTemplate() { + Identifier = identifier, + CreateInstance = () => CreatePlatformInstance(identifier) + }); + } + + private static Platform CreatePlatformInstance(string identifier) where T : Platform + { + Platform platform = CreateInstance(); + platform.InitializeProperties(); + platform.Identifier = identifier; + + return platform; + } + + internal void OnEnable() + { + if (hasLoaded) + { + // Already loaded + return; + } + + hasLoaded = true; + +#if UNITY_EDITOR + if (editorSettings != null) + { + // Clear the EditorSettings object in case it has not been reloaded (this can happen + // if the settings asset is modified on disk). + editorSettings.Clear(); + + editorSettings.RuntimeSettings = this; + } +#endif + + PopulatePlatformsFromAsset(); + + DefaultPlatform = Platforms.FirstOrDefault(platform => platform is PlatformDefault); + PlayInEditorPlatform = Platforms.FirstOrDefault(platform => platform is PlatformPlayInEditor); + +#if UNITY_EDITOR + if (editorSettings != null) + { + if (switchSettingsMigration == false) + { + // Create Switch settings from the legacy Mobile settings, if they exist + Legacy.CopySetting(LiveUpdateSettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + Legacy.CopySetting(OverlaySettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + + Legacy.CopySetting(RealChannelSettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + Legacy.CopySetting(VirtualChannelSettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + Legacy.CopySetting(SampleRateSettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + Legacy.CopySetting(SpeakerModeSettings, Legacy.Platform.Mobile, Legacy.Platform.Switch); + switchSettingsMigration = true; + } + + // Fix up slashes for old settings meta data. + SourceProjectPath = RuntimeUtils.GetCommonPlatformPath(SourceProjectPath); + sourceBankPathUnformatted = RuntimeUtils.GetCommonPlatformPath(sourceBankPathUnformatted); + + // Remove the FMODStudioCache if in the old location + string oldCache = "Assets/Plugins/FMOD/Resources/FMODStudioCache.asset"; + if (File.Exists(oldCache)) + { + AssetDatabase.DeleteAsset(oldCache); + } + + editorSettings.AddMissingPlatforms(); + + // Add all known platforms to the settings asset. We can only do this if the Settings + // object is already in the asset database, which won't be the case if we're inside the + // CreateInstance call in the Instance accessor above. + if (AssetDatabase.Contains(this)) + { + editorSettings.AddPlatformsToAsset(); + } + } +#endif + + // Link all known platforms + Platforms.ForEach(LinkPlatform); + } + + private void PopulatePlatformsFromAsset() + { + Platforms.Clear(); + +#if UNITY_EDITOR + string assetPath = AssetDatabase.GetAssetPath(this); + UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(assetPath); + Platform[] assetPlatforms = assets.OfType().ToArray(); +#else + Platform[] assetPlatforms = Resources.LoadAll(SettingsAssetName); +#endif + + foreach (Platform newPlatform in assetPlatforms) + { + Platform existingPlatform = FindPlatform(newPlatform.Identifier); + + if (existingPlatform != null) + { + // Duplicate platform; clean one of them up + Platform platformToDestroy; + + if (newPlatform.Active && !existingPlatform.Active) + { + RemovePlatform(existingPlatform.Identifier); + + platformToDestroy = existingPlatform; + existingPlatform = null; + } + else + { + platformToDestroy = newPlatform; + } + + RuntimeUtils.DebugLogWarningFormat("FMOD: Cleaning up duplicate platform: ID = {0}, name = '{1}', type = {2}", + platformToDestroy.Identifier, platformToDestroy.DisplayName, platformToDestroy.GetType().Name); + + DestroyImmediate(platformToDestroy, true); + } + + if (existingPlatform == null) + { + newPlatform.EnsurePropertiesAreValid(); + AddPlatform(newPlatform); + } + } + +#if UNITY_EDITOR + // Remove any invalid child platforms (ie. deprecated platforms). + foreach (Platform newPlatform in assetPlatforms) + { + if (newPlatform.ChildIdentifiers.RemoveAll(x => FindPlatform(x) == null) > 0) + { + EditorUtility.SetDirty(newPlatform); + } + } + + if (editorSettings != null) + { + Platforms.ForEach(editorSettings.UpdateMigratedPlatform); + } +#endif + } + } + + // This class stores data types and code used for migrating old settings. + internal static class Legacy + { +#if UNITY_EDITOR + private const string RegisterStaticPluginsAssetPathRelative = + "/Plugins/FMOD/Cache/fmod_register_static_plugins.cpp"; + private const string RegisterStaticPluginsAssetPathFull = "Assets" + RegisterStaticPluginsAssetPathRelative; + + public static void CleanTemporaryChanges() + { + CleanIl2CppArgs(); + CleanTemporaryFiles(); + } + + private static IEnumerable AdditionalIl2CppFiles() + { + yield return Application.dataPath + RegisterStaticPluginsAssetPathRelative; + yield return Application.dataPath + "/Plugins/FMOD/src/Runtime/fmod_static_plugin_support.h"; + } + + public static void CleanIl2CppArgs() + { + const string Il2CppCommand_AdditionalCpp = "--additional-cpp"; + + string arguments = PlayerSettings.GetAdditionalIl2CppArgs(); + string newArguments = arguments; + + foreach (string path in AdditionalIl2CppFiles()) + { + // Match on basename only in case the temp file location has moved + string basename = Regex.Escape(Path.GetFileName(path)); + Regex regex = new Regex(Il2CppCommand_AdditionalCpp + "=\"[^\"]*" + basename + "\""); + + for (int startIndex = 0; startIndex < newArguments.Length; ) + { + Match match = regex.Match(newArguments, startIndex); + + if (!match.Success) + { + break; + } + + RuntimeUtils.DebugLogFormat("FMOD: Removing Il2CPP argument '{0}'", match.Value); + + int matchStart = match.Index; + int matchEnd = match.Index + match.Length; + + // Consume an adjacent space if there is one + if (matchStart > 0 && newArguments[matchStart - 1] == ' ') + { + --matchStart; + } + else if (matchEnd < newArguments.Length && newArguments[matchEnd] == ' ') + { + ++matchEnd; + } + + newArguments = newArguments.Substring(0, matchStart) + newArguments.Substring(matchEnd); + startIndex = matchStart; + } + } + + if (newArguments != arguments) + { + PlayerSettings.SetAdditionalIl2CppArgs(newArguments); + } + } + + public static void CleanTemporaryFiles() + { + if (EditorApplication.isPlayingOrWillChangePlaymode) + { + // Messing with the asset database while entering play mode causes a NullReferenceException + return; + } + + string[] TemporaryFiles = { + RegisterStaticPluginsAssetPathFull, + }; + + foreach (string path in TemporaryFiles) + { + if (Settings.EditorSettings != null) + { + Settings.EditorSettings.DeleteTemporaryFile(path); + } + } + } +#endif + + [Serializable] + public enum Platform + { + None, + PlayInEditor, + Default, + Desktop, + Mobile, + MobileHigh, + MobileLow, + Console, + Windows, + Mac, + Linux, + iOS, + Android, + Deprecated_1, + XboxOne, + PS4, + Deprecated_2, + Deprecated_3, + AppleTV, + UWP, + Switch, + WebGL, + Deprecated_4, + Reserved_1, + Reserved_2, + Reserved_3, + Count, + } + + public class PlatformSettingBase + { + public Platform Platform; + } + + public class PlatformSetting : PlatformSettingBase + { + public T Value; + } + + [Serializable] + public class PlatformIntSetting : PlatformSetting + { + } + + [Serializable] + public class PlatformStringSetting : PlatformSetting + { + } + + [Serializable] + public class PlatformBoolSetting : PlatformSetting + { + } + + // Copies a setting from one platform to another. + public static void CopySetting(List list, Platform fromPlatform, Platform toPlatform) + where T : PlatformSetting, new() + { + T fromSetting = list.Find((x) => x.Platform == fromPlatform); + T toSetting = list.Find((x) => x.Platform == toPlatform); + + if (fromSetting != null) + { + if (toSetting == null) + { + toSetting = new T() { Platform = toPlatform }; + list.Add(toSetting); + } + + toSetting.Value = fromSetting.Value; + } + else if (toSetting != null) + { + list.Remove(toSetting); + } + } + + public static void CopySetting(List list, Platform fromPlatform, Platform toPlatform) + { + CopySetting(list, fromPlatform, toPlatform); + } + + public static void CopySetting(List list, Platform fromPlatform, Platform toPlatform) + { + CopySetting(list, fromPlatform, toPlatform); + } + + // Returns the UI display name for the given platform. + public static string DisplayName(Platform platform) + { + switch (platform) + { + case Platform.Linux: + return "Linux"; + case Platform.Desktop: + return "Desktop"; + case Platform.Console: + return "Console"; + case Platform.iOS: + return "iOS"; + case Platform.Mac: + return "OSX"; + case Platform.Mobile: + return "Mobile"; + case Platform.PS4: + return "PS4"; + case Platform.Windows: + return "Windows"; + case Platform.UWP: + return "UWP"; + case Platform.XboxOne: + return "XBox One"; + case Platform.Android: + return "Android"; + case Platform.AppleTV: + return "Apple TV"; + case Platform.MobileHigh: + return "High-End Mobile"; + case Platform.MobileLow: + return "Low-End Mobile"; + case Platform.Switch: + return "Switch"; + case Platform.WebGL: + return "WebGL"; + } + return "Unknown"; + } + + // Returns the UI sort order for the given platform. + public static float SortOrder(Platform legacyPlatform) + { + switch (legacyPlatform) + { + case Platform.Desktop: + return 1; + case Platform.Windows: + return 1.1f; + case Platform.Mac: + return 1.2f; + case Platform.Linux: + return 1.3f; + case Platform.Mobile: + return 2; + case Platform.MobileHigh: + return 2.1f; + case Platform.MobileLow: + return 2.2f; + case Platform.AppleTV: + return 2.3f; + case Platform.Console: + return 3; + case Platform.XboxOne: + return 3.1f; + case Platform.PS4: + return 3.2f; + case Platform.Switch: + return 3.3f; + default: + return 0; + } + } + + // Returns the parent for the given platform. + public static Platform Parent(Platform platform) + { + switch (platform) + { + case Platform.Windows: + case Platform.Linux: + case Platform.Mac: + case Platform.UWP: + case Platform.WebGL: + return Platform.Desktop; + case Platform.MobileHigh: + case Platform.MobileLow: + case Platform.iOS: + case Platform.Android: + case Platform.AppleTV: + return Platform.Mobile; + case Platform.Switch: + case Platform.XboxOne: + case Platform.PS4: + case Platform.Reserved_1: + case Platform.Reserved_2: + case Platform.Reserved_3: + return Platform.Console; + case Platform.Desktop: + case Platform.Console: + case Platform.Mobile: + return Platform.Default; + case Platform.PlayInEditor: + case Platform.Default: + default: + return Platform.None; + } + } + + // Determines whether the given platform is a group + public static bool IsGroup(Platform platform) + { + switch (platform) + { + case Platform.Desktop: + case Platform.Mobile: + case Platform.Console: + return true; + default: + return false; + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/Settings.cs.meta b/Assets/Plugins/FMOD/src/Settings.cs.meta new file mode 100644 index 0000000..cdb4a83 --- /dev/null +++ b/Assets/Plugins/FMOD/src/Settings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: eef8d824ea7b63742966aaa0e94ac383 +timeCreated: 1435215721 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -400 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/StudioBankLoader.cs b/Assets/Plugins/FMOD/src/StudioBankLoader.cs new file mode 100644 index 0000000..8a2afa0 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioBankLoader.cs @@ -0,0 +1,118 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace FMODUnity +{ + [AddComponentMenu("FMOD Studio/FMOD Studio Bank Loader")] + public class StudioBankLoader : MonoBehaviour + { + public LoaderGameEvent LoadEvent; + public LoaderGameEvent UnloadEvent; + [BankRef] + public List Banks; + public string CollisionTag; + public bool PreloadSamples; + private bool isQuitting; + + private void HandleGameEvent(LoaderGameEvent gameEvent) + { + if (LoadEvent == gameEvent) + { + Load(); + } + if (UnloadEvent == gameEvent) + { + Unload(); + } + } + + private void Start() + { + RuntimeUtils.EnforceLibraryOrder(); + HandleGameEvent(LoaderGameEvent.ObjectStart); + } + + private void OnApplicationQuit() + { + isQuitting = true; + } + + private void OnDestroy() + { + if (!isQuitting) + { + HandleGameEvent(LoaderGameEvent.ObjectDestroy); + } + } + +#if UNITY_PHYSICS_EXIST + private void OnTriggerEnter(Collider other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(LoaderGameEvent.TriggerEnter); + } + } + + private void OnTriggerExit(Collider other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(LoaderGameEvent.TriggerExit); + } + } +#endif + +#if UNITY_PHYSICS2D_EXIST + private void OnTriggerEnter2D(Collider2D other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(LoaderGameEvent.TriggerEnter2D); + } + } + + private void OnTriggerExit2D(Collider2D other) + { + if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag)) + { + HandleGameEvent(LoaderGameEvent.TriggerExit2D); + } + } +#endif + + private void OnEnable() + { + HandleGameEvent(LoaderGameEvent.ObjectEnable); + } + + private void OnDisable() + { + HandleGameEvent(LoaderGameEvent.ObjectDisable); + } + + public void Load() + { + foreach (var bankRef in Banks) + { + try + { + RuntimeManager.LoadBank(bankRef, PreloadSamples); + } + catch (BankLoadException e) + { + RuntimeUtils.DebugLogException(e); + } + } + RuntimeManager.WaitForAllSampleLoading(); + } + + public void Unload() + { + foreach (var bankRef in Banks) + { + RuntimeManager.UnloadBank(bankRef); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/StudioBankLoader.cs.meta b/Assets/Plugins/FMOD/src/StudioBankLoader.cs.meta new file mode 100644 index 0000000..6649bdd --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioBankLoader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b9468c5f457ace64f8d4df6d642b107f +timeCreated: 1440562167 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -250 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/StudioEventEmitter.cs b/Assets/Plugins/FMOD/src/StudioEventEmitter.cs new file mode 100644 index 0000000..a6ec1f9 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioEventEmitter.cs @@ -0,0 +1,387 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace FMODUnity +{ + [AddComponentMenu("FMOD Studio/FMOD Studio Event Emitter")] + public class StudioEventEmitter : EventHandler + { + public EventReference EventReference; + + [Obsolete("Use the EventReference field instead")] + public string Event = ""; + + public EmitterGameEvent PlayEvent = EmitterGameEvent.None; + public EmitterGameEvent StopEvent = EmitterGameEvent.None; + public bool AllowFadeout = true; + public bool TriggerOnce = false; + public bool Preload = false; + public bool AllowNonRigidbodyDoppler = false; + public ParamRef[] Params = new ParamRef[0]; + public bool OverrideAttenuation = false; + public float OverrideMinDistance = -1.0f; + public float OverrideMaxDistance = -1.0f; + + protected FMOD.Studio.EventDescription eventDescription; + + protected FMOD.Studio.EventInstance instance; + + private bool hasTriggered = false; + private bool isQuitting = false; + private bool isOneshot = false; + private List cachedParams = new List(); + + private static List activeEmitters = new List(); + + private const string SnapshotString = "snapshot"; + + public FMOD.Studio.EventDescription EventDescription { get { return eventDescription; } } + + public FMOD.Studio.EventInstance EventInstance { get { return instance; } } + + public bool IsActive { get; private set; } + + private float MaxDistance + { + get + { + if (OverrideAttenuation) + { + return OverrideMaxDistance; + } + + if (!eventDescription.isValid()) + { + Lookup(); + } + + float minDistance, maxDistance; + eventDescription.getMinMaxDistance(out minDistance, out maxDistance); + return maxDistance; + } + } + + public static void UpdateActiveEmitters() + { + foreach (StudioEventEmitter emitter in activeEmitters) + { + emitter.UpdatePlayingStatus(); + } + } + + private static void RegisterActiveEmitter(StudioEventEmitter emitter) + { + if (!activeEmitters.Contains(emitter)) + { + activeEmitters.Add(emitter); + } + } + + private static void DeregisterActiveEmitter(StudioEventEmitter emitter) + { + activeEmitters.Remove(emitter); + } + + private void UpdatePlayingStatus(bool force = false) + { + // If at least one listener is within the max distance, ensure an event instance is playing + bool playInstance = StudioListener.DistanceSquaredToNearestListener(transform.position) <= (MaxDistance * MaxDistance); + + if (force || playInstance != IsPlaying()) + { + if (playInstance) + { + PlayInstance(); + } + else + { + StopInstance(); + } + } + } + + protected override void Start() + { + RuntimeUtils.EnforceLibraryOrder(); + if (Preload) + { + Lookup(); + eventDescription.loadSampleData(); + } + + HandleGameEvent(EmitterGameEvent.ObjectStart); + + // If a Rigidbody is added, turn off "allowNonRigidbodyDoppler" option +#if UNITY_PHYSICS_EXIST + if (AllowNonRigidbodyDoppler && GetComponent()) + { + AllowNonRigidbodyDoppler = false; + } +#endif + } + + private void OnApplicationQuit() + { + isQuitting = true; + } + + protected override void OnDestroy() + { + if (!isQuitting) + { + HandleGameEvent(EmitterGameEvent.ObjectDestroy); + + if (instance.isValid()) + { + RuntimeManager.DetachInstanceFromGameObject(instance); + if (eventDescription.isValid() && isOneshot) + { + instance.release(); + instance.clearHandle(); + } + } + + DeregisterActiveEmitter(this); + + if (Preload) + { + eventDescription.unloadSampleData(); + } + } + } + + protected override void HandleGameEvent(EmitterGameEvent gameEvent) + { + if (PlayEvent == gameEvent) + { + Play(); + } + if (StopEvent == gameEvent) + { + Stop(); + } + } + + private void Lookup() + { + eventDescription = RuntimeManager.GetEventDescription(EventReference); + + if (eventDescription.isValid()) + { + for (int i = 0; i < Params.Length; i++) + { + FMOD.Studio.PARAMETER_DESCRIPTION param; + eventDescription.getParameterDescriptionByName(Params[i].Name, out param); + Params[i].ID = param.id; + } + } + } + + public void Play() + { + if (TriggerOnce && hasTriggered) + { + return; + } + + if (EventReference.IsNull) + { + return; + } + + cachedParams.Clear(); + + if (!eventDescription.isValid()) + { + Lookup(); + } + + bool isSnapshot; + eventDescription.isSnapshot(out isSnapshot); + + if (!isSnapshot) + { + eventDescription.isOneshot(out isOneshot); + } + + bool is3D; + eventDescription.is3D(out is3D); + + IsActive = true; + + if (is3D && !isOneshot && Settings.Instance.StopEventsOutsideMaxDistance) + { + RegisterActiveEmitter(this); + UpdatePlayingStatus(true); + } + else + { + PlayInstance(); + } + } + + private void PlayInstance() + { + if (!instance.isValid()) + { + instance.clearHandle(); + } + + // Let previous oneshot instances play out + if (isOneshot && instance.isValid()) + { + instance.release(); + instance.clearHandle(); + } + + bool is3D; + eventDescription.is3D(out is3D); + + if (!instance.isValid()) + { + eventDescription.createInstance(out instance); + + // Only want to update if we need to set 3D attributes + if (is3D) + { + var transform = GetComponent(); +#if UNITY_PHYSICS_EXIST + if (GetComponent()) + { + Rigidbody rigidBody = GetComponent(); + instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)); + RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody); + } + else +#endif +#if UNITY_PHYSICS2D_EXIST + if (GetComponent()) + { + var rigidBody2D = GetComponent(); + instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D)); + RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D); + } + else +#endif + { + instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject)); + RuntimeManager.AttachInstanceToGameObject(instance, transform, AllowNonRigidbodyDoppler); + } + } + } + + foreach (var param in Params) + { + instance.setParameterByID(param.ID, param.Value); + } + + foreach (var cachedParam in cachedParams) + { + instance.setParameterByID(cachedParam.ID, cachedParam.Value); + } + + if (is3D && OverrideAttenuation) + { + instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance); + instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance); + } + + instance.start(); + + hasTriggered = true; + } + + public void Stop() + { + DeregisterActiveEmitter(this); + IsActive = false; + cachedParams.Clear(); + StopInstance(); + } + + private void StopInstance() + { + if (TriggerOnce && hasTriggered) + { + DeregisterActiveEmitter(this); + } + + if (instance.isValid()) + { + instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE); + instance.release(); + if (!AllowFadeout) + { + instance.clearHandle(); + } + } + } + + public void SetParameter(string name, float value, bool ignoreseekspeed = false) + { + if (Settings.Instance.StopEventsOutsideMaxDistance && IsActive) + { + string findName = name; + ParamRef cachedParam = cachedParams.Find(x => x.Name == findName); + + if (cachedParam == null) + { + FMOD.Studio.PARAMETER_DESCRIPTION paramDesc; + eventDescription.getParameterDescriptionByName(name, out paramDesc); + + cachedParam = new ParamRef(); + cachedParam.ID = paramDesc.id; + cachedParam.Name = paramDesc.name; + cachedParams.Add(cachedParam); + } + + cachedParam.Value = value; + } + + if (instance.isValid()) + { + instance.setParameterByName(name, value, ignoreseekspeed); + } + } + + public void SetParameter(FMOD.Studio.PARAMETER_ID id, float value, bool ignoreseekspeed = false) + { + if (Settings.Instance.StopEventsOutsideMaxDistance && IsActive) + { + FMOD.Studio.PARAMETER_ID findId = id; + ParamRef cachedParam = cachedParams.Find(x => x.ID.Equals(findId)); + + if (cachedParam == null) + { + FMOD.Studio.PARAMETER_DESCRIPTION paramDesc; + eventDescription.getParameterDescriptionByID(id, out paramDesc); + + cachedParam = new ParamRef(); + cachedParam.ID = paramDesc.id; + cachedParam.Name = paramDesc.name; + cachedParams.Add(cachedParam); + } + + cachedParam.Value = value; + } + + if (instance.isValid()) + { + instance.setParameterByID(id, value, ignoreseekspeed); + } + } + + public bool IsPlaying() + { + if (instance.isValid()) + { + FMOD.Studio.PLAYBACK_STATE playbackState; + instance.getPlaybackState(out playbackState); + return (playbackState != FMOD.Studio.PLAYBACK_STATE.STOPPED); + } + return false; + } + } +} diff --git a/Assets/Plugins/FMOD/src/StudioEventEmitter.cs.meta b/Assets/Plugins/FMOD/src/StudioEventEmitter.cs.meta new file mode 100644 index 0000000..429f028 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioEventEmitter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9a6610d2e704f1648819acc8d7460285 +timeCreated: 1444629021 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -220 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs b/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs new file mode 100644 index 0000000..76ec617 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs @@ -0,0 +1,56 @@ +using System; +using UnityEngine; +using UnityEngine.Serialization; + +namespace FMODUnity +{ + [AddComponentMenu("FMOD Studio/FMOD Studio Global Parameter Trigger")] + public class StudioGlobalParameterTrigger: EventHandler + { + [ParamRef] + [FormerlySerializedAs("parameter")] + public string Parameter; + + public EmitterGameEvent TriggerEvent; + + [FormerlySerializedAs("value")] + public float Value; + + private FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription; + public FMOD.Studio.PARAMETER_DESCRIPTION ParameterDescription { get { return parameterDescription; } } + + protected override void HandleGameEvent(EmitterGameEvent gameEvent) + { + if (TriggerEvent == gameEvent) + { + TriggerParameters(); + } + } + + public void TriggerParameters() + { + bool paramNameSpecified = !string.IsNullOrEmpty(Parameter); + if (paramNameSpecified) + { + FMOD.RESULT result = FMOD.RESULT.OK; + bool paramIDNeedsLookup = string.IsNullOrEmpty(parameterDescription.name); + if (paramIDNeedsLookup) + { + result = RuntimeManager.StudioSystem.getParameterDescriptionByName(Parameter, out parameterDescription); + if (result != FMOD.RESULT.OK) + { + RuntimeUtils.DebugLogError(string.Format(("[FMOD] StudioGlobalParameterTrigger failed to lookup parameter {0} : result = {1}"), Parameter, result)); + return; + } + } + + result = RuntimeManager.StudioSystem.setParameterByID(parameterDescription.id, Value); + if (result != FMOD.RESULT.OK) + { + RuntimeUtils.DebugLogError(string.Format(("[FMOD] StudioGlobalParameterTrigger failed to set parameter {0} : result = {1}"), Parameter, result)); + return; + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs.meta b/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs.meta new file mode 100644 index 0000000..af31c44 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9b0e04e2572f9a940a47465f6f3c2f00 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/StudioListener.cs b/Assets/Plugins/FMOD/src/StudioListener.cs new file mode 100644 index 0000000..8505f6d --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioListener.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace FMODUnity +{ + [AddComponentMenu("FMOD Studio/FMOD Studio Listener")] + public class StudioListener : MonoBehaviour + { + [SerializeField] + private GameObject attenuationObject = null; + +#if UNITY_PHYSICS_EXIST + private Rigidbody rigidBody; +#endif +#if UNITY_PHYSICS2D_EXIST + private Rigidbody2D rigidBody2D; +#endif + private static List listeners = new List(); + + public static int ListenerCount + { + get + { + return listeners.Count; + } + } + + public int ListenerNumber + { + get + { + return listeners.IndexOf(this); + } + } + + public static float DistanceToNearestListener(Vector3 position) + { + float result = float.MaxValue; + for (int i = 0; i < listeners.Count; i++) + { + result = Mathf.Min(result, Vector3.Distance(position, listeners[i].transform.position)); + } + return result; + } + + public static float DistanceSquaredToNearestListener(Vector3 position) + { + float result = float.MaxValue; + for (int i = 0; i < listeners.Count; i++) + { + result = Mathf.Min(result, (position - listeners[i].transform.position).sqrMagnitude); + } + return result; + } + + private static void AddListener(StudioListener listener) + { + // Is the listener already in the list? + if (listeners.Contains(listener)) + { + Debug.LogWarning(string.Format(("[FMOD] Listener has already been added at index {0}."), listener.ListenerNumber)); + return; + } + + // If already at the max numListeners + if (listeners.Count >= FMOD.CONSTANTS.MAX_LISTENERS) + { + Debug.LogWarning(string.Format(("[FMOD] Max number of listeners reached : {0}."), FMOD.CONSTANTS.MAX_LISTENERS)); + } + + listeners.Add(listener); + RuntimeManager.StudioSystem.setNumListeners(Mathf.Clamp(listeners.Count, 1, FMOD.CONSTANTS.MAX_LISTENERS)); + } + + private static void RemoveListener(StudioListener listener) + { + listeners.Remove(listener); + RuntimeManager.StudioSystem.setNumListeners(Mathf.Clamp(listeners.Count, 1, FMOD.CONSTANTS.MAX_LISTENERS)); + } + + private void OnEnable() + { + RuntimeUtils.EnforceLibraryOrder(); +#if UNITY_PHYSICS_EXIST + rigidBody = gameObject.GetComponent(); +#endif +#if UNITY_PHYSICS2D_EXIST + rigidBody2D = gameObject.GetComponent(); +#endif + AddListener(this); + } + + private void OnDisable() + { + RemoveListener(this); + } + + private void Update() + { + if (ListenerNumber >= 0 && ListenerNumber < FMOD.CONSTANTS.MAX_LISTENERS) + { + SetListenerLocation(); + } + } + + private void SetListenerLocation() + { +#if UNITY_PHYSICS_EXIST + if (rigidBody) + { + RuntimeManager.SetListenerLocation(ListenerNumber, gameObject, rigidBody, attenuationObject); + } + else +#endif +#if UNITY_PHYSICS2D_EXIST + if (rigidBody2D) + { + RuntimeManager.SetListenerLocation(ListenerNumber, gameObject, rigidBody2D, attenuationObject); + } + else +#endif + { + RuntimeManager.SetListenerLocation(ListenerNumber, gameObject, attenuationObject); + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/StudioListener.cs.meta b/Assets/Plugins/FMOD/src/StudioListener.cs.meta new file mode 100644 index 0000000..4cb2969 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioListener.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 86c6556701af9e04380698b89f691b6e +timeCreated: 1449016511 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 80 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs b/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs new file mode 100644 index 0000000..3c94f78 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs @@ -0,0 +1,63 @@ +using System; +using UnityEngine; + +namespace FMODUnity +{ + [Serializable] + public class EmitterRef + { + public StudioEventEmitter Target; + public ParamRef[] Params; + } + + [AddComponentMenu("FMOD Studio/FMOD Studio Parameter Trigger")] + public class StudioParameterTrigger: EventHandler + { + public EmitterRef[] Emitters; + public EmitterGameEvent TriggerEvent; + + private void Awake() + { + for (int i = 0; i < Emitters.Length; i++) + { + var emitterRef = Emitters[i]; + if (emitterRef.Target != null && !emitterRef.Target.EventReference.IsNull) + { + FMOD.Studio.EventDescription eventDesc = RuntimeManager.GetEventDescription(emitterRef.Target.EventReference); + if (eventDesc.isValid()) + { + for (int j = 0; j < Emitters[i].Params.Length; j++) + { + FMOD.Studio.PARAMETER_DESCRIPTION param; + eventDesc.getParameterDescriptionByName(emitterRef.Params[j].Name, out param); + emitterRef.Params[j].ID = param.id; + } + } + } + } + } + + protected override void HandleGameEvent(EmitterGameEvent gameEvent) + { + if (TriggerEvent == gameEvent) + { + TriggerParameters(); + } + } + + public void TriggerParameters() + { + for (int i = 0; i < Emitters.Length; i++) + { + var emitterRef = Emitters[i]; + if (emitterRef.Target != null && emitterRef.Target.EventInstance.isValid()) + { + for (int j = 0; j < Emitters[i].Params.Length; j++) + { + emitterRef.Target.EventInstance.setParameterByID(Emitters[i].Params[j].ID, Emitters[i].Params[j].Value); + } + } + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs.meta b/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs.meta new file mode 100644 index 0000000..be920b2 --- /dev/null +++ b/Assets/Plugins/FMOD/src/StudioParameterTrigger.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 744a208c85da6d04c861d81b992e4ead +timeCreated: 1451968823 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/fmod.cs b/Assets/Plugins/FMOD/src/fmod.cs new file mode 100644 index 0000000..5b88ec1 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod.cs @@ -0,0 +1,4084 @@ +/* ======================================================================================== */ +/* FMOD Core API - C# wrapper. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/docs/2.02/api/core-api.html */ +/* ======================================================================================== */ + +using System; +using System.Text; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +namespace FMOD +{ + /* + FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion + 0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number. + */ + public partial class VERSION + { + public const int number = 0x00020221; +#if !UNITY_2019_4_OR_NEWER + public const string dll = "fmod"; +#endif + } + + public class CONSTANTS + { + public const int MAX_CHANNEL_WIDTH = 32; + public const int MAX_LISTENERS = 8; + public const int REVERB_MAXINSTANCES = 4; + public const int MAX_SYSTEMS = 8; + } + + /* + FMOD core types + */ + public enum RESULT : int + { + OK, + ERR_BADCOMMAND, + ERR_CHANNEL_ALLOC, + ERR_CHANNEL_STOLEN, + ERR_DMA, + ERR_DSP_CONNECTION, + ERR_DSP_DONTPROCESS, + ERR_DSP_FORMAT, + ERR_DSP_INUSE, + ERR_DSP_NOTFOUND, + ERR_DSP_RESERVED, + ERR_DSP_SILENCE, + ERR_DSP_TYPE, + ERR_FILE_BAD, + ERR_FILE_COULDNOTSEEK, + ERR_FILE_DISKEJECTED, + ERR_FILE_EOF, + ERR_FILE_ENDOFDATA, + ERR_FILE_NOTFOUND, + ERR_FORMAT, + ERR_HEADER_MISMATCH, + ERR_HTTP, + ERR_HTTP_ACCESS, + ERR_HTTP_PROXY_AUTH, + ERR_HTTP_SERVER_ERROR, + ERR_HTTP_TIMEOUT, + ERR_INITIALIZATION, + ERR_INITIALIZED, + ERR_INTERNAL, + ERR_INVALID_FLOAT, + ERR_INVALID_HANDLE, + ERR_INVALID_PARAM, + ERR_INVALID_POSITION, + ERR_INVALID_SPEAKER, + ERR_INVALID_SYNCPOINT, + ERR_INVALID_THREAD, + ERR_INVALID_VECTOR, + ERR_MAXAUDIBLE, + ERR_MEMORY, + ERR_MEMORY_CANTPOINT, + ERR_NEEDS3D, + ERR_NEEDSHARDWARE, + ERR_NET_CONNECT, + ERR_NET_SOCKET_ERROR, + ERR_NET_URL, + ERR_NET_WOULD_BLOCK, + ERR_NOTREADY, + ERR_OUTPUT_ALLOCATED, + ERR_OUTPUT_CREATEBUFFER, + ERR_OUTPUT_DRIVERCALL, + ERR_OUTPUT_FORMAT, + ERR_OUTPUT_INIT, + ERR_OUTPUT_NODRIVERS, + ERR_PLUGIN, + ERR_PLUGIN_MISSING, + ERR_PLUGIN_RESOURCE, + ERR_PLUGIN_VERSION, + ERR_RECORD, + ERR_REVERB_CHANNELGROUP, + ERR_REVERB_INSTANCE, + ERR_SUBSOUNDS, + ERR_SUBSOUND_ALLOCATED, + ERR_SUBSOUND_CANTMOVE, + ERR_TAGNOTFOUND, + ERR_TOOMANYCHANNELS, + ERR_TRUNCATED, + ERR_UNIMPLEMENTED, + ERR_UNINITIALIZED, + ERR_UNSUPPORTED, + ERR_VERSION, + ERR_EVENT_ALREADY_LOADED, + ERR_EVENT_LIVEUPDATE_BUSY, + ERR_EVENT_LIVEUPDATE_MISMATCH, + ERR_EVENT_LIVEUPDATE_TIMEOUT, + ERR_EVENT_NOTFOUND, + ERR_STUDIO_UNINITIALIZED, + ERR_STUDIO_NOT_LOADED, + ERR_INVALID_STRING, + ERR_ALREADY_LOCKED, + ERR_NOT_LOCKED, + ERR_RECORD_DISCONNECTED, + ERR_TOOMANYSAMPLES, + } + + public enum CHANNELCONTROL_TYPE : int + { + CHANNEL, + CHANNELGROUP, + MAX + } + + [StructLayout(LayoutKind.Sequential)] + public struct VECTOR + { + public float x; + public float y; + public float z; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ATTRIBUTES_3D + { + public VECTOR position; + public VECTOR velocity; + public VECTOR forward; + public VECTOR up; + } + + [StructLayout(LayoutKind.Sequential)] + public partial struct GUID + { + public int Data1; + public int Data2; + public int Data3; + public int Data4; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ASYNCREADINFO + { + public IntPtr handle; + public uint offset; + public uint sizebytes; + public int priority; + + public IntPtr userdata; + public IntPtr buffer; + public uint bytesread; + public FILE_ASYNCDONE_FUNC done; + } + + public enum OUTPUTTYPE : int + { + AUTODETECT, + + UNKNOWN, + NOSOUND, + WAVWRITER, + NOSOUND_NRT, + WAVWRITER_NRT, + + WASAPI, + ASIO, + PULSEAUDIO, + ALSA, + COREAUDIO, + AUDIOTRACK, + OPENSL, + AUDIOOUT, + AUDIO3D, + WEBAUDIO, + NNAUDIO, + WINSONIC, + AAUDIO, + AUDIOWORKLET, + PHASE, + OHAUDIO, + + MAX, + } + + public enum PORT_TYPE : int + { + MUSIC, + COPYRIGHT_MUSIC, + VOICE, + CONTROLLER, + PERSONAL, + VIBRATION, + AUX, + + MAX + } + + public enum DEBUG_MODE : int + { + TTY, + FILE, + CALLBACK, + } + + [Flags] + public enum DEBUG_FLAGS : uint + { + NONE = 0x00000000, + ERROR = 0x00000001, + WARNING = 0x00000002, + LOG = 0x00000004, + + TYPE_MEMORY = 0x00000100, + TYPE_FILE = 0x00000200, + TYPE_CODEC = 0x00000400, + TYPE_TRACE = 0x00000800, + + DISPLAY_TIMESTAMPS = 0x00010000, + DISPLAY_LINENUMBERS = 0x00020000, + DISPLAY_THREAD = 0x00040000, + } + + [Flags] + public enum MEMORY_TYPE : uint + { + NORMAL = 0x00000000, + STREAM_FILE = 0x00000001, + STREAM_DECODE = 0x00000002, + SAMPLEDATA = 0x00000004, + DSP_BUFFER = 0x00000008, + PLUGIN = 0x00000010, + PERSISTENT = 0x00200000, + ALL = 0xFFFFFFFF + } + + public enum SPEAKERMODE : int + { + DEFAULT, + RAW, + MONO, + STEREO, + QUAD, + SURROUND, + _5POINT1, + _7POINT1, + _7POINT1POINT4, + + MAX, + } + + public enum SPEAKER : int + { + NONE = -1, + FRONT_LEFT, + FRONT_RIGHT, + FRONT_CENTER, + LOW_FREQUENCY, + SURROUND_LEFT, + SURROUND_RIGHT, + BACK_LEFT, + BACK_RIGHT, + TOP_FRONT_LEFT, + TOP_FRONT_RIGHT, + TOP_BACK_LEFT, + TOP_BACK_RIGHT, + + MAX, + } + + [Flags] + public enum CHANNELMASK : uint + { + FRONT_LEFT = 0x00000001, + FRONT_RIGHT = 0x00000002, + FRONT_CENTER = 0x00000004, + LOW_FREQUENCY = 0x00000008, + SURROUND_LEFT = 0x00000010, + SURROUND_RIGHT = 0x00000020, + BACK_LEFT = 0x00000040, + BACK_RIGHT = 0x00000080, + BACK_CENTER = 0x00000100, + + MONO = (FRONT_LEFT), + STEREO = (FRONT_LEFT | FRONT_RIGHT), + LRC = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER), + QUAD = (FRONT_LEFT | FRONT_RIGHT | SURROUND_LEFT | SURROUND_RIGHT), + SURROUND = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT), + _5POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT), + _5POINT1_REARS = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | BACK_LEFT | BACK_RIGHT), + _7POINT0 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT), + _7POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT) + } + + public enum CHANNELORDER : int + { + DEFAULT, + WAVEFORMAT, + PROTOOLS, + ALLMONO, + ALLSTEREO, + ALSA, + + MAX, + } + + public enum PLUGINTYPE : int + { + OUTPUT, + CODEC, + DSP, + + MAX, + } + + [StructLayout(LayoutKind.Sequential)] + public struct PLUGINLIST + { + PLUGINTYPE type; + IntPtr description; + } + + [Flags] + public enum INITFLAGS : uint + { + NORMAL = 0x00000000, + STREAM_FROM_UPDATE = 0x00000001, + MIX_FROM_UPDATE = 0x00000002, + _3D_RIGHTHANDED = 0x00000004, + CLIP_OUTPUT = 0x00000008, + CHANNEL_LOWPASS = 0x00000100, + CHANNEL_DISTANCEFILTER = 0x00000200, + PROFILE_ENABLE = 0x00010000, + VOL0_BECOMES_VIRTUAL = 0x00020000, + GEOMETRY_USECLOSEST = 0x00040000, + PREFER_DOLBY_DOWNMIX = 0x00080000, + THREAD_UNSAFE = 0x00100000, + PROFILE_METER_ALL = 0x00200000, + MEMORY_TRACKING = 0x00400000, + } + + public enum SOUND_TYPE : int + { + UNKNOWN, + AIFF, + ASF, + DLS, + FLAC, + FSB, + IT, + MIDI, + MOD, + MPEG, + OGGVORBIS, + PLAYLIST, + RAW, + S3M, + USER, + WAV, + XM, + XMA, + AUDIOQUEUE, + AT9, + VORBIS, + MEDIA_FOUNDATION, + MEDIACODEC, + FADPCM, + OPUS, + + MAX, + } + + public enum SOUND_FORMAT : int + { + NONE, + PCM8, + PCM16, + PCM24, + PCM32, + PCMFLOAT, + BITSTREAM, + + MAX + } + + [Flags] + public enum MODE : uint + { + DEFAULT = 0x00000000, + LOOP_OFF = 0x00000001, + LOOP_NORMAL = 0x00000002, + LOOP_BIDI = 0x00000004, + _2D = 0x00000008, + _3D = 0x00000010, + CREATESTREAM = 0x00000080, + CREATESAMPLE = 0x00000100, + CREATECOMPRESSEDSAMPLE = 0x00000200, + OPENUSER = 0x00000400, + OPENMEMORY = 0x00000800, + OPENMEMORY_POINT = 0x10000000, + OPENRAW = 0x00001000, + OPENONLY = 0x00002000, + ACCURATETIME = 0x00004000, + MPEGSEARCH = 0x00008000, + NONBLOCKING = 0x00010000, + UNIQUE = 0x00020000, + _3D_HEADRELATIVE = 0x00040000, + _3D_WORLDRELATIVE = 0x00080000, + _3D_INVERSEROLLOFF = 0x00100000, + _3D_LINEARROLLOFF = 0x00200000, + _3D_LINEARSQUAREROLLOFF = 0x00400000, + _3D_INVERSETAPEREDROLLOFF = 0x00800000, + _3D_CUSTOMROLLOFF = 0x04000000, + _3D_IGNOREGEOMETRY = 0x40000000, + IGNORETAGS = 0x02000000, + LOWMEM = 0x08000000, + VIRTUAL_PLAYFROMSTART = 0x80000000 + } + + public enum OPENSTATE : int + { + READY = 0, + LOADING, + ERROR, + CONNECTING, + BUFFERING, + SEEKING, + PLAYING, + SETPOSITION, + + MAX, + } + + public enum SOUNDGROUP_BEHAVIOR : int + { + BEHAVIOR_FAIL, + BEHAVIOR_MUTE, + BEHAVIOR_STEALLOWEST, + + MAX, + } + + public enum CHANNELCONTROL_CALLBACK_TYPE : int + { + END, + VIRTUALVOICE, + SYNCPOINT, + OCCLUSION, + + MAX, + } + + public struct CHANNELCONTROL_DSP_INDEX + { + public const int HEAD = -1; + public const int FADER = -2; + public const int TAIL = -3; + } + + public enum ERRORCALLBACK_INSTANCETYPE : int + { + NONE, + SYSTEM, + CHANNEL, + CHANNELGROUP, + CHANNELCONTROL, + SOUND, + SOUNDGROUP, + DSP, + DSPCONNECTION, + GEOMETRY, + REVERB3D, + STUDIO_SYSTEM, + STUDIO_EVENTDESCRIPTION, + STUDIO_EVENTINSTANCE, + STUDIO_PARAMETERINSTANCE, + STUDIO_BUS, + STUDIO_VCA, + STUDIO_BANK, + STUDIO_COMMANDREPLAY + } + + [StructLayout(LayoutKind.Sequential)] + public struct ERRORCALLBACK_INFO + { + public RESULT result; + public ERRORCALLBACK_INSTANCETYPE instancetype; + public IntPtr instance; + public StringWrapper functionname; + public StringWrapper functionparams; + } + + [StructLayout(LayoutKind.Sequential)] + public struct CPU_USAGE + { + public float dsp; /* DSP mixing CPU usage. */ + public float stream; /* Streaming engine CPU usage. */ + public float geometry; /* Geometry engine CPU usage. */ + public float update; /* System::update CPU usage. */ + public float convolution1; /* Convolution reverb processing thread #1 CPU usage */ + public float convolution2; /* Convolution reverb processing thread #2 CPU usage */ + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_DATA_PARAMETER_INFO + { + public IntPtr data; + public uint length; + public int index; + } + + [Flags] + public enum SYSTEM_CALLBACK_TYPE : uint + { + DEVICELISTCHANGED = 0x00000001, + DEVICELOST = 0x00000002, + MEMORYALLOCATIONFAILED = 0x00000004, + THREADCREATED = 0x00000008, + BADDSPCONNECTION = 0x00000010, + PREMIX = 0x00000020, + POSTMIX = 0x00000040, + ERROR = 0x00000080, + MIDMIX = 0x00000100, + THREADDESTROYED = 0x00000200, + PREUPDATE = 0x00000400, + POSTUPDATE = 0x00000800, + RECORDLISTCHANGED = 0x00001000, + BUFFEREDNOMIX = 0x00002000, + DEVICEREINITIALIZE = 0x00004000, + OUTPUTUNDERRUN = 0x00008000, + RECORDPOSITIONCHANGED = 0x00010000, + ALL = 0xFFFFFFFF, + } + + /* + FMOD Callbacks + */ + public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message); + public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata); + public delegate RESULT CHANNELCONTROL_CALLBACK (IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2); + public delegate RESULT DSP_CALLBACK (IntPtr dsp, DSP_CALLBACK_TYPE type, IntPtr data); + public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result); + public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen); + public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype); + public delegate RESULT FILE_OPEN_CALLBACK (IntPtr name, ref uint filesize, ref IntPtr handle, IntPtr userdata); + public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata); + public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata); + public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata); + public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata); + public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata); + public delegate void FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result); + public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr); + public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance); + + public enum DSP_RESAMPLER : int + { + DEFAULT, + NOINTERP, + LINEAR, + CUBIC, + SPLINE, + + MAX, + } + + public enum DSP_CALLBACK_TYPE : int + { + DATAPARAMETERRELEASE, + + MAX, + } + + public enum DSPCONNECTION_TYPE : int + { + STANDARD, + SIDECHAIN, + SEND, + SEND_SIDECHAIN, + + MAX, + } + + public enum TAGTYPE : int + { + UNKNOWN = 0, + ID3V1, + ID3V2, + VORBISCOMMENT, + SHOUTCAST, + ICECAST, + ASF, + MIDI, + PLAYLIST, + FMOD, + USER, + + MAX + } + + public enum TAGDATATYPE : int + { + BINARY = 0, + INT, + FLOAT, + STRING, + STRING_UTF16, + STRING_UTF16BE, + STRING_UTF8, + + MAX + } + + [StructLayout(LayoutKind.Sequential)] + public struct TAG + { + public TAGTYPE type; + public TAGDATATYPE datatype; + public StringWrapper name; + public IntPtr data; + public uint datalen; + public bool updated; + } + + [Flags] + public enum TIMEUNIT : uint + { + MS = 0x00000001, + PCM = 0x00000002, + PCMBYTES = 0x00000004, + RAWBYTES = 0x00000008, + PCMFRACTION = 0x00000010, + MODORDER = 0x00000100, + MODROW = 0x00000200, + MODPATTERN = 0x00000400, + } + + public struct PORT_INDEX + { + public const ulong NONE = 0xFFFFFFFFFFFFFFFF; + public const ulong FLAG_VR_CONTROLLER = 0x1000000000000000; + } + + [StructLayout(LayoutKind.Sequential)] + public struct CREATESOUNDEXINFO + { + public int cbsize; + public uint length; + public uint fileoffset; + public int numchannels; + public int defaultfrequency; + public SOUND_FORMAT format; + public uint decodebuffersize; + public int initialsubsound; + public int numsubsounds; + public IntPtr inclusionlist; + public int inclusionlistnum; + public IntPtr pcmreadcallback_internal; + public IntPtr pcmsetposcallback_internal; + public IntPtr nonblockcallback_internal; + public IntPtr dlsname; + public IntPtr encryptionkey; + public int maxpolyphony; + public IntPtr userdata; + public SOUND_TYPE suggestedsoundtype; + public IntPtr fileuseropen_internal; + public IntPtr fileuserclose_internal; + public IntPtr fileuserread_internal; + public IntPtr fileuserseek_internal; + public IntPtr fileuserasyncread_internal; + public IntPtr fileuserasynccancel_internal; + public IntPtr fileuserdata; + public int filebuffersize; + public CHANNELORDER channelorder; + public IntPtr initialsoundgroup; + public uint initialseekposition; + public TIMEUNIT initialseekpostype; + public int ignoresetfilesystem; + public uint audioqueuepolicy; + public uint minmidigranularity; + public int nonblockthreadid; + public IntPtr fsbguid; + + public SOUND_PCMREAD_CALLBACK pcmreadcallback + { + set { pcmreadcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return pcmreadcallback_internal == IntPtr.Zero ? null : (SOUND_PCMREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmreadcallback_internal, typeof(SOUND_PCMREAD_CALLBACK)); } + } + public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback + { + set { pcmsetposcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return pcmsetposcallback_internal == IntPtr.Zero ? null : (SOUND_PCMSETPOS_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmsetposcallback_internal, typeof(SOUND_PCMSETPOS_CALLBACK)); } + } + public SOUND_NONBLOCK_CALLBACK nonblockcallback + { + set { nonblockcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return nonblockcallback_internal == IntPtr.Zero ? null : (SOUND_NONBLOCK_CALLBACK)Marshal.GetDelegateForFunctionPointer(nonblockcallback_internal, typeof(SOUND_NONBLOCK_CALLBACK)); } + } + public FILE_OPEN_CALLBACK fileuseropen + { + set { fileuseropen_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuseropen_internal == IntPtr.Zero ? null : (FILE_OPEN_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuseropen_internal, typeof(FILE_OPEN_CALLBACK)); } + } + public FILE_CLOSE_CALLBACK fileuserclose + { + set { fileuserclose_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuserclose_internal == IntPtr.Zero ? null : (FILE_CLOSE_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserclose_internal, typeof(FILE_CLOSE_CALLBACK)); } + } + public FILE_READ_CALLBACK fileuserread + { + set { fileuserread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuserread_internal == IntPtr.Zero ? null : (FILE_READ_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserread_internal, typeof(FILE_READ_CALLBACK)); } + } + public FILE_SEEK_CALLBACK fileuserseek + { + set { fileuserseek_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuserseek_internal == IntPtr.Zero ? null : (FILE_SEEK_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserseek_internal, typeof(FILE_SEEK_CALLBACK)); } + } + public FILE_ASYNCREAD_CALLBACK fileuserasyncread + { + set { fileuserasyncread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuserasyncread_internal == IntPtr.Zero ? null : (FILE_ASYNCREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasyncread_internal, typeof(FILE_ASYNCREAD_CALLBACK)); } + } + public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel + { + set { fileuserasynccancel_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } + get { return fileuserasynccancel_internal == IntPtr.Zero ? null : (FILE_ASYNCCANCEL_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasynccancel_internal, typeof(FILE_ASYNCCANCEL_CALLBACK)); } + } + + } + +#pragma warning disable 414 + [StructLayout(LayoutKind.Sequential)] + public struct REVERB_PROPERTIES + { + public float DecayTime; + public float EarlyDelay; + public float LateDelay; + public float HFReference; + public float HFDecayRatio; + public float Diffusion; + public float Density; + public float LowShelfFrequency; + public float LowShelfGain; + public float HighCut; + public float EarlyLateMix; + public float WetLevel; + + #region wrapperinternal + public REVERB_PROPERTIES(float decayTime, float earlyDelay, float lateDelay, float hfReference, + float hfDecayRatio, float diffusion, float density, float lowShelfFrequency, float lowShelfGain, + float highCut, float earlyLateMix, float wetLevel) + { + DecayTime = decayTime; + EarlyDelay = earlyDelay; + LateDelay = lateDelay; + HFReference = hfReference; + HFDecayRatio = hfDecayRatio; + Diffusion = diffusion; + Density = density; + LowShelfFrequency = lowShelfFrequency; + LowShelfGain = lowShelfGain; + HighCut = highCut; + EarlyLateMix = earlyLateMix; + WetLevel = wetLevel; + } + #endregion + } +#pragma warning restore 414 + + public class PRESET + { + public static REVERB_PROPERTIES OFF() { return new REVERB_PROPERTIES( 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f );} + public static REVERB_PROPERTIES GENERIC() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f );} + public static REVERB_PROPERTIES PADDEDCELL() { return new REVERB_PROPERTIES( 170, 1, 2, 5000, 10, 100, 100, 250, 0, 160, 84, -7.8f );} + public static REVERB_PROPERTIES ROOM() { return new REVERB_PROPERTIES( 400, 2, 3, 5000, 83, 100, 100, 250, 0, 6050, 88, -9.4f );} + public static REVERB_PROPERTIES BATHROOM() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 54, 100, 60, 250, 0, 2900, 83, 0.5f );} + public static REVERB_PROPERTIES LIVINGROOM() { return new REVERB_PROPERTIES( 500, 3, 4, 5000, 10, 100, 100, 250, 0, 160, 58, -19.0f );} + public static REVERB_PROPERTIES STONEROOM() { return new REVERB_PROPERTIES( 2300, 12, 17, 5000, 64, 100, 100, 250, 0, 7800, 71, -8.5f );} + public static REVERB_PROPERTIES AUDITORIUM() { return new REVERB_PROPERTIES( 4300, 20, 30, 5000, 59, 100, 100, 250, 0, 5850, 64, -11.7f );} + public static REVERB_PROPERTIES CONCERTHALL() { return new REVERB_PROPERTIES( 3900, 20, 29, 5000, 70, 100, 100, 250, 0, 5650, 80, -9.8f );} + public static REVERB_PROPERTIES CAVE() { return new REVERB_PROPERTIES( 2900, 15, 22, 5000, 100, 100, 100, 250, 0, 20000, 59, -11.3f );} + public static REVERB_PROPERTIES ARENA() { return new REVERB_PROPERTIES( 7200, 20, 30, 5000, 33, 100, 100, 250, 0, 4500, 80, -9.6f );} + public static REVERB_PROPERTIES HANGAR() { return new REVERB_PROPERTIES( 10000, 20, 30, 5000, 23, 100, 100, 250, 0, 3400, 72, -7.4f );} + public static REVERB_PROPERTIES CARPETTEDHALLWAY() { return new REVERB_PROPERTIES( 300, 2, 30, 5000, 10, 100, 100, 250, 0, 500, 56, -24.0f );} + public static REVERB_PROPERTIES HALLWAY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 59, 100, 100, 250, 0, 7800, 87, -5.5f );} + public static REVERB_PROPERTIES STONECORRIDOR() { return new REVERB_PROPERTIES( 270, 13, 20, 5000, 79, 100, 100, 250, 0, 9000, 86, -6.0f );} + public static REVERB_PROPERTIES ALLEY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 86, 100, 100, 250, 0, 8300, 80, -9.8f );} + public static REVERB_PROPERTIES FOREST() { return new REVERB_PROPERTIES( 1500, 162, 88, 5000, 54, 79, 100, 250, 0, 760, 94, -12.3f );} + public static REVERB_PROPERTIES CITY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 67, 50, 100, 250, 0, 4050, 66, -26.0f );} + public static REVERB_PROPERTIES MOUNTAINS() { return new REVERB_PROPERTIES( 1500, 300, 100, 5000, 21, 27, 100, 250, 0, 1220, 82, -24.0f );} + public static REVERB_PROPERTIES QUARRY() { return new REVERB_PROPERTIES( 1500, 61, 25, 5000, 83, 100, 100, 250, 0, 3400, 100, -5.0f );} + public static REVERB_PROPERTIES PLAIN() { return new REVERB_PROPERTIES( 1500, 179, 100, 5000, 50, 21, 100, 250, 0, 1670, 65, -28.0f );} + public static REVERB_PROPERTIES PARKINGLOT() { return new REVERB_PROPERTIES( 1700, 8, 12, 5000, 100, 100, 100, 250, 0, 20000, 56, -19.5f );} + public static REVERB_PROPERTIES SEWERPIPE() { return new REVERB_PROPERTIES( 2800, 14, 21, 5000, 14, 80, 60, 250, 0, 3400, 66, 1.2f );} + public static REVERB_PROPERTIES UNDERWATER() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 10, 100, 100, 250, 0, 500, 92, 7.0f );} + } + + [StructLayout(LayoutKind.Sequential)] + public struct ADVANCEDSETTINGS + { + public int cbSize; + public int maxMPEGCodecs; + public int maxADPCMCodecs; + public int maxXMACodecs; + public int maxVorbisCodecs; + public int maxAT9Codecs; + public int maxFADPCMCodecs; + public int maxPCMCodecs; + public int ASIONumChannels; + public IntPtr ASIOChannelList; + public IntPtr ASIOSpeakerList; + public float vol0virtualvol; + public uint defaultDecodeBufferSize; + public ushort profilePort; + public uint geometryMaxFadeTime; + public float distanceFilterCenterFreq; + public int reverb3Dinstance; + public int DSPBufferPoolSize; + public DSP_RESAMPLER resamplerMethod; + public uint randomSeed; + public int maxConvolutionThreads; + public int maxOpusCodecs; + public int maxSpatialObjects; + } + + [Flags] + public enum DRIVER_STATE : uint + { + CONNECTED = 0x00000001, + DEFAULT = 0x00000002, + } + + public enum THREAD_PRIORITY : int + { + /* Platform specific priority range */ + PLATFORM_MIN = -32 * 1024, + PLATFORM_MAX = 32 * 1024, + + /* Platform agnostic priorities, maps internally to platform specific value */ + DEFAULT = PLATFORM_MIN - 1, + LOW = PLATFORM_MIN - 2, + MEDIUM = PLATFORM_MIN - 3, + HIGH = PLATFORM_MIN - 4, + VERY_HIGH = PLATFORM_MIN - 5, + EXTREME = PLATFORM_MIN - 6, + CRITICAL = PLATFORM_MIN - 7, + + /* Thread defaults */ + MIXER = EXTREME, + FEEDER = CRITICAL, + STREAM = VERY_HIGH, + FILE = HIGH, + NONBLOCKING = HIGH, + RECORD = HIGH, + GEOMETRY = LOW, + PROFILER = MEDIUM, + STUDIO_UPDATE = MEDIUM, + STUDIO_LOAD_BANK = MEDIUM, + STUDIO_LOAD_SAMPLE = MEDIUM, + CONVOLUTION1 = VERY_HIGH, + CONVOLUTION2 = VERY_HIGH + + } + + public enum THREAD_STACK_SIZE : uint + { + DEFAULT = 0, + MIXER = 80 * 1024, + FEEDER = 16 * 1024, + STREAM = 96 * 1024, + FILE = 64 * 1024, + NONBLOCKING = 112 * 1024, + RECORD = 16 * 1024, + GEOMETRY = 48 * 1024, + PROFILER = 128 * 1024, + STUDIO_UPDATE = 96 * 1024, + STUDIO_LOAD_BANK = 96 * 1024, + STUDIO_LOAD_SAMPLE = 96 * 1024, + CONVOLUTION1 = 16 * 1024, + CONVOLUTION2 = 16 * 1024 + } + + [Flags] + public enum THREAD_AFFINITY : long + { + /* Platform agnostic thread groupings */ + GROUP_DEFAULT = 0x4000000000000000, + GROUP_A = 0x4000000000000001, + GROUP_B = 0x4000000000000002, + GROUP_C = 0x4000000000000003, + + /* Thread defaults */ + MIXER = GROUP_A, + FEEDER = GROUP_C, + STREAM = GROUP_C, + FILE = GROUP_C, + NONBLOCKING = GROUP_C, + RECORD = GROUP_C, + GEOMETRY = GROUP_C, + PROFILER = GROUP_C, + STUDIO_UPDATE = GROUP_B, + STUDIO_LOAD_BANK = GROUP_C, + STUDIO_LOAD_SAMPLE = GROUP_C, + CONVOLUTION1 = GROUP_C, + CONVOLUTION2 = GROUP_C, + + /* Core mask, valid up to 1 << 61 */ + CORE_ALL = 0, + CORE_0 = 1 << 0, + CORE_1 = 1 << 1, + CORE_2 = 1 << 2, + CORE_3 = 1 << 3, + CORE_4 = 1 << 4, + CORE_5 = 1 << 5, + CORE_6 = 1 << 6, + CORE_7 = 1 << 7, + CORE_8 = 1 << 8, + CORE_9 = 1 << 9, + CORE_10 = 1 << 10, + CORE_11 = 1 << 11, + CORE_12 = 1 << 12, + CORE_13 = 1 << 13, + CORE_14 = 1 << 14, + CORE_15 = 1 << 15 + } + + public enum THREAD_TYPE : int + { + MIXER, + FEEDER, + STREAM, + FILE, + NONBLOCKING, + RECORD, + GEOMETRY, + PROFILER, + STUDIO_UPDATE, + STUDIO_LOAD_BANK, + STUDIO_LOAD_SAMPLE, + CONVOLUTION1, + CONVOLUTION2, + + MAX + } + + /* + FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started. + */ + public struct Factory + { + public static RESULT System_Create(out System system) + { + return FMOD5_System_Create(out system.handle, VERSION.number); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Create(out IntPtr system, uint headerversion); + + #endregion + } + + /* + FMOD global system functions (optional). + */ + public struct Memory + { + public static RESULT Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags = MEMORY_TYPE.ALL) + { + return FMOD5_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); + } + + public static RESULT GetStats(out int currentalloced, out int maxalloced, bool blocking = true) + { + return FMOD5_Memory_GetStats(out currentalloced, out maxalloced, blocking); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Memory_Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Memory_GetStats (out int currentalloced, out int maxalloced, bool blocking); + + #endregion + } + + public struct Debug + { + public static RESULT Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode = DEBUG_MODE.TTY, DEBUG_CALLBACK callback = null, string filename = null) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Debug_Initialize(flags, mode, callback, encoder.byteFromStringUTF8(filename)); + } + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Debug_Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode, DEBUG_CALLBACK callback, byte[] filename); + + #endregion + } + + public struct Thread + { + public static RESULT SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity = THREAD_AFFINITY.GROUP_DEFAULT, THREAD_PRIORITY priority = THREAD_PRIORITY.DEFAULT, THREAD_STACK_SIZE stacksize = THREAD_STACK_SIZE.DEFAULT) + { + return FMOD5_Thread_SetAttributes(type, affinity, priority, stacksize); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Thread_SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity, THREAD_PRIORITY priority, THREAD_STACK_SIZE stacksize); + #endregion + } + + /* + 'System' API. + */ + public struct System + { + public RESULT release() + { + return FMOD5_System_Release(this.handle); + } + + // Setup functions. + public RESULT setOutput(OUTPUTTYPE output) + { + return FMOD5_System_SetOutput(this.handle, output); + } + public RESULT getOutput(out OUTPUTTYPE output) + { + return FMOD5_System_GetOutput(this.handle, out output); + } + public RESULT getNumDrivers(out int numdrivers) + { + return FMOD5_System_GetNumDrivers(this.handle, out numdrivers); + } + public RESULT getDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels); + using (StringHelper.ThreadSafeEncoding encoding = StringHelper.GetFreeHelper()) + { + name = encoding.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) + { + return FMOD5_System_GetDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels); + } + public RESULT setDriver(int driver) + { + return FMOD5_System_SetDriver(this.handle, driver); + } + public RESULT getDriver(out int driver) + { + return FMOD5_System_GetDriver(this.handle, out driver); + } + public RESULT setSoftwareChannels(int numsoftwarechannels) + { + return FMOD5_System_SetSoftwareChannels(this.handle, numsoftwarechannels); + } + public RESULT getSoftwareChannels(out int numsoftwarechannels) + { + return FMOD5_System_GetSoftwareChannels(this.handle, out numsoftwarechannels); + } + public RESULT setSoftwareFormat(int samplerate, SPEAKERMODE speakermode, int numrawspeakers) + { + return FMOD5_System_SetSoftwareFormat(this.handle, samplerate, speakermode, numrawspeakers); + } + public RESULT getSoftwareFormat(out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers) + { + return FMOD5_System_GetSoftwareFormat(this.handle, out samplerate, out speakermode, out numrawspeakers); + } + public RESULT setDSPBufferSize(uint bufferlength, int numbuffers) + { + return FMOD5_System_SetDSPBufferSize(this.handle, bufferlength, numbuffers); + } + public RESULT getDSPBufferSize(out uint bufferlength, out int numbuffers) + { + return FMOD5_System_GetDSPBufferSize(this.handle, out bufferlength, out numbuffers); + } + public RESULT setFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign) + { + return FMOD5_System_SetFileSystem(this.handle, useropen, userclose, userread, userseek, userasyncread, userasynccancel, blockalign); + } + public RESULT attachFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek) + { + return FMOD5_System_AttachFileSystem(this.handle, useropen, userclose, userread, userseek); + } + public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings) + { + settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD5_System_SetAdvancedSettings(this.handle, ref settings); + } + public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings) + { + settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD5_System_GetAdvancedSettings(this.handle, ref settings); + } + public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL) + { + return FMOD5_System_SetCallback(this.handle, callback, callbackmask); + } + + // Plug-in support. + public RESULT setPluginPath(string path) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_SetPluginPath(this.handle, encoder.byteFromStringUTF8(path)); + } + } + public RESULT loadPlugin(string filename, out uint handle, uint priority = 0) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_LoadPlugin(this.handle, encoder.byteFromStringUTF8(filename), out handle, priority); + } + } + public RESULT unloadPlugin(uint handle) + { + return FMOD5_System_UnloadPlugin(this.handle, handle); + } + public RESULT getNumNestedPlugins(uint handle, out int count) + { + return FMOD5_System_GetNumNestedPlugins(this.handle, handle, out count); + } + public RESULT getNestedPlugin(uint handle, int index, out uint nestedhandle) + { + return FMOD5_System_GetNestedPlugin(this.handle, handle, index, out nestedhandle); + } + public RESULT getNumPlugins(PLUGINTYPE plugintype, out int numplugins) + { + return FMOD5_System_GetNumPlugins(this.handle, plugintype, out numplugins); + } + public RESULT getPluginHandle(PLUGINTYPE plugintype, int index, out uint handle) + { + return FMOD5_System_GetPluginHandle(this.handle, plugintype, index, out handle); + } + public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out string name, int namelen, out uint version) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, stringMem, namelen, out version); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out uint version) + { + return FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, IntPtr.Zero, 0, out version); + } + public RESULT setOutputByPlugin(uint handle) + { + return FMOD5_System_SetOutputByPlugin(this.handle, handle); + } + public RESULT getOutputByPlugin(out uint handle) + { + return FMOD5_System_GetOutputByPlugin(this.handle, out handle); + } + public RESULT createDSPByPlugin(uint handle, out DSP dsp) + { + return FMOD5_System_CreateDSPByPlugin(this.handle, handle, out dsp.handle); + } + public RESULT getDSPInfoByPlugin(uint handle, out IntPtr description) + { + return FMOD5_System_GetDSPInfoByPlugin(this.handle, handle, out description); + } + public RESULT registerDSP(ref DSP_DESCRIPTION description, out uint handle) + { + return FMOD5_System_RegisterDSP(this.handle, ref description, out handle); + } + + // Init/Close. + public RESULT init(int maxchannels, INITFLAGS flags, IntPtr extradriverdata) + { + return FMOD5_System_Init(this.handle, maxchannels, flags, extradriverdata); + } + public RESULT close() + { + return FMOD5_System_Close(this.handle); + } + + // General post-init system functions. + public RESULT update() + { + return FMOD5_System_Update(this.handle); + } + public RESULT setSpeakerPosition(SPEAKER speaker, float x, float y, bool active) + { + return FMOD5_System_SetSpeakerPosition(this.handle, speaker, x, y, active); + } + public RESULT getSpeakerPosition(SPEAKER speaker, out float x, out float y, out bool active) + { + return FMOD5_System_GetSpeakerPosition(this.handle, speaker, out x, out y, out active); + } + public RESULT setStreamBufferSize(uint filebuffersize, TIMEUNIT filebuffersizetype) + { + return FMOD5_System_SetStreamBufferSize(this.handle, filebuffersize, filebuffersizetype); + } + public RESULT getStreamBufferSize(out uint filebuffersize, out TIMEUNIT filebuffersizetype) + { + return FMOD5_System_GetStreamBufferSize(this.handle, out filebuffersize, out filebuffersizetype); + } + public RESULT set3DSettings(float dopplerscale, float distancefactor, float rolloffscale) + { + return FMOD5_System_Set3DSettings(this.handle, dopplerscale, distancefactor, rolloffscale); + } + public RESULT get3DSettings(out float dopplerscale, out float distancefactor, out float rolloffscale) + { + return FMOD5_System_Get3DSettings(this.handle, out dopplerscale, out distancefactor, out rolloffscale); + } + public RESULT set3DNumListeners(int numlisteners) + { + return FMOD5_System_Set3DNumListeners(this.handle, numlisteners); + } + public RESULT get3DNumListeners(out int numlisteners) + { + return FMOD5_System_Get3DNumListeners(this.handle, out numlisteners); + } + public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up) + { + return FMOD5_System_Set3DListenerAttributes(this.handle, listener, ref pos, ref vel, ref forward, ref up); + } + public RESULT get3DListenerAttributes(int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up) + { + return FMOD5_System_Get3DListenerAttributes(this.handle, listener, out pos, out vel, out forward, out up); + } + public RESULT set3DRolloffCallback(CB_3D_ROLLOFF_CALLBACK callback) + { + return FMOD5_System_Set3DRolloffCallback(this.handle, callback); + } + public RESULT mixerSuspend() + { + return FMOD5_System_MixerSuspend(this.handle); + } + public RESULT mixerResume() + { + return FMOD5_System_MixerResume(this.handle); + } + public RESULT getDefaultMixMatrix(SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop) + { + return FMOD5_System_GetDefaultMixMatrix(this.handle, sourcespeakermode, targetspeakermode, matrix, matrixhop); + } + public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels) + { + return FMOD5_System_GetSpeakerModeChannels(this.handle, mode, out channels); + } + + // System information functions. + public RESULT getVersion(out uint version) + { + return FMOD5_System_GetVersion(this.handle, out version); + } + public RESULT getOutputHandle(out IntPtr handle) + { + return FMOD5_System_GetOutputHandle(this.handle, out handle); + } + public RESULT getChannelsPlaying(out int channels) + { + return FMOD5_System_GetChannelsPlaying(this.handle, out channels, IntPtr.Zero); + } + public RESULT getChannelsPlaying(out int channels, out int realchannels) + { + return FMOD5_System_GetChannelsPlaying(this.handle, out channels, out realchannels); + } + public RESULT getCPUUsage(out CPU_USAGE usage) + { + return FMOD5_System_GetCPUUsage(this.handle, out usage); + } + public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead) + { + return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead); + } + + // Sound/DSP/Channel/FX creation and retrieval. + public RESULT createSound(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateSound(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle); + } + } + public RESULT createSound(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateSound(this.handle, data, mode, ref exinfo, out sound.handle); + } + public RESULT createSound(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateSound(this.handle, name_or_data, mode, ref exinfo, out sound.handle); + } + public RESULT createSound(string name, MODE mode, out Sound sound) + { + CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); + exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); + + return createSound(name, mode, ref exinfo, out sound); + } + public RESULT createStream(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateStream(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle); + } + } + public RESULT createStream(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateStream(this.handle, data, mode, ref exinfo, out sound.handle); + } + public RESULT createStream(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateStream(this.handle, name_or_data, mode, ref exinfo, out sound.handle); + } + public RESULT createStream(string name, MODE mode, out Sound sound) + { + CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); + exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); + + return createStream(name, mode, ref exinfo, out sound); + } + public RESULT createDSP(ref DSP_DESCRIPTION description, out DSP dsp) + { + return FMOD5_System_CreateDSP(this.handle, ref description, out dsp.handle); + } + public RESULT createDSPByType(DSP_TYPE type, out DSP dsp) + { + return FMOD5_System_CreateDSPByType(this.handle, type, out dsp.handle); + } + public RESULT createChannelGroup(string name, out ChannelGroup channelgroup) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateChannelGroup(this.handle, encoder.byteFromStringUTF8(name), out channelgroup.handle); + } + } + public RESULT createSoundGroup(string name, out SoundGroup soundgroup) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateSoundGroup(this.handle, encoder.byteFromStringUTF8(name), out soundgroup.handle); + } + } + public RESULT createReverb3D(out Reverb3D reverb) + { + return FMOD5_System_CreateReverb3D(this.handle, out reverb.handle); + } + public RESULT playSound(Sound sound, ChannelGroup channelgroup, bool paused, out Channel channel) + { + return FMOD5_System_PlaySound(this.handle, sound.handle, channelgroup.handle, paused, out channel.handle); + } + public RESULT playDSP(DSP dsp, ChannelGroup channelgroup, bool paused, out Channel channel) + { + return FMOD5_System_PlayDSP(this.handle, dsp.handle, channelgroup.handle, paused, out channel.handle); + } + public RESULT getChannel(int channelid, out Channel channel) + { + return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle); + } + public RESULT getDSPInfoByType(DSP_TYPE type, out IntPtr description) + { + return FMOD5_System_GetDSPInfoByType(this.handle, type, out description); + } + public RESULT getMasterChannelGroup(out ChannelGroup channelgroup) + { + return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle); + } + public RESULT getMasterSoundGroup(out SoundGroup soundgroup) + { + return FMOD5_System_GetMasterSoundGroup(this.handle, out soundgroup.handle); + } + + // Routing to ports. + public RESULT attachChannelGroupToPort(PORT_TYPE portType, ulong portIndex, ChannelGroup channelgroup, bool passThru = false) + { + return FMOD5_System_AttachChannelGroupToPort(this.handle, portType, portIndex, channelgroup.handle, passThru); + } + public RESULT detachChannelGroupFromPort(ChannelGroup channelgroup) + { + return FMOD5_System_DetachChannelGroupFromPort(this.handle, channelgroup.handle); + } + + // Reverb api. + public RESULT setReverbProperties(int instance, ref REVERB_PROPERTIES prop) + { + return FMOD5_System_SetReverbProperties(this.handle, instance, ref prop); + } + public RESULT getReverbProperties(int instance, out REVERB_PROPERTIES prop) + { + return FMOD5_System_GetReverbProperties(this.handle, instance, out prop); + } + + // System level DSP functionality. + public RESULT lockDSP() + { + return FMOD5_System_LockDSP(this.handle); + } + public RESULT unlockDSP() + { + return FMOD5_System_UnlockDSP(this.handle); + } + + // Recording api + public RESULT getRecordNumDrivers(out int numdrivers, out int numconnected) + { + return FMOD5_System_GetRecordNumDrivers(this.handle, out numdrivers, out numconnected); + } + public RESULT getRecordDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetRecordDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state); + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getRecordDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) + { + return FMOD5_System_GetRecordDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels, out state); + } + public RESULT getRecordPosition(int id, out uint position) + { + return FMOD5_System_GetRecordPosition(this.handle, id, out position); + } + public RESULT recordStart(int id, Sound sound, bool loop) + { + return FMOD5_System_RecordStart(this.handle, id, sound.handle, loop); + } + public RESULT recordStop(int id) + { + return FMOD5_System_RecordStop(this.handle, id); + } + public RESULT isRecording(int id, out bool recording) + { + return FMOD5_System_IsRecording(this.handle, id, out recording); + } + + // Geometry api + public RESULT createGeometry(int maxpolygons, int maxvertices, out Geometry geometry) + { + return FMOD5_System_CreateGeometry(this.handle, maxpolygons, maxvertices, out geometry.handle); + } + public RESULT setGeometrySettings(float maxworldsize) + { + return FMOD5_System_SetGeometrySettings(this.handle, maxworldsize); + } + public RESULT getGeometrySettings(out float maxworldsize) + { + return FMOD5_System_GetGeometrySettings(this.handle, out maxworldsize); + } + public RESULT loadGeometry(IntPtr data, int datasize, out Geometry geometry) + { + return FMOD5_System_LoadGeometry(this.handle, data, datasize, out geometry.handle); + } + public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, out float direct, out float reverb) + { + return FMOD5_System_GetGeometryOcclusion(this.handle, ref listener, ref source, out direct, out reverb); + } + + // Network functions + public RESULT setNetworkProxy(string proxy) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_SetNetworkProxy(this.handle, encoder.byteFromStringUTF8(proxy)); + } + } + public RESULT getNetworkProxy(out string proxy, int proxylen) + { + IntPtr stringMem = Marshal.AllocHGlobal(proxylen); + + RESULT result = FMOD5_System_GetNetworkProxy(this.handle, stringMem, proxylen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + proxy = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT setNetworkTimeout(int timeout) + { + return FMOD5_System_SetNetworkTimeout(this.handle, timeout); + } + public RESULT getNetworkTimeout(out int timeout) + { + return FMOD5_System_GetNetworkTimeout(this.handle, out timeout); + } + + // Userdata set/get + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_System_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_System_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Release (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetOutput (IntPtr system, OUTPUTTYPE output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutput (IntPtr system, out OUTPUTTYPE output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumDrivers (IntPtr system, out int numdrivers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetDriver (IntPtr system, int driver); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDriver (IntPtr system, out int driver); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSoftwareChannels (IntPtr system, int numsoftwarechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSoftwareChannels (IntPtr system, out int numsoftwarechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSoftwareFormat (IntPtr system, int samplerate, SPEAKERMODE speakermode, int numrawspeakers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSoftwareFormat (IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetDSPBufferSize (IntPtr system, uint bufferlength, int numbuffers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPBufferSize (IntPtr system, out uint bufferlength, out int numbuffers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_AttachFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetCallback (IntPtr system, SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetPluginPath (IntPtr system, byte[] path); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LoadPlugin (IntPtr system, byte[] filename, out uint handle, uint priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_UnloadPlugin (IntPtr system, uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumNestedPlugins (IntPtr system, uint handle, out int count); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNestedPlugin (IntPtr system, uint handle, int index, out uint nestedhandle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumPlugins (IntPtr system, PLUGINTYPE plugintype, out int numplugins); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetPluginHandle (IntPtr system, PLUGINTYPE plugintype, int index, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetPluginInfo (IntPtr system, uint handle, out PLUGINTYPE plugintype, IntPtr name, int namelen, out uint version); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetOutputByPlugin (IntPtr system, uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutputByPlugin (IntPtr system, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSPByPlugin (IntPtr system, uint handle, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPInfoByPlugin (IntPtr system, uint handle, out IntPtr description); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RegisterDSP (IntPtr system, ref DSP_DESCRIPTION description, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Init (IntPtr system, int maxchannels, INITFLAGS flags, IntPtr extradriverdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Close (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Update (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSpeakerPosition (IntPtr system, SPEAKER speaker, float x, float y, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSpeakerPosition (IntPtr system, SPEAKER speaker, out float x, out float y, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetStreamBufferSize (IntPtr system, uint filebuffersize, TIMEUNIT filebuffersizetype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetStreamBufferSize (IntPtr system, out uint filebuffersize, out TIMEUNIT filebuffersizetype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DSettings (IntPtr system, float dopplerscale, float distancefactor, float rolloffscale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DSettings (IntPtr system, out float dopplerscale, out float distancefactor, out float rolloffscale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DNumListeners (IntPtr system, int numlisteners); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DNumListeners (IntPtr system, out int numlisteners); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DListenerAttributes (IntPtr system, int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DListenerAttributes (IntPtr system, int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DRolloffCallback (IntPtr system, CB_3D_ROLLOFF_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_MixerSuspend (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_MixerResume (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDefaultMixMatrix (IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSpeakerModeChannels (IntPtr system, SPEAKERMODE mode, out int channels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetVersion (IntPtr system, out uint version); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutputHandle (IntPtr system, out IntPtr handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, out int realchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out CPU_USAGE usage); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSound (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateStream (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateStream (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSP (IntPtr system, ref DSP_DESCRIPTION description, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSPByType (IntPtr system, DSP_TYPE type, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateChannelGroup (IntPtr system, byte[] name, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSoundGroup (IntPtr system, byte[] name, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateReverb3D (IntPtr system, out IntPtr reverb); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_PlaySound (IntPtr system, IntPtr sound, IntPtr channelgroup, bool paused, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_PlayDSP (IntPtr system, IntPtr dsp, IntPtr channelgroup, bool paused, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPInfoByType (IntPtr system, DSP_TYPE type, out IntPtr description); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_AttachChannelGroupToPort (IntPtr system, PORT_TYPE portType, ulong portIndex, IntPtr channelgroup, bool passThru); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_DetachChannelGroupFromPort(IntPtr system, IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetReverbProperties (IntPtr system, int instance, ref REVERB_PROPERTIES prop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetReverbProperties (IntPtr system, int instance, out REVERB_PROPERTIES prop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LockDSP (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_UnlockDSP (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordNumDrivers (IntPtr system, out int numdrivers, out int numconnected); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordPosition (IntPtr system, int id, out uint position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RecordStart (IntPtr system, int id, IntPtr sound, bool loop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RecordStop (IntPtr system, int id); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_IsRecording (IntPtr system, int id, out bool recording); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateGeometry (IntPtr system, int maxpolygons, int maxvertices, out IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetGeometrySettings (IntPtr system, float maxworldsize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetGeometrySettings (IntPtr system, out float maxworldsize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LoadGeometry (IntPtr system, IntPtr data, int datasize, out IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetGeometryOcclusion (IntPtr system, ref VECTOR listener, ref VECTOR source, out float direct, out float reverb); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetNetworkProxy (IntPtr system, byte[] proxy); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNetworkProxy (IntPtr system, IntPtr proxy, int proxylen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetNetworkTimeout (IntPtr system, int timeout); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNetworkTimeout (IntPtr system, out int timeout); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetUserData (IntPtr system, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetUserData (IntPtr system, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public System(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + + /* + 'Sound' API. + */ + public struct Sound + { + public RESULT release() + { + return FMOD5_Sound_Release(this.handle); + } + public RESULT getSystemObject(out System system) + { + return FMOD5_Sound_GetSystemObject(this.handle, out system.handle); + } + + // Standard sound manipulation functions. + public RESULT @lock(uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2) + { + return FMOD5_Sound_Lock(this.handle, offset, length, out ptr1, out ptr2, out len1, out len2); + } + public RESULT unlock(IntPtr ptr1, IntPtr ptr2, uint len1, uint len2) + { + return FMOD5_Sound_Unlock(this.handle, ptr1, ptr2, len1, len2); + } + public RESULT setDefaults(float frequency, int priority) + { + return FMOD5_Sound_SetDefaults(this.handle, frequency, priority); + } + public RESULT getDefaults(out float frequency, out int priority) + { + return FMOD5_Sound_GetDefaults(this.handle, out frequency, out priority); + } + public RESULT set3DMinMaxDistance(float min, float max) + { + return FMOD5_Sound_Set3DMinMaxDistance(this.handle, min, max); + } + public RESULT get3DMinMaxDistance(out float min, out float max) + { + return FMOD5_Sound_Get3DMinMaxDistance(this.handle, out min, out max); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_Sound_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_Sound_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_Sound_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_Sound_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + + public RESULT getSubSound(int index, out Sound subsound) + { + return FMOD5_Sound_GetSubSound(this.handle, index, out subsound.handle); + } + public RESULT getSubSoundParent(out Sound parentsound) + { + return FMOD5_Sound_GetSubSoundParent(this.handle, out parentsound.handle); + } + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_Sound_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getLength(out uint length, TIMEUNIT lengthtype) + { + return FMOD5_Sound_GetLength(this.handle, out length, lengthtype); + } + public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits) + { + return FMOD5_Sound_GetFormat(this.handle, out type, out format, out channels, out bits); + } + public RESULT getNumSubSounds(out int numsubsounds) + { + return FMOD5_Sound_GetNumSubSounds(this.handle, out numsubsounds); + } + public RESULT getNumTags(out int numtags, out int numtagsupdated) + { + return FMOD5_Sound_GetNumTags(this.handle, out numtags, out numtagsupdated); + } + public RESULT getTag(string name, int index, out TAG tag) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Sound_GetTag(this.handle, encoder.byteFromStringUTF8(name), index, out tag); + } + } + public RESULT getOpenState(out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy) + { + return FMOD5_Sound_GetOpenState(this.handle, out openstate, out percentbuffered, out starving, out diskbusy); + } + public RESULT readData(byte[] buffer) + { + return FMOD5_Sound_ReadData(this.handle, buffer, (uint)buffer.Length, IntPtr.Zero); + } + public RESULT readData(byte[] buffer, out uint read) + { + return FMOD5_Sound_ReadData(this.handle, buffer, (uint)buffer.Length, out read); + } + [Obsolete("Use Sound.readData(byte[], out uint) or Sound.readData(byte[]) instead.")] + public RESULT readData(IntPtr buffer, uint length, out uint read) + { + return FMOD5_Sound_ReadData(this.handle, buffer, length, out read); + } + public RESULT seekData(uint pcm) + { + return FMOD5_Sound_SeekData(this.handle, pcm); + } + public RESULT setSoundGroup(SoundGroup soundgroup) + { + return FMOD5_Sound_SetSoundGroup(this.handle, soundgroup.handle); + } + public RESULT getSoundGroup(out SoundGroup soundgroup) + { + return FMOD5_Sound_GetSoundGroup(this.handle, out soundgroup.handle); + } + + // Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks. + public RESULT getNumSyncPoints(out int numsyncpoints) + { + return FMOD5_Sound_GetNumSyncPoints(this.handle, out numsyncpoints); + } + public RESULT getSyncPoint(int index, out IntPtr point) + { + return FMOD5_Sound_GetSyncPoint(this.handle, index, out point); + } + public RESULT getSyncPointInfo(IntPtr point, out string name, int namelen, out uint offset, TIMEUNIT offsettype) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_Sound_GetSyncPointInfo(this.handle, point, stringMem, namelen, out offset, offsettype); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getSyncPointInfo(IntPtr point, out uint offset, TIMEUNIT offsettype) + { + return FMOD5_Sound_GetSyncPointInfo(this.handle, point, IntPtr.Zero, 0, out offset, offsettype); + } + public RESULT addSyncPoint(uint offset, TIMEUNIT offsettype, string name, out IntPtr point) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Sound_AddSyncPoint(this.handle, offset, offsettype, encoder.byteFromStringUTF8(name), out point); + } + } + public RESULT deleteSyncPoint(IntPtr point) + { + return FMOD5_Sound_DeleteSyncPoint(this.handle, point); + } + + // Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time. + public RESULT setMode(MODE mode) + { + return FMOD5_Sound_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_Sound_GetMode(this.handle, out mode); + } + public RESULT setLoopCount(int loopcount) + { + return FMOD5_Sound_SetLoopCount(this.handle, loopcount); + } + public RESULT getLoopCount(out int loopcount) + { + return FMOD5_Sound_GetLoopCount(this.handle, out loopcount); + } + public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Sound_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype); + } + public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Sound_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype); + } + + // For MOD/S3M/XM/IT/MID sequenced formats only. + public RESULT getMusicNumChannels(out int numchannels) + { + return FMOD5_Sound_GetMusicNumChannels(this.handle, out numchannels); + } + public RESULT setMusicChannelVolume(int channel, float volume) + { + return FMOD5_Sound_SetMusicChannelVolume(this.handle, channel, volume); + } + public RESULT getMusicChannelVolume(int channel, out float volume) + { + return FMOD5_Sound_GetMusicChannelVolume(this.handle, channel, out volume); + } + public RESULT setMusicSpeed(float speed) + { + return FMOD5_Sound_SetMusicSpeed(this.handle, speed); + } + public RESULT getMusicSpeed(out float speed) + { + return FMOD5_Sound_GetMusicSpeed(this.handle, out speed); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Sound_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Sound_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Release (IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSystemObject (IntPtr sound, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Lock (IntPtr sound, uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Unlock (IntPtr sound, IntPtr ptr1, IntPtr ptr2, uint len1, uint len2); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetDefaults (IntPtr sound, float frequency, int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetDefaults (IntPtr sound, out float frequency, out int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DMinMaxDistance (IntPtr sound, float min, float max); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DMinMaxDistance (IntPtr sound, out float min, out float max); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DConeSettings (IntPtr sound, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DConeSettings (IntPtr sound, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DCustomRolloff (IntPtr sound, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DCustomRolloff (IntPtr sound, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSubSound (IntPtr sound, int index, out IntPtr subsound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSubSoundParent (IntPtr sound, out IntPtr parentsound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetName (IntPtr sound, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLength (IntPtr sound, out uint length, TIMEUNIT lengthtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetFormat (IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumSubSounds (IntPtr sound, out int numsubsounds); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumTags (IntPtr sound, out int numtags, out int numtagsupdated); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetTag (IntPtr sound, byte[] name, int index, out TAG tag); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetOpenState (IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, byte[] buffer, uint length, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, byte[] buffer, uint length, out uint read); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, IntPtr buffer, uint length, out uint read); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SeekData (IntPtr sound, uint pcm); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetSoundGroup (IntPtr sound, IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSoundGroup (IntPtr sound, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumSyncPoints (IntPtr sound, out int numsyncpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSyncPoint (IntPtr sound, int index, out IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSyncPointInfo (IntPtr sound, IntPtr point, IntPtr name, int namelen, out uint offset, TIMEUNIT offsettype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_AddSyncPoint (IntPtr sound, uint offset, TIMEUNIT offsettype, byte[] name, out IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_DeleteSyncPoint (IntPtr sound, IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMode (IntPtr sound, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMode (IntPtr sound, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetLoopCount (IntPtr sound, int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLoopCount (IntPtr sound, out int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetLoopPoints (IntPtr sound, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLoopPoints (IntPtr sound, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicNumChannels (IntPtr sound, out int numchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMusicChannelVolume (IntPtr sound, int channel, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicChannelVolume (IntPtr sound, int channel, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMusicSpeed (IntPtr sound, float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicSpeed (IntPtr sound, out float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetUserData (IntPtr sound, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetUserData (IntPtr sound, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Sound(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'ChannelControl' API + */ + interface IChannelControl + { + RESULT getSystemObject (out System system); + + // General control functionality for Channels and ChannelGroups. + RESULT stop (); + RESULT setPaused (bool paused); + RESULT getPaused (out bool paused); + RESULT setVolume (float volume); + RESULT getVolume (out float volume); + RESULT setVolumeRamp (bool ramp); + RESULT getVolumeRamp (out bool ramp); + RESULT getAudibility (out float audibility); + RESULT setPitch (float pitch); + RESULT getPitch (out float pitch); + RESULT setMute (bool mute); + RESULT getMute (out bool mute); + RESULT setReverbProperties (int instance, float wet); + RESULT getReverbProperties (int instance, out float wet); + RESULT setLowPassGain (float gain); + RESULT getLowPassGain (out float gain); + RESULT setMode (MODE mode); + RESULT getMode (out MODE mode); + RESULT setCallback (CHANNELCONTROL_CALLBACK callback); + RESULT isPlaying (out bool isplaying); + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + RESULT setPan (float pan); + RESULT setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + RESULT setMixLevelsInput (float[] levels, int numlevels); + RESULT setMixMatrix (float[] matrix, int outchannels, int inchannels, int inchannel_hop); + RESULT getMixMatrix (float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + + // Clock based functionality. + RESULT getDSPClock (out ulong dspclock, out ulong parentclock); + RESULT setDelay (ulong dspclock_start, ulong dspclock_end, bool stopchannels); + RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end); + RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + RESULT addFadePoint (ulong dspclock, float volume); + RESULT setFadePointRamp (ulong dspclock, float volume); + RESULT removeFadePoints (ulong dspclock_start, ulong dspclock_end); + RESULT getFadePoints (ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + + // DSP effects. + RESULT getDSP (int index, out DSP dsp); + RESULT addDSP (int index, DSP dsp); + RESULT removeDSP (DSP dsp); + RESULT getNumDSPs (out int numdsps); + RESULT setDSPIndex (DSP dsp, int index); + RESULT getDSPIndex (DSP dsp, out int index); + + // 3D functionality. + RESULT set3DAttributes (ref VECTOR pos, ref VECTOR vel); + RESULT get3DAttributes (out VECTOR pos, out VECTOR vel); + RESULT set3DMinMaxDistance (float mindistance, float maxdistance); + RESULT get3DMinMaxDistance (out float mindistance, out float maxdistance); + RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume); + RESULT get3DConeSettings (out float insideconeangle, out float outsideconeangle, out float outsidevolume); + RESULT set3DConeOrientation (ref VECTOR orientation); + RESULT get3DConeOrientation (out VECTOR orientation); + RESULT set3DCustomRolloff (ref VECTOR points, int numpoints); + RESULT get3DCustomRolloff (out IntPtr points, out int numpoints); + RESULT set3DOcclusion (float directocclusion, float reverbocclusion); + RESULT get3DOcclusion (out float directocclusion, out float reverbocclusion); + RESULT set3DSpread (float angle); + RESULT get3DSpread (out float angle); + RESULT set3DLevel (float level); + RESULT get3DLevel (out float level); + RESULT set3DDopplerLevel (float level); + RESULT get3DDopplerLevel (out float level); + RESULT set3DDistanceFilter (bool custom, float customLevel, float centerFreq); + RESULT get3DDistanceFilter (out bool custom, out float customLevel, out float centerFreq); + + // Userdata set/get. + RESULT setUserData (IntPtr userdata); + RESULT getUserData (out IntPtr userdata); + } + + /* + 'Channel' API + */ + public struct Channel : IChannelControl + { + // Channel specific control functionality. + public RESULT setFrequency(float frequency) + { + return FMOD5_Channel_SetFrequency(this.handle, frequency); + } + public RESULT getFrequency(out float frequency) + { + return FMOD5_Channel_GetFrequency(this.handle, out frequency); + } + public RESULT setPriority(int priority) + { + return FMOD5_Channel_SetPriority(this.handle, priority); + } + public RESULT getPriority(out int priority) + { + return FMOD5_Channel_GetPriority(this.handle, out priority); + } + public RESULT setPosition(uint position, TIMEUNIT postype) + { + return FMOD5_Channel_SetPosition(this.handle, position, postype); + } + public RESULT getPosition(out uint position, TIMEUNIT postype) + { + return FMOD5_Channel_GetPosition(this.handle, out position, postype); + } + public RESULT setChannelGroup(ChannelGroup channelgroup) + { + return FMOD5_Channel_SetChannelGroup(this.handle, channelgroup.handle); + } + public RESULT getChannelGroup(out ChannelGroup channelgroup) + { + return FMOD5_Channel_GetChannelGroup(this.handle, out channelgroup.handle); + } + public RESULT setLoopCount(int loopcount) + { + return FMOD5_Channel_SetLoopCount(this.handle, loopcount); + } + public RESULT getLoopCount(out int loopcount) + { + return FMOD5_Channel_GetLoopCount(this.handle, out loopcount); + } + public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Channel_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype); + } + public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Channel_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype); + } + + // Information only functions. + public RESULT isVirtual(out bool isvirtual) + { + return FMOD5_Channel_IsVirtual(this.handle, out isvirtual); + } + public RESULT getCurrentSound(out Sound sound) + { + return FMOD5_Channel_GetCurrentSound(this.handle, out sound.handle); + } + public RESULT getIndex(out int index) + { + return FMOD5_Channel_GetIndex(this.handle, out index); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_Channel_GetSystemObject(this.handle, out system.handle); + } + + // General control functionality for Channels and ChannelGroups. + public RESULT stop() + { + return FMOD5_Channel_Stop(this.handle); + } + public RESULT setPaused(bool paused) + { + return FMOD5_Channel_SetPaused(this.handle, paused); + } + public RESULT getPaused(out bool paused) + { + return FMOD5_Channel_GetPaused(this.handle, out paused); + } + public RESULT setVolume(float volume) + { + return FMOD5_Channel_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_Channel_GetVolume(this.handle, out volume); + } + public RESULT setVolumeRamp(bool ramp) + { + return FMOD5_Channel_SetVolumeRamp(this.handle, ramp); + } + public RESULT getVolumeRamp(out bool ramp) + { + return FMOD5_Channel_GetVolumeRamp(this.handle, out ramp); + } + public RESULT getAudibility(out float audibility) + { + return FMOD5_Channel_GetAudibility(this.handle, out audibility); + } + public RESULT setPitch(float pitch) + { + return FMOD5_Channel_SetPitch(this.handle, pitch); + } + public RESULT getPitch(out float pitch) + { + return FMOD5_Channel_GetPitch(this.handle, out pitch); + } + public RESULT setMute(bool mute) + { + return FMOD5_Channel_SetMute(this.handle, mute); + } + public RESULT getMute(out bool mute) + { + return FMOD5_Channel_GetMute(this.handle, out mute); + } + public RESULT setReverbProperties(int instance, float wet) + { + return FMOD5_Channel_SetReverbProperties(this.handle, instance, wet); + } + public RESULT getReverbProperties(int instance, out float wet) + { + return FMOD5_Channel_GetReverbProperties(this.handle, instance, out wet); + } + public RESULT setLowPassGain(float gain) + { + return FMOD5_Channel_SetLowPassGain(this.handle, gain); + } + public RESULT getLowPassGain(out float gain) + { + return FMOD5_Channel_GetLowPassGain(this.handle, out gain); + } + public RESULT setMode(MODE mode) + { + return FMOD5_Channel_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_Channel_GetMode(this.handle, out mode); + } + public RESULT setCallback(CHANNELCONTROL_CALLBACK callback) + { + return FMOD5_Channel_SetCallback(this.handle, callback); + } + public RESULT isPlaying(out bool isplaying) + { + return FMOD5_Channel_IsPlaying(this.handle, out isplaying); + } + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + public RESULT setPan(float pan) + { + return FMOD5_Channel_SetPan(this.handle, pan); + } + public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright) + { + return FMOD5_Channel_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright); + } + public RESULT setMixLevelsInput(float[] levels, int numlevels) + { + return FMOD5_Channel_SetMixLevelsInput(this.handle, levels, numlevels); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0) + { + return FMOD5_Channel_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0) + { + return FMOD5_Channel_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + + // Clock based functionality. + public RESULT getDSPClock(out ulong dspclock, out ulong parentclock) + { + return FMOD5_Channel_GetDSPClock(this.handle, out dspclock, out parentclock); + } + public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels = true) + { + return FMOD5_Channel_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end) + { + return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels) + { + return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels); + } + public RESULT addFadePoint(ulong dspclock, float volume) + { + return FMOD5_Channel_AddFadePoint(this.handle, dspclock, volume); + } + public RESULT setFadePointRamp(ulong dspclock, float volume) + { + return FMOD5_Channel_SetFadePointRamp(this.handle, dspclock, volume); + } + public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end) + { + return FMOD5_Channel_RemoveFadePoints(this.handle, dspclock_start, dspclock_end); + } + public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume) + { + return FMOD5_Channel_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume); + } + + // DSP effects. + public RESULT getDSP(int index, out DSP dsp) + { + return FMOD5_Channel_GetDSP(this.handle, index, out dsp.handle); + } + public RESULT addDSP(int index, DSP dsp) + { + return FMOD5_Channel_AddDSP(this.handle, index, dsp.handle); + } + public RESULT removeDSP(DSP dsp) + { + return FMOD5_Channel_RemoveDSP(this.handle, dsp.handle); + } + public RESULT getNumDSPs(out int numdsps) + { + return FMOD5_Channel_GetNumDSPs(this.handle, out numdsps); + } + public RESULT setDSPIndex(DSP dsp, int index) + { + return FMOD5_Channel_SetDSPIndex(this.handle, dsp.handle, index); + } + public RESULT getDSPIndex(DSP dsp, out int index) + { + return FMOD5_Channel_GetDSPIndex(this.handle, dsp.handle, out index); + } + + // 3D functionality. + public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel) + { + return FMOD5_Channel_Set3DAttributes(this.handle, ref pos, ref vel); + } + public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel) + { + return FMOD5_Channel_Get3DAttributes(this.handle, out pos, out vel); + } + public RESULT set3DMinMaxDistance(float mindistance, float maxdistance) + { + return FMOD5_Channel_Set3DMinMaxDistance(this.handle, mindistance, maxdistance); + } + public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance) + { + return FMOD5_Channel_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_Channel_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_Channel_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DConeOrientation(ref VECTOR orientation) + { + return FMOD5_Channel_Set3DConeOrientation(this.handle, ref orientation); + } + public RESULT get3DConeOrientation(out VECTOR orientation) + { + return FMOD5_Channel_Get3DConeOrientation(this.handle, out orientation); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_Channel_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_Channel_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + public RESULT set3DOcclusion(float directocclusion, float reverbocclusion) + { + return FMOD5_Channel_Set3DOcclusion(this.handle, directocclusion, reverbocclusion); + } + public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion) + { + return FMOD5_Channel_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion); + } + public RESULT set3DSpread(float angle) + { + return FMOD5_Channel_Set3DSpread(this.handle, angle); + } + public RESULT get3DSpread(out float angle) + { + return FMOD5_Channel_Get3DSpread(this.handle, out angle); + } + public RESULT set3DLevel(float level) + { + return FMOD5_Channel_Set3DLevel(this.handle, level); + } + public RESULT get3DLevel(out float level) + { + return FMOD5_Channel_Get3DLevel(this.handle, out level); + } + public RESULT set3DDopplerLevel(float level) + { + return FMOD5_Channel_Set3DDopplerLevel(this.handle, level); + } + public RESULT get3DDopplerLevel(out float level) + { + return FMOD5_Channel_Get3DDopplerLevel(this.handle, out level); + } + public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq) + { + return FMOD5_Channel_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq); + } + public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq) + { + return FMOD5_Channel_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Channel_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Channel_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetFrequency (IntPtr channel, float frequency); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetFrequency (IntPtr channel, out float frequency); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPriority (IntPtr channel, int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPriority (IntPtr channel, out int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPosition (IntPtr channel, uint position, TIMEUNIT postype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPosition (IntPtr channel, out uint position, TIMEUNIT postype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetChannelGroup (IntPtr channel, IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetChannelGroup (IntPtr channel, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLoopCount (IntPtr channel, int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLoopCount (IntPtr channel, out int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLoopPoints (IntPtr channel, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLoopPoints (IntPtr channel, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_IsVirtual (IntPtr channel, out bool isvirtual); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetCurrentSound (IntPtr channel, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetIndex (IntPtr channel, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetSystemObject (IntPtr channel, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Stop (IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPaused (IntPtr channel, bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPaused (IntPtr channel, out bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetVolume (IntPtr channel, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetVolume (IntPtr channel, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetVolumeRamp (IntPtr channel, bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetVolumeRamp (IntPtr channel, out bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetAudibility (IntPtr channel, out float audibility); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPitch (IntPtr channel, float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPitch (IntPtr channel, out float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMute (IntPtr channel, bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMute (IntPtr channel, out bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetReverbProperties (IntPtr channel, int instance, float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetReverbProperties (IntPtr channel, int instance, out float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLowPassGain (IntPtr channel, float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLowPassGain (IntPtr channel, out float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMode (IntPtr channel, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMode (IntPtr channel, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetCallback (IntPtr channel, CHANNELCONTROL_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_IsPlaying (IntPtr channel, out bool isplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPan (IntPtr channel, float pan); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixLevelsOutput (IntPtr channel, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixLevelsInput (IntPtr channel, float[] levels, int numlevels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixMatrix (IntPtr channel, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMixMatrix (IntPtr channel, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSPClock (IntPtr channel, out ulong dspclock, out ulong parentclock); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetDelay (IntPtr channel, ulong dspclock_start, ulong dspclock_end, bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_AddFadePoint (IntPtr channel, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetFadePointRamp (IntPtr channel, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_RemoveFadePoints (IntPtr channel, ulong dspclock_start, ulong dspclock_end); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetFadePoints (IntPtr channel, ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSP (IntPtr channel, int index, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_AddDSP (IntPtr channel, int index, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_RemoveDSP (IntPtr channel, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetNumDSPs (IntPtr channel, out int numdsps); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetDSPIndex (IntPtr channel, IntPtr dsp, int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSPIndex (IntPtr channel, IntPtr dsp, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DAttributes (IntPtr channel, ref VECTOR pos, ref VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DAttributes (IntPtr channel, out VECTOR pos, out VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DMinMaxDistance (IntPtr channel, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DMinMaxDistance (IntPtr channel, out float mindistance, out float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DConeSettings (IntPtr channel, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DConeSettings (IntPtr channel, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DConeOrientation (IntPtr channel, ref VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DConeOrientation (IntPtr channel, out VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DCustomRolloff (IntPtr channel, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DCustomRolloff (IntPtr channel, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DOcclusion (IntPtr channel, float directocclusion, float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DOcclusion (IntPtr channel, out float directocclusion, out float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DSpread (IntPtr channel, float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DSpread (IntPtr channel, out float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DLevel (IntPtr channel, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DLevel (IntPtr channel, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DDopplerLevel (IntPtr channel, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DDopplerLevel (IntPtr channel, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DDistanceFilter (IntPtr channel, bool custom, float customLevel, float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DDistanceFilter (IntPtr channel, out bool custom, out float customLevel, out float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetUserData (IntPtr channel, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetUserData (IntPtr channel, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Channel(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'ChannelGroup' API + */ + public struct ChannelGroup : IChannelControl + { + public RESULT release() + { + return FMOD5_ChannelGroup_Release(this.handle); + } + + // Nested channel groups. + public RESULT addGroup(ChannelGroup group, bool propagatedspclock = true) + { + return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, IntPtr.Zero); + } + public RESULT addGroup(ChannelGroup group, bool propagatedspclock, out DSPConnection connection) + { + return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, out connection.handle); + } + public RESULT getNumGroups(out int numgroups) + { + return FMOD5_ChannelGroup_GetNumGroups(this.handle, out numgroups); + } + public RESULT getGroup(int index, out ChannelGroup group) + { + return FMOD5_ChannelGroup_GetGroup(this.handle, index, out group.handle); + } + public RESULT getParentGroup(out ChannelGroup group) + { + return FMOD5_ChannelGroup_GetParentGroup(this.handle, out group.handle); + } + + // Information only functions. + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_ChannelGroup_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getNumChannels(out int numchannels) + { + return FMOD5_ChannelGroup_GetNumChannels(this.handle, out numchannels); + } + public RESULT getChannel(int index, out Channel channel) + { + return FMOD5_ChannelGroup_GetChannel(this.handle, index, out channel.handle); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_ChannelGroup_GetSystemObject(this.handle, out system.handle); + } + + // General control functionality for Channels and ChannelGroups. + public RESULT stop() + { + return FMOD5_ChannelGroup_Stop(this.handle); + } + public RESULT setPaused(bool paused) + { + return FMOD5_ChannelGroup_SetPaused(this.handle, paused); + } + public RESULT getPaused(out bool paused) + { + return FMOD5_ChannelGroup_GetPaused(this.handle, out paused); + } + public RESULT setVolume(float volume) + { + return FMOD5_ChannelGroup_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_ChannelGroup_GetVolume(this.handle, out volume); + } + public RESULT setVolumeRamp(bool ramp) + { + return FMOD5_ChannelGroup_SetVolumeRamp(this.handle, ramp); + } + public RESULT getVolumeRamp(out bool ramp) + { + return FMOD5_ChannelGroup_GetVolumeRamp(this.handle, out ramp); + } + public RESULT getAudibility(out float audibility) + { + return FMOD5_ChannelGroup_GetAudibility(this.handle, out audibility); + } + public RESULT setPitch(float pitch) + { + return FMOD5_ChannelGroup_SetPitch(this.handle, pitch); + } + public RESULT getPitch(out float pitch) + { + return FMOD5_ChannelGroup_GetPitch(this.handle, out pitch); + } + public RESULT setMute(bool mute) + { + return FMOD5_ChannelGroup_SetMute(this.handle, mute); + } + public RESULT getMute(out bool mute) + { + return FMOD5_ChannelGroup_GetMute(this.handle, out mute); + } + public RESULT setReverbProperties(int instance, float wet) + { + return FMOD5_ChannelGroup_SetReverbProperties(this.handle, instance, wet); + } + public RESULT getReverbProperties(int instance, out float wet) + { + return FMOD5_ChannelGroup_GetReverbProperties(this.handle, instance, out wet); + } + public RESULT setLowPassGain(float gain) + { + return FMOD5_ChannelGroup_SetLowPassGain(this.handle, gain); + } + public RESULT getLowPassGain(out float gain) + { + return FMOD5_ChannelGroup_GetLowPassGain(this.handle, out gain); + } + public RESULT setMode(MODE mode) + { + return FMOD5_ChannelGroup_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_ChannelGroup_GetMode(this.handle, out mode); + } + public RESULT setCallback(CHANNELCONTROL_CALLBACK callback) + { + return FMOD5_ChannelGroup_SetCallback(this.handle, callback); + } + public RESULT isPlaying(out bool isplaying) + { + return FMOD5_ChannelGroup_IsPlaying(this.handle, out isplaying); + } + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + public RESULT setPan(float pan) + { + return FMOD5_ChannelGroup_SetPan(this.handle, pan); + } + public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright) + { + return FMOD5_ChannelGroup_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright); + } + public RESULT setMixLevelsInput(float[] levels, int numlevels) + { + return FMOD5_ChannelGroup_SetMixLevelsInput(this.handle, levels, numlevels); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop) + { + return FMOD5_ChannelGroup_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop) + { + return FMOD5_ChannelGroup_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + + // Clock based functionality. + public RESULT getDSPClock(out ulong dspclock, out ulong parentclock) + { + return FMOD5_ChannelGroup_GetDSPClock(this.handle, out dspclock, out parentclock); + } + public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels) + { + return FMOD5_ChannelGroup_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end) + { + return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels) + { + return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels); + } + public RESULT addFadePoint(ulong dspclock, float volume) + { + return FMOD5_ChannelGroup_AddFadePoint(this.handle, dspclock, volume); + } + public RESULT setFadePointRamp(ulong dspclock, float volume) + { + return FMOD5_ChannelGroup_SetFadePointRamp(this.handle, dspclock, volume); + } + public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end) + { + return FMOD5_ChannelGroup_RemoveFadePoints(this.handle, dspclock_start, dspclock_end); + } + public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume) + { + return FMOD5_ChannelGroup_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume); + } + + // DSP effects. + public RESULT getDSP(int index, out DSP dsp) + { + return FMOD5_ChannelGroup_GetDSP(this.handle, index, out dsp.handle); + } + public RESULT addDSP(int index, DSP dsp) + { + return FMOD5_ChannelGroup_AddDSP(this.handle, index, dsp.handle); + } + public RESULT removeDSP(DSP dsp) + { + return FMOD5_ChannelGroup_RemoveDSP(this.handle, dsp.handle); + } + public RESULT getNumDSPs(out int numdsps) + { + return FMOD5_ChannelGroup_GetNumDSPs(this.handle, out numdsps); + } + public RESULT setDSPIndex(DSP dsp, int index) + { + return FMOD5_ChannelGroup_SetDSPIndex(this.handle, dsp.handle, index); + } + public RESULT getDSPIndex(DSP dsp, out int index) + { + return FMOD5_ChannelGroup_GetDSPIndex(this.handle, dsp.handle, out index); + } + + // 3D functionality. + public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel) + { + return FMOD5_ChannelGroup_Set3DAttributes(this.handle, ref pos, ref vel); + } + public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel) + { + return FMOD5_ChannelGroup_Get3DAttributes(this.handle, out pos, out vel); + } + public RESULT set3DMinMaxDistance(float mindistance, float maxdistance) + { + return FMOD5_ChannelGroup_Set3DMinMaxDistance(this.handle, mindistance, maxdistance); + } + public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance) + { + return FMOD5_ChannelGroup_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_ChannelGroup_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_ChannelGroup_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DConeOrientation(ref VECTOR orientation) + { + return FMOD5_ChannelGroup_Set3DConeOrientation(this.handle, ref orientation); + } + public RESULT get3DConeOrientation(out VECTOR orientation) + { + return FMOD5_ChannelGroup_Get3DConeOrientation(this.handle, out orientation); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_ChannelGroup_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_ChannelGroup_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + public RESULT set3DOcclusion(float directocclusion, float reverbocclusion) + { + return FMOD5_ChannelGroup_Set3DOcclusion(this.handle, directocclusion, reverbocclusion); + } + public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion) + { + return FMOD5_ChannelGroup_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion); + } + public RESULT set3DSpread(float angle) + { + return FMOD5_ChannelGroup_Set3DSpread(this.handle, angle); + } + public RESULT get3DSpread(out float angle) + { + return FMOD5_ChannelGroup_Get3DSpread(this.handle, out angle); + } + public RESULT set3DLevel(float level) + { + return FMOD5_ChannelGroup_Set3DLevel(this.handle, level); + } + public RESULT get3DLevel(out float level) + { + return FMOD5_ChannelGroup_Get3DLevel(this.handle, out level); + } + public RESULT set3DDopplerLevel(float level) + { + return FMOD5_ChannelGroup_Set3DDopplerLevel(this.handle, level); + } + public RESULT get3DDopplerLevel(out float level) + { + return FMOD5_ChannelGroup_Get3DDopplerLevel(this.handle, out level); + } + public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq) + { + return FMOD5_ChannelGroup_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq); + } + public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq) + { + return FMOD5_ChannelGroup_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_ChannelGroup_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_ChannelGroup_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Release (IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, out IntPtr connection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumGroups (IntPtr channelgroup, out int numgroups); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetGroup (IntPtr channelgroup, int index, out IntPtr group); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetParentGroup (IntPtr channelgroup, out IntPtr group); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetName (IntPtr channelgroup, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumChannels (IntPtr channelgroup, out int numchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetChannel (IntPtr channelgroup, int index, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetSystemObject (IntPtr channelgroup, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Stop (IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPaused (IntPtr channelgroup, bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetPaused (IntPtr channelgroup, out bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetVolume (IntPtr channelgroup, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetVolume (IntPtr channelgroup, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetVolumeRamp (IntPtr channelgroup, bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetVolumeRamp (IntPtr channelgroup, out bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetAudibility (IntPtr channelgroup, out float audibility); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPitch (IntPtr channelgroup, float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetPitch (IntPtr channelgroup, out float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMute (IntPtr channelgroup, bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMute (IntPtr channelgroup, out bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetReverbProperties (IntPtr channelgroup, int instance, float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetReverbProperties (IntPtr channelgroup, int instance, out float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetLowPassGain (IntPtr channelgroup, float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetLowPassGain (IntPtr channelgroup, out float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMode (IntPtr channelgroup, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMode (IntPtr channelgroup, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetCallback (IntPtr channelgroup, CHANNELCONTROL_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_IsPlaying (IntPtr channelgroup, out bool isplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPan (IntPtr channelgroup, float pan); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsOutput (IntPtr channelgroup, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsInput (IntPtr channelgroup, float[] levels, int numlevels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixMatrix (IntPtr channelgroup, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMixMatrix (IntPtr channelgroup, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSPClock (IntPtr channelgroup, out ulong dspclock, out ulong parentclock); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetDelay (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end, bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddFadePoint (IntPtr channelgroup, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetFadePointRamp (IntPtr channelgroup, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_RemoveFadePoints (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetFadePoints (IntPtr channelgroup, ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSP (IntPtr channelgroup, int index, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddDSP (IntPtr channelgroup, int index, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_RemoveDSP (IntPtr channelgroup, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumDSPs (IntPtr channelgroup, out int numdsps); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetDSPIndex (IntPtr channelgroup, IntPtr dsp, int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSPIndex (IntPtr channelgroup, IntPtr dsp, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DAttributes (IntPtr channelgroup, ref VECTOR pos, ref VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DAttributes (IntPtr channelgroup, out VECTOR pos, out VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DMinMaxDistance (IntPtr channelgroup, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DMinMaxDistance (IntPtr channelgroup, out float mindistance, out float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DConeSettings (IntPtr channelgroup, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DConeSettings (IntPtr channelgroup, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DConeOrientation(IntPtr channelgroup, ref VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DConeOrientation(IntPtr channelgroup, out VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DCustomRolloff (IntPtr channelgroup, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DCustomRolloff (IntPtr channelgroup, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DOcclusion (IntPtr channelgroup, float directocclusion, float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DOcclusion (IntPtr channelgroup, out float directocclusion, out float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DSpread (IntPtr channelgroup, float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DSpread (IntPtr channelgroup, out float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DLevel (IntPtr channelgroup, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DLevel (IntPtr channelgroup, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DDopplerLevel (IntPtr channelgroup, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DDopplerLevel (IntPtr channelgroup, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DDistanceFilter (IntPtr channelgroup, bool custom, float customLevel, float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DDistanceFilter (IntPtr channelgroup, out bool custom, out float customLevel, out float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetUserData (IntPtr channelgroup, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetUserData (IntPtr channelgroup, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public ChannelGroup(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'SoundGroup' API + */ + public struct SoundGroup + { + public RESULT release() + { + return FMOD5_SoundGroup_Release(this.handle); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_SoundGroup_GetSystemObject(this.handle, out system.handle); + } + + // SoundGroup control functions. + public RESULT setMaxAudible(int maxaudible) + { + return FMOD5_SoundGroup_SetMaxAudible(this.handle, maxaudible); + } + public RESULT getMaxAudible(out int maxaudible) + { + return FMOD5_SoundGroup_GetMaxAudible(this.handle, out maxaudible); + } + public RESULT setMaxAudibleBehavior(SOUNDGROUP_BEHAVIOR behavior) + { + return FMOD5_SoundGroup_SetMaxAudibleBehavior(this.handle, behavior); + } + public RESULT getMaxAudibleBehavior(out SOUNDGROUP_BEHAVIOR behavior) + { + return FMOD5_SoundGroup_GetMaxAudibleBehavior(this.handle, out behavior); + } + public RESULT setMuteFadeSpeed(float speed) + { + return FMOD5_SoundGroup_SetMuteFadeSpeed(this.handle, speed); + } + public RESULT getMuteFadeSpeed(out float speed) + { + return FMOD5_SoundGroup_GetMuteFadeSpeed(this.handle, out speed); + } + public RESULT setVolume(float volume) + { + return FMOD5_SoundGroup_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_SoundGroup_GetVolume(this.handle, out volume); + } + public RESULT stop() + { + return FMOD5_SoundGroup_Stop(this.handle); + } + + // Information only functions. + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_SoundGroup_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getNumSounds(out int numsounds) + { + return FMOD5_SoundGroup_GetNumSounds(this.handle, out numsounds); + } + public RESULT getSound(int index, out Sound sound) + { + return FMOD5_SoundGroup_GetSound(this.handle, index, out sound.handle); + } + public RESULT getNumPlaying(out int numplaying) + { + return FMOD5_SoundGroup_GetNumPlaying(this.handle, out numplaying); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_SoundGroup_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_SoundGroup_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_Release (IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetSystemObject (IntPtr soundgroup, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMaxAudible (IntPtr soundgroup, int maxaudible); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMaxAudible (IntPtr soundgroup, out int maxaudible); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMaxAudibleBehavior (IntPtr soundgroup, SOUNDGROUP_BEHAVIOR behavior); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMaxAudibleBehavior (IntPtr soundgroup, out SOUNDGROUP_BEHAVIOR behavior); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMuteFadeSpeed (IntPtr soundgroup, float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMuteFadeSpeed (IntPtr soundgroup, out float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetVolume (IntPtr soundgroup, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetVolume (IntPtr soundgroup, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_Stop (IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetName (IntPtr soundgroup, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetNumSounds (IntPtr soundgroup, out int numsounds); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetSound (IntPtr soundgroup, int index, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetNumPlaying (IntPtr soundgroup, out int numplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetUserData (IntPtr soundgroup, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetUserData (IntPtr soundgroup, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public SoundGroup(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'DSP' API + */ + public struct DSP + { + public RESULT release() + { + return FMOD5_DSP_Release(this.handle); + } + public RESULT getSystemObject(out System system) + { + return FMOD5_DSP_GetSystemObject(this.handle, out system.handle); + } + + // Connection / disconnection / input and output enumeration. + public RESULT addInput(DSP input) + { + return FMOD5_DSP_AddInput(this.handle, input.handle, IntPtr.Zero, DSPCONNECTION_TYPE.STANDARD); + } + public RESULT addInput(DSP input, out DSPConnection connection, DSPCONNECTION_TYPE type = DSPCONNECTION_TYPE.STANDARD) + { + return FMOD5_DSP_AddInput(this.handle, input.handle, out connection.handle, type); + } + public RESULT disconnectFrom(DSP target, DSPConnection connection) + { + return FMOD5_DSP_DisconnectFrom(this.handle, target.handle, connection.handle); + } + public RESULT disconnectAll(bool inputs, bool outputs) + { + return FMOD5_DSP_DisconnectAll(this.handle, inputs, outputs); + } + public RESULT getNumInputs(out int numinputs) + { + return FMOD5_DSP_GetNumInputs(this.handle, out numinputs); + } + public RESULT getNumOutputs(out int numoutputs) + { + return FMOD5_DSP_GetNumOutputs(this.handle, out numoutputs); + } + public RESULT getInput(int index, out DSP input, out DSPConnection inputconnection) + { + return FMOD5_DSP_GetInput(this.handle, index, out input.handle, out inputconnection.handle); + } + public RESULT getOutput(int index, out DSP output, out DSPConnection outputconnection) + { + return FMOD5_DSP_GetOutput(this.handle, index, out output.handle, out outputconnection.handle); + } + + // DSP unit control. + public RESULT setActive(bool active) + { + return FMOD5_DSP_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_DSP_GetActive(this.handle, out active); + } + public RESULT setBypass(bool bypass) + { + return FMOD5_DSP_SetBypass(this.handle, bypass); + } + public RESULT getBypass(out bool bypass) + { + return FMOD5_DSP_GetBypass(this.handle, out bypass); + } + public RESULT setWetDryMix(float prewet, float postwet, float dry) + { + return FMOD5_DSP_SetWetDryMix(this.handle, prewet, postwet, dry); + } + public RESULT getWetDryMix(out float prewet, out float postwet, out float dry) + { + return FMOD5_DSP_GetWetDryMix(this.handle, out prewet, out postwet, out dry); + } + public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode) + { + return FMOD5_DSP_SetChannelFormat(this.handle, channelmask, numchannels, source_speakermode); + } + public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode) + { + return FMOD5_DSP_GetChannelFormat(this.handle, out channelmask, out numchannels, out source_speakermode); + } + public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode) + { + return FMOD5_DSP_GetOutputChannelFormat(this.handle, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode); + } + public RESULT reset() + { + return FMOD5_DSP_Reset(this.handle); + } + public RESULT setCallback(DSP_CALLBACK callback) + { + return FMOD5_DSP_SetCallback(this.handle, callback); + } + + // DSP parameter control. + public RESULT setParameterFloat(int index, float value) + { + return FMOD5_DSP_SetParameterFloat(this.handle, index, value); + } + public RESULT setParameterInt(int index, int value) + { + return FMOD5_DSP_SetParameterInt(this.handle, index, value); + } + public RESULT setParameterBool(int index, bool value) + { + return FMOD5_DSP_SetParameterBool(this.handle, index, value); + } + public RESULT setParameterData(int index, byte[] data) + { + return FMOD5_DSP_SetParameterData(this.handle, index, Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), (uint)data.Length); + } + public RESULT getParameterFloat(int index, out float value) + { + return FMOD5_DSP_GetParameterFloat(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterInt(int index, out int value) + { + return FMOD5_DSP_GetParameterInt(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterBool(int index, out bool value) + { + return FMOD5_DSP_GetParameterBool(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterData(int index, out IntPtr data, out uint length) + { + return FMOD5_DSP_GetParameterData(this.handle, index, out data, out length, IntPtr.Zero, 0); + } + public RESULT getNumParameters(out int numparams) + { + return FMOD5_DSP_GetNumParameters(this.handle, out numparams); + } + public RESULT getParameterInfo(int index, out DSP_PARAMETER_DESC desc) + { + IntPtr descPtr; + RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr); + desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC)); + return result; + } + public RESULT getDataParameterIndex(int datatype, out int index) + { + return FMOD5_DSP_GetDataParameterIndex(this.handle, datatype, out index); + } + public RESULT showConfigDialog(IntPtr hwnd, bool show) + { + return FMOD5_DSP_ShowConfigDialog(this.handle, hwnd, show); + } + + // DSP attributes. + public RESULT getInfo(out string name, out uint version, out int channels, out int configwidth, out int configheight) + { + IntPtr nameMem = Marshal.AllocHGlobal(32); + + RESULT result = FMOD5_DSP_GetInfo(this.handle, nameMem, out version, out channels, out configwidth, out configheight); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(nameMem); + } + Marshal.FreeHGlobal(nameMem); + return result; + } + public RESULT getInfo(out uint version, out int channels, out int configwidth, out int configheight) + { + return FMOD5_DSP_GetInfo(this.handle, IntPtr.Zero, out version, out channels, out configwidth, out configheight); ; + } + public RESULT getType(out DSP_TYPE type) + { + return FMOD5_DSP_GetType(this.handle, out type); + } + public RESULT getIdle(out bool idle) + { + return FMOD5_DSP_GetIdle(this.handle, out idle); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_DSP_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_DSP_GetUserData(this.handle, out userdata); + } + + // Metering. + public RESULT setMeteringEnabled(bool inputEnabled, bool outputEnabled) + { + return FMOD5_DSP_SetMeteringEnabled(this.handle, inputEnabled, outputEnabled); + } + public RESULT getMeteringEnabled(out bool inputEnabled, out bool outputEnabled) + { + return FMOD5_DSP_GetMeteringEnabled(this.handle, out inputEnabled, out outputEnabled); + } + + public RESULT getMeteringInfo(IntPtr zero, out DSP_METERING_INFO outputInfo) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, zero, out outputInfo); + } + public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, IntPtr zero) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, zero); + } + public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, out outputInfo); + } + + public RESULT getCPUUsage(out uint exclusive, out uint inclusive) + { + return FMOD5_DSP_GetCPUUsage(this.handle, out exclusive, out inclusive); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_Release (IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetSystemObject (IntPtr dsp, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, IntPtr zero, DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, out IntPtr connection, DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_DisconnectFrom (IntPtr dsp, IntPtr target, IntPtr connection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_DisconnectAll (IntPtr dsp, bool inputs, bool outputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumInputs (IntPtr dsp, out int numinputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumOutputs (IntPtr dsp, out int numoutputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetInput (IntPtr dsp, int index, out IntPtr input, out IntPtr inputconnection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetOutput (IntPtr dsp, int index, out IntPtr output, out IntPtr outputconnection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetActive (IntPtr dsp, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetActive (IntPtr dsp, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetBypass (IntPtr dsp, bool bypass); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetBypass (IntPtr dsp, out bool bypass); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetWetDryMix (IntPtr dsp, float prewet, float postwet, float dry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetWetDryMix (IntPtr dsp, out float prewet, out float postwet, out float dry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_Reset (IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetCallback (IntPtr dsp, DSP_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterFloat (IntPtr dsp, int index, float value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterInt (IntPtr dsp, int index, int value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterBool (IntPtr dsp, int index, bool value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterData (IntPtr dsp, int index, IntPtr data, uint length); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterFloat (IntPtr dsp, int index, out float value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterInt (IntPtr dsp, int index, out int value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterBool (IntPtr dsp, int index, out bool value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterData (IntPtr dsp, int index, out IntPtr data, out uint length, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumParameters (IntPtr dsp, out int numparams); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterInfo (IntPtr dsp, int index, out IntPtr desc); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetDataParameterIndex (IntPtr dsp, int datatype, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_ShowConfigDialog (IntPtr dsp, IntPtr hwnd, bool show); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetInfo (IntPtr dsp, IntPtr name, out uint version, out int channels, out int configwidth, out int configheight); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetType (IntPtr dsp, out DSP_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetIdle (IntPtr dsp, out bool idle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetUserData (IntPtr dsp, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetUserData (IntPtr dsp, out IntPtr userdata); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_SetMeteringEnabled (IntPtr dsp, bool inputEnabled, bool outputEnabled); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringEnabled (IntPtr dsp, out bool inputEnabled, out bool outputEnabled); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, IntPtr zero, out DSP_METERING_INFO outputInfo); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, IntPtr zero); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetCPUUsage (IntPtr dsp, out uint exclusive, out uint inclusive); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public DSP(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'DSPConnection' API + */ + public struct DSPConnection + { + public RESULT getInput(out DSP input) + { + return FMOD5_DSPConnection_GetInput(this.handle, out input.handle); + } + public RESULT getOutput(out DSP output) + { + return FMOD5_DSPConnection_GetOutput(this.handle, out output.handle); + } + public RESULT setMix(float volume) + { + return FMOD5_DSPConnection_SetMix(this.handle, volume); + } + public RESULT getMix(out float volume) + { + return FMOD5_DSPConnection_GetMix(this.handle, out volume); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0) + { + return FMOD5_DSPConnection_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0) + { + return FMOD5_DSPConnection_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + public RESULT getType(out DSPCONNECTION_TYPE type) + { + return FMOD5_DSPConnection_GetType(this.handle, out type); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_DSPConnection_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_DSPConnection_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetInput (IntPtr dspconnection, out IntPtr input); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetOutput (IntPtr dspconnection, out IntPtr output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetMix (IntPtr dspconnection, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetMix (IntPtr dspconnection, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetMixMatrix (IntPtr dspconnection, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetMixMatrix (IntPtr dspconnection, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetType (IntPtr dspconnection, out DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetUserData (IntPtr dspconnection, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetUserData (IntPtr dspconnection, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public DSPConnection(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'Geometry' API + */ + public struct Geometry + { + public RESULT release() + { + return FMOD5_Geometry_Release(this.handle); + } + + // Polygon manipulation. + public RESULT addPolygon(float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex) + { + return FMOD5_Geometry_AddPolygon(this.handle, directocclusion, reverbocclusion, doublesided, numvertices, vertices, out polygonindex); + } + public RESULT getNumPolygons(out int numpolygons) + { + return FMOD5_Geometry_GetNumPolygons(this.handle, out numpolygons); + } + public RESULT getMaxPolygons(out int maxpolygons, out int maxvertices) + { + return FMOD5_Geometry_GetMaxPolygons(this.handle, out maxpolygons, out maxvertices); + } + public RESULT getPolygonNumVertices(int index, out int numvertices) + { + return FMOD5_Geometry_GetPolygonNumVertices(this.handle, index, out numvertices); + } + public RESULT setPolygonVertex(int index, int vertexindex, ref VECTOR vertex) + { + return FMOD5_Geometry_SetPolygonVertex(this.handle, index, vertexindex, ref vertex); + } + public RESULT getPolygonVertex(int index, int vertexindex, out VECTOR vertex) + { + return FMOD5_Geometry_GetPolygonVertex(this.handle, index, vertexindex, out vertex); + } + public RESULT setPolygonAttributes(int index, float directocclusion, float reverbocclusion, bool doublesided) + { + return FMOD5_Geometry_SetPolygonAttributes(this.handle, index, directocclusion, reverbocclusion, doublesided); + } + public RESULT getPolygonAttributes(int index, out float directocclusion, out float reverbocclusion, out bool doublesided) + { + return FMOD5_Geometry_GetPolygonAttributes(this.handle, index, out directocclusion, out reverbocclusion, out doublesided); + } + + // Object manipulation. + public RESULT setActive(bool active) + { + return FMOD5_Geometry_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_Geometry_GetActive(this.handle, out active); + } + public RESULT setRotation(ref VECTOR forward, ref VECTOR up) + { + return FMOD5_Geometry_SetRotation(this.handle, ref forward, ref up); + } + public RESULT getRotation(out VECTOR forward, out VECTOR up) + { + return FMOD5_Geometry_GetRotation(this.handle, out forward, out up); + } + public RESULT setPosition(ref VECTOR position) + { + return FMOD5_Geometry_SetPosition(this.handle, ref position); + } + public RESULT getPosition(out VECTOR position) + { + return FMOD5_Geometry_GetPosition(this.handle, out position); + } + public RESULT setScale(ref VECTOR scale) + { + return FMOD5_Geometry_SetScale(this.handle, ref scale); + } + public RESULT getScale(out VECTOR scale) + { + return FMOD5_Geometry_GetScale(this.handle, out scale); + } + public RESULT save(IntPtr data, out int datasize) + { + return FMOD5_Geometry_Save(this.handle, data, out datasize); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Geometry_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Geometry_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_Release (IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_AddPolygon (IntPtr geometry, float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetNumPolygons (IntPtr geometry, out int numpolygons); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetMaxPolygons (IntPtr geometry, out int maxpolygons, out int maxvertices); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonNumVertices(IntPtr geometry, int index, out int numvertices); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPolygonVertex (IntPtr geometry, int index, int vertexindex, ref VECTOR vertex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonVertex (IntPtr geometry, int index, int vertexindex, out VECTOR vertex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPolygonAttributes (IntPtr geometry, int index, float directocclusion, float reverbocclusion, bool doublesided); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonAttributes (IntPtr geometry, int index, out float directocclusion, out float reverbocclusion, out bool doublesided); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetActive (IntPtr geometry, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetActive (IntPtr geometry, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetRotation (IntPtr geometry, ref VECTOR forward, ref VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetRotation (IntPtr geometry, out VECTOR forward, out VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPosition (IntPtr geometry, ref VECTOR position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPosition (IntPtr geometry, out VECTOR position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetScale (IntPtr geometry, ref VECTOR scale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetScale (IntPtr geometry, out VECTOR scale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_Save (IntPtr geometry, IntPtr data, out int datasize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetUserData (IntPtr geometry, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetUserData (IntPtr geometry, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Geometry(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'Reverb3D' API + */ + public struct Reverb3D + { + public RESULT release() + { + return FMOD5_Reverb3D_Release(this.handle); + } + + // Reverb manipulation. + public RESULT set3DAttributes(ref VECTOR position, float mindistance, float maxdistance) + { + return FMOD5_Reverb3D_Set3DAttributes(this.handle, ref position, mindistance, maxdistance); + } + public RESULT get3DAttributes(ref VECTOR position, ref float mindistance, ref float maxdistance) + { + return FMOD5_Reverb3D_Get3DAttributes(this.handle, ref position, ref mindistance, ref maxdistance); + } + public RESULT setProperties(ref REVERB_PROPERTIES properties) + { + return FMOD5_Reverb3D_SetProperties(this.handle, ref properties); + } + public RESULT getProperties(ref REVERB_PROPERTIES properties) + { + return FMOD5_Reverb3D_GetProperties(this.handle, ref properties); + } + public RESULT setActive(bool active) + { + return FMOD5_Reverb3D_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_Reverb3D_GetActive(this.handle, out active); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Reverb3D_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Reverb3D_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Release (IntPtr reverb3d); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Set3DAttributes (IntPtr reverb3d, ref VECTOR position, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Get3DAttributes (IntPtr reverb3d, ref VECTOR position, ref float mindistance, ref float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetActive (IntPtr reverb3d, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetActive (IntPtr reverb3d, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetUserData (IntPtr reverb3d, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetUserData (IntPtr reverb3d, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Reverb3D(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + #region Helper Functions + [StructLayout(LayoutKind.Sequential)] + public struct StringWrapper + { + IntPtr nativeUtf8Ptr; + + public StringWrapper(IntPtr ptr) + { + nativeUtf8Ptr = ptr; + } + + public static implicit operator string(StringWrapper fstring) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return encoder.stringFromNative(fstring.nativeUtf8Ptr); + } + } + + public bool StartsWith(byte[] prefix) + { + if (nativeUtf8Ptr == IntPtr.Zero) + { + return false; + } + + for (int i = 0; i < prefix.Length; i++) + { + if (Marshal.ReadByte(nativeUtf8Ptr, i) != prefix[i]) + { + return false; + } + } + + return true; + } + + public bool Equals(byte[] comparison) + { + if (nativeUtf8Ptr == IntPtr.Zero) + { + return false; + } + + for (int i = 0; i < comparison.Length; i++) + { + if (Marshal.ReadByte(nativeUtf8Ptr, i) != comparison[i]) + { + return false; + } + } + + if (Marshal.ReadByte(nativeUtf8Ptr, comparison.Length) != 0) + { + return false; + } + + return true; + } + } + + static class StringHelper + { + public class ThreadSafeEncoding : IDisposable + { + UTF8Encoding encoding = new UTF8Encoding(); + byte[] encodedBuffer = new byte[128]; + char[] decodedBuffer = new char[128]; + bool inUse; + GCHandle gcHandle; + + public bool InUse() { return inUse; } + public void SetInUse() { inUse = true; } + + private int roundUpPowerTwo(int number) + { + int newNumber = 1; + while (newNumber <= number) + { + newNumber *= 2; + } + + return newNumber; + } + + public byte[] byteFromStringUTF8(string s) + { + if (s == null) + { + return null; + } + + int maximumLength = encoding.GetMaxByteCount(s.Length) + 1; // +1 for null terminator + if (maximumLength > encodedBuffer.Length) + { + int encodedLength = encoding.GetByteCount(s) + 1; // +1 for null terminator + if (encodedLength > encodedBuffer.Length) + { + encodedBuffer = new byte[roundUpPowerTwo(encodedLength)]; + } + } + + int byteCount = encoding.GetBytes(s, 0, s.Length, encodedBuffer, 0); + encodedBuffer[byteCount] = 0; // Apply null terminator + + return encodedBuffer; + } + + public IntPtr intptrFromStringUTF8(string s) + { + if (s == null) + { + return IntPtr.Zero; + } + + gcHandle = GCHandle.Alloc(byteFromStringUTF8(s), GCHandleType.Pinned); + return gcHandle.AddrOfPinnedObject(); + } + + public string stringFromNative(IntPtr nativePtr) + { + if (nativePtr == IntPtr.Zero) + { + return ""; + } + + int nativeLen = 0; + while (Marshal.ReadByte(nativePtr, nativeLen) != 0) + { + nativeLen++; + } + + if (nativeLen == 0) + { + return ""; + } + + if (nativeLen > encodedBuffer.Length) + { + encodedBuffer = new byte[roundUpPowerTwo(nativeLen)]; + } + + Marshal.Copy(nativePtr, encodedBuffer, 0, nativeLen); + + int maximumLength = encoding.GetMaxCharCount(nativeLen); + if (maximumLength > decodedBuffer.Length) + { + int decodedLength = encoding.GetCharCount(encodedBuffer, 0, nativeLen); + if (decodedLength > decodedBuffer.Length) + { + decodedBuffer = new char[roundUpPowerTwo(decodedLength)]; + } + } + + int charCount = encoding.GetChars(encodedBuffer, 0, nativeLen, decodedBuffer, 0); + + return new String(decodedBuffer, 0, charCount); + } + + public void Dispose() + { + if (gcHandle.IsAllocated) + { + gcHandle.Free(); + } + lock (encoders) + { + inUse = false; + } + } + } + + static List encoders = new List(1); + + public static ThreadSafeEncoding GetFreeHelper() + { + lock (encoders) + { + ThreadSafeEncoding helper = null; + // Search for not in use helper + for (int i = 0; i < encoders.Count; i++) + { + if (!encoders[i].InUse()) + { + helper = encoders[i]; + break; + } + } + // Otherwise create another helper + if (helper == null) + { + helper = new ThreadSafeEncoding(); + encoders.Add(helper); + } + helper.SetInUse(); + return helper; + } + } + } + + // Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541 + // Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings + public static class MarshalHelper + { +#pragma warning disable 618 + public static int SizeOf(Type t) + { + return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations + } + + public static object PtrToStructure(IntPtr ptr, Type structureType) + { + return Marshal.PtrToStructure(ptr, structureType); + } +#pragma warning restore 618 + } + + #endregion +} diff --git a/Assets/Plugins/FMOD/src/fmod.cs.meta b/Assets/Plugins/FMOD/src/fmod.cs.meta new file mode 100644 index 0000000..07641e1 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd0d0c955caff8940ac1667ee36dd4c9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/fmod_dsp.cs b/Assets/Plugins/FMOD/src/fmod_dsp.cs new file mode 100644 index 0000000..804f97f --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_dsp.cs @@ -0,0 +1,897 @@ +/* ======================================================================================== */ +/* FMOD Core API - DSP header file. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */ +/* */ +/* Use this header if you are wanting to develop your own DSP plugin to use with FMODs */ +/* dsp system. With this header you can make your own DSP plugin that FMOD can */ +/* register and use. See the documentation and examples on how to make a working plugin. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/docs/2.02/api/plugin-api-dsp.html */ +/* =========================================================================================*/ + +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace FMOD +{ + [StructLayout(LayoutKind.Sequential)] + public struct DSP_BUFFER_ARRAY + { + public int numbuffers; + public int[] buffernumchannels; + public CHANNELMASK[] bufferchannelmask; + public IntPtr[] buffers; + public SPEAKERMODE speakermode; + } + + public enum DSP_PROCESS_OPERATION + { + PROCESS_PERFORM = 0, + PROCESS_QUERY + } + + [StructLayout(LayoutKind.Sequential)] + public struct COMPLEX + { + public float real; + public float imag; + } + + public enum DSP_PAN_SURROUND_FLAGS + { + DEFAULT = 0, + ROTATION_NOT_BIASED = 1, + } + + + /* + DSP callbacks + */ + public delegate RESULT DSP_CREATE_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_RELEASE_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_RESET_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SETPOSITION_CALLBACK (ref DSP_STATE dsp_state, uint pos); + public delegate RESULT DSP_READ_CALLBACK (ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels); + public delegate RESULT DSP_SHOULDIPROCESS_CALLBACK (ref DSP_STATE dsp_state, bool inputsidle, uint length, CHANNELMASK inmask, int inchannels, SPEAKERMODE speakermode); + public delegate RESULT DSP_PROCESS_CALLBACK (ref DSP_STATE dsp_state, uint length, ref DSP_BUFFER_ARRAY inbufferarray, ref DSP_BUFFER_ARRAY outbufferarray, bool inputsidle, DSP_PROCESS_OPERATION op); + public delegate RESULT DSP_SETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, float value); + public delegate RESULT DSP_SETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, int value); + public delegate RESULT DSP_SETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, bool value); + public delegate RESULT DSP_SETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, IntPtr data, uint length); + public delegate RESULT DSP_GETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, ref float value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, ref int value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, ref bool value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, ref IntPtr data, ref uint length, IntPtr valuestr); + public delegate RESULT DSP_SYSTEM_REGISTER_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SYSTEM_DEREGISTER_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SYSTEM_MIX_CALLBACK (ref DSP_STATE dsp_state, int stage); + + + /* + DSP functions + */ + public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr str); + public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate); + public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize); + public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output); + public delegate RESULT DSP_GETCLOCK_FUNC (ref DSP_STATE dsp_state, out ulong clock, out uint offset, out uint length); + public delegate RESULT DSP_GETLISTENERATTRIBUTES_FUNC (ref DSP_STATE dsp_state, ref int numlisteners, IntPtr attributes); + public delegate RESULT DSP_GETUSERDATA_FUNC (ref DSP_STATE dsp_state, out IntPtr userdata); + public delegate RESULT DSP_DFT_FFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr signal, IntPtr dft, IntPtr window, int signalhop); + public delegate RESULT DSP_DFT_IFFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr dft, IntPtr signal, IntPtr window, int signalhop); + public delegate RESULT DSP_PAN_SUMMONOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float lowFrequencyGain, float overallGain, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSTEREOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float pan, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix, DSP_PAN_SURROUND_FLAGS flags); + public delegate RESULT DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_GETROLLOFFGAIN_FUNC (ref DSP_STATE dsp_state, DSP_PAN_3D_ROLLOFF_TYPE rolloff, float distance, float mindistance, float maxdistance, out float gain); + + + public enum DSP_TYPE : int + { + UNKNOWN, + MIXER, + OSCILLATOR, + LOWPASS, + ITLOWPASS, + HIGHPASS, + ECHO, + FADER, + FLANGE, + DISTORTION, + NORMALIZE, + LIMITER, + PARAMEQ, + PITCHSHIFT, + CHORUS, + VSTPLUGIN, + WINAMPPLUGIN, + ITECHO, + COMPRESSOR, + SFXREVERB, + LOWPASS_SIMPLE, + DELAY, + TREMOLO, + LADSPAPLUGIN, + SEND, + RETURN, + HIGHPASS_SIMPLE, + PAN, + THREE_EQ, + FFT, + LOUDNESS_METER, + ENVELOPEFOLLOWER, + CONVOLUTIONREVERB, + CHANNELMIX, + TRANSCEIVER, + OBJECTPAN, + MULTIBAND_EQ, + MAX + } + + public enum DSP_PARAMETER_TYPE + { + FLOAT = 0, + INT, + BOOL, + DATA, + MAX + } + + public enum DSP_PARAMETER_FLOAT_MAPPING_TYPE + { + DSP_PARAMETER_FLOAT_MAPPING_TYPE_LINEAR = 0, + DSP_PARAMETER_FLOAT_MAPPING_TYPE_AUTO, + DSP_PARAMETER_FLOAT_MAPPING_TYPE_PIECEWISE_LINEAR, + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FLOAT_MAPPING_PIECEWISE_LINEAR + { + public int numpoints; + public IntPtr pointparamvalues; + public IntPtr pointpositions; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FLOAT_MAPPING + { + public DSP_PARAMETER_FLOAT_MAPPING_TYPE type; + public DSP_PARAMETER_FLOAT_MAPPING_PIECEWISE_LINEAR piecewiselinearmapping; + } + + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_FLOAT + { + public float min; + public float max; + public float defaultval; + public DSP_PARAMETER_FLOAT_MAPPING mapping; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_INT + { + public int min; + public int max; + public int defaultval; + public bool goestoinf; + public IntPtr valuenames; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_BOOL + { + public bool defaultval; + public IntPtr valuenames; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_DATA + { + public int datatype; + } + + [StructLayout(LayoutKind.Explicit)] + public struct DSP_PARAMETER_DESC_UNION + { + [FieldOffset(0)] + public DSP_PARAMETER_DESC_FLOAT floatdesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_INT intdesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_BOOL booldesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_DATA datadesc; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC + { + public DSP_PARAMETER_TYPE type; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[] name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[] label; + public string description; + + public DSP_PARAMETER_DESC_UNION desc; + } + + public enum DSP_PARAMETER_DATA_TYPE + { + DSP_PARAMETER_DATA_TYPE_USER = 0, + DSP_PARAMETER_DATA_TYPE_OVERALLGAIN = -1, + DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES = -2, + DSP_PARAMETER_DATA_TYPE_SIDECHAIN = -3, + DSP_PARAMETER_DATA_TYPE_FFT = -4, + DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES_MULTI = -5, + DSP_PARAMETER_DATA_TYPE_ATTENUATION_RANGE = -6 + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_OVERALLGAIN + { + public float linear_gain; + public float linear_gain_additive; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_3DATTRIBUTES + { + public ATTRIBUTES_3D relative; + public ATTRIBUTES_3D absolute; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_3DATTRIBUTES_MULTI + { + public int numlisteners; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public ATTRIBUTES_3D[] relative; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public float[] weight; + public ATTRIBUTES_3D absolute; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_SIDECHAIN + { + public int sidechainenable; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FFT + { + public int length; + public int numchannels; + + [MarshalAs(UnmanagedType.ByValArray,SizeConst=32)] + private IntPtr[] spectrum_internal; + + public float[][] spectrum + { + get + { + var buffer = new float[numchannels][]; + + for (int i = 0; i < numchannels; ++i) + { + buffer[i] = new float[length]; + Marshal.Copy(spectrum_internal[i], buffer[i], 0, length); + } + + return buffer; + } + } + + public void getSpectrum(ref float[][] buffer) + { + int bufferLength = Math.Min(buffer.Length, numchannels); + for (int i = 0; i < bufferLength; ++i) + { + getSpectrum(i, ref buffer[i]); + } + } + + public void getSpectrum(int channel, ref float[] buffer) + { + int bufferLength = Math.Min(buffer.Length, length); + Marshal.Copy(spectrum_internal[channel], buffer, 0, bufferLength); + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_LOUDNESS_METER_INFO_TYPE + { + public float momentaryloudness; + public float shorttermloudness; + public float integratedloudness; + public float loudness10thpercentile; + public float loudness95thpercentile; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 66)] + public float[] loudnesshistogram; + public float maxtruepeak; + public float maxmomentaryloudness; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_LOUDNESS_METER_WEIGHTING_TYPE + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public float[] channelweight; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_ATTENUATION_RANGE + { + public float min; + public float max; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_DESCRIPTION + { + public uint pluginsdkversion; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] name; + public uint version; + public int numinputbuffers; + public int numoutputbuffers; + public DSP_CREATE_CALLBACK create; + public DSP_RELEASE_CALLBACK release; + public DSP_RESET_CALLBACK reset; + public DSP_READ_CALLBACK read; + public DSP_PROCESS_CALLBACK process; + public DSP_SETPOSITION_CALLBACK setposition; + + public int numparameters; + public IntPtr paramdesc; + public DSP_SETPARAM_FLOAT_CALLBACK setparameterfloat; + public DSP_SETPARAM_INT_CALLBACK setparameterint; + public DSP_SETPARAM_BOOL_CALLBACK setparameterbool; + public DSP_SETPARAM_DATA_CALLBACK setparameterdata; + public DSP_GETPARAM_FLOAT_CALLBACK getparameterfloat; + public DSP_GETPARAM_INT_CALLBACK getparameterint; + public DSP_GETPARAM_BOOL_CALLBACK getparameterbool; + public DSP_GETPARAM_DATA_CALLBACK getparameterdata; + public DSP_SHOULDIPROCESS_CALLBACK shouldiprocess; + public IntPtr userdata; + + public DSP_SYSTEM_REGISTER_CALLBACK sys_register; + public DSP_SYSTEM_DEREGISTER_CALLBACK sys_deregister; + public DSP_SYSTEM_MIX_CALLBACK sys_mix; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_DFT_FUNCTIONS + { + public DSP_DFT_FFTREAL_FUNC fftreal; + public DSP_DFT_IFFTREAL_FUNC inversefftreal; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_PAN_FUNCTIONS + { + public DSP_PAN_SUMMONOMATRIX_FUNC summonomatrix; + public DSP_PAN_SUMSTEREOMATRIX_FUNC sumstereomatrix; + public DSP_PAN_SUMSURROUNDMATRIX_FUNC sumsurroundmatrix; + public DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC summonotosurroundmatrix; + public DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC sumstereotosurroundmatrix; + public DSP_PAN_GETROLLOFFGAIN_FUNC getrolloffgain; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_FUNCTIONS + { + public DSP_ALLOC_FUNC alloc; + public DSP_REALLOC_FUNC realloc; + public DSP_FREE_FUNC free; + public DSP_GETSAMPLERATE_FUNC getsamplerate; + public DSP_GETBLOCKSIZE_FUNC getblocksize; + public IntPtr dft; + public IntPtr pan; + public DSP_GETSPEAKERMODE_FUNC getspeakermode; + public DSP_GETCLOCK_FUNC getclock; + public DSP_GETLISTENERATTRIBUTES_FUNC getlistenerattributes; + public DSP_LOG_FUNC log; + public DSP_GETUSERDATA_FUNC getuserdata; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE + { + public IntPtr instance; + public IntPtr plugindata; + public uint channelmask; + public int source_speakermode; + public IntPtr sidechaindata; + public int sidechainchannels; + public IntPtr functions; + public int systemobject; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_METERING_INFO + { + public int numsamples; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] + public float[] peaklevel; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] + public float[] rmslevel; + public short numchannels; + } + + /* + ============================================================================================================== + + FMOD built in effect parameters. + Use DSP::setParameter with these enums for the 'index' parameter. + + ============================================================================================================== + */ + + public enum DSP_OSCILLATOR : int + { + TYPE, + RATE + } + + public enum DSP_LOWPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_ITLOWPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_HIGHPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_ECHO : int + { + DELAY, + FEEDBACK, + DRYLEVEL, + WETLEVEL + } + + public enum DSP_FADER : int + { + GAIN, + OVERALL_GAIN, + } + + public enum DSP_DELAY : int + { + CH0, + CH1, + CH2, + CH3, + CH4, + CH5, + CH6, + CH7, + CH8, + CH9, + CH10, + CH11, + CH12, + CH13, + CH14, + CH15, + MAXDELAY, + } + + public enum DSP_FLANGE : int + { + MIX, + DEPTH, + RATE + } + + public enum DSP_TREMOLO : int + { + FREQUENCY, + DEPTH, + SHAPE, + SKEW, + DUTY, + SQUARE, + PHASE, + SPREAD + } + + public enum DSP_DISTORTION : int + { + LEVEL + } + + public enum DSP_NORMALIZE : int + { + FADETIME, + THRESHOLD, + MAXAMP + } + + public enum DSP_LIMITER : int + { + RELEASETIME, + CEILING, + MAXIMIZERGAIN, + MODE, + } + + public enum DSP_PARAMEQ : int + { + CENTER, + BANDWIDTH, + GAIN + } + + public enum DSP_MULTIBAND_EQ : int + { + A_FILTER, + A_FREQUENCY, + A_Q, + A_GAIN, + B_FILTER, + B_FREQUENCY, + B_Q, + B_GAIN, + C_FILTER, + C_FREQUENCY, + C_Q, + C_GAIN, + D_FILTER, + D_FREQUENCY, + D_Q, + D_GAIN, + E_FILTER, + E_FREQUENCY, + E_Q, + E_GAIN, + } + + public enum DSP_MULTIBAND_EQ_FILTER_TYPE : int + { + DISABLED, + LOWPASS_12DB, + LOWPASS_24DB, + LOWPASS_48DB, + HIGHPASS_12DB, + HIGHPASS_24DB, + HIGHPASS_48DB, + LOWSHELF, + HIGHSHELF, + PEAKING, + BANDPASS, + NOTCH, + ALLPASS, + } + + public enum DSP_PITCHSHIFT : int + { + PITCH, + FFTSIZE, + OVERLAP, + MAXCHANNELS + } + + public enum DSP_CHORUS : int + { + MIX, + RATE, + DEPTH, + } + + public enum DSP_ITECHO : int + { + WETDRYMIX, + FEEDBACK, + LEFTDELAY, + RIGHTDELAY, + PANDELAY + } + + public enum DSP_COMPRESSOR : int + { + THRESHOLD, + RATIO, + ATTACK, + RELEASE, + GAINMAKEUP, + USESIDECHAIN, + LINKED + } + + public enum DSP_SFXREVERB : int + { + DECAYTIME, + EARLYDELAY, + LATEDELAY, + HFREFERENCE, + HFDECAYRATIO, + DIFFUSION, + DENSITY, + LOWSHELFFREQUENCY, + LOWSHELFGAIN, + HIGHCUT, + EARLYLATEMIX, + WETLEVEL, + DRYLEVEL + } + + public enum DSP_LOWPASS_SIMPLE : int + { + CUTOFF + } + + public enum DSP_SEND : int + { + RETURNID, + LEVEL, + } + + public enum DSP_RETURN : int + { + ID, + INPUT_SPEAKER_MODE + } + + public enum DSP_HIGHPASS_SIMPLE : int + { + CUTOFF + } + + public enum DSP_PAN_2D_STEREO_MODE_TYPE : int + { + DISTRIBUTED, + DISCRETE + } + + public enum DSP_PAN_MODE_TYPE : int + { + MONO, + STEREO, + SURROUND + } + + public enum DSP_PAN_3D_ROLLOFF_TYPE : int + { + LINEARSQUARED, + LINEAR, + INVERSE, + INVERSETAPERED, + CUSTOM + } + + public enum DSP_PAN_3D_EXTENT_MODE_TYPE : int + { + AUTO, + USER, + OFF + } + + public enum DSP_PAN : int + { + MODE, + _2D_STEREO_POSITION, + _2D_DIRECTION, + _2D_EXTENT, + _2D_ROTATION, + _2D_LFE_LEVEL, + _2D_STEREO_MODE, + _2D_STEREO_SEPARATION, + _2D_STEREO_AXIS, + ENABLED_SPEAKERS, + _3D_POSITION, + _3D_ROLLOFF, + _3D_MIN_DISTANCE, + _3D_MAX_DISTANCE, + _3D_EXTENT_MODE, + _3D_SOUND_SIZE, + _3D_MIN_EXTENT, + _3D_PAN_BLEND, + LFE_UPMIX_ENABLED, + OVERALL_GAIN, + SURROUND_SPEAKER_MODE, + _2D_HEIGHT_BLEND, + ATTENUATION_RANGE, + OVERRIDE_RANGE + } + + public enum DSP_THREE_EQ_CROSSOVERSLOPE_TYPE : int + { + _12DB, + _24DB, + _48DB + } + + public enum DSP_THREE_EQ : int + { + LOWGAIN, + MIDGAIN, + HIGHGAIN, + LOWCROSSOVER, + HIGHCROSSOVER, + CROSSOVERSLOPE + } + + public enum DSP_FFT_WINDOW : int + { + RECT, + TRIANGLE, + HAMMING, + HANNING, + BLACKMAN, + BLACKMANHARRIS + } + + public enum DSP_FFT : int + { + WINDOWSIZE, + WINDOWTYPE, + SPECTRUMDATA, + DOMINANT_FREQ + } + + + public enum DSP_LOUDNESS_METER : int + { + STATE, + WEIGHTING, + INFO + } + + + public enum DSP_LOUDNESS_METER_STATE_TYPE : int + { + RESET_INTEGRATED = -3, + RESET_MAXPEAK = -2, + RESET_ALL = -1, + PAUSED = 0, + ANALYZING = 1 + } + + public enum DSP_ENVELOPEFOLLOWER : int + { + ATTACK, + RELEASE, + ENVELOPE, + USESIDECHAIN + } + + public enum DSP_CONVOLUTION_REVERB : int + { + IR, + WET, + DRY, + LINKED + } + + public enum DSP_CHANNELMIX_OUTPUT : int + { + DEFAULT, + ALLMONO, + ALLSTEREO, + ALLQUAD, + ALL5POINT1, + ALL7POINT1, + ALLLFE, + ALL7POINT1POINT4 + } + + public enum DSP_CHANNELMIX : int + { + OUTPUTGROUPING, + GAIN_CH0, + GAIN_CH1, + GAIN_CH2, + GAIN_CH3, + GAIN_CH4, + GAIN_CH5, + GAIN_CH6, + GAIN_CH7, + GAIN_CH8, + GAIN_CH9, + GAIN_CH10, + GAIN_CH11, + GAIN_CH12, + GAIN_CH13, + GAIN_CH14, + GAIN_CH15, + GAIN_CH16, + GAIN_CH17, + GAIN_CH18, + GAIN_CH19, + GAIN_CH20, + GAIN_CH21, + GAIN_CH22, + GAIN_CH23, + GAIN_CH24, + GAIN_CH25, + GAIN_CH26, + GAIN_CH27, + GAIN_CH28, + GAIN_CH29, + GAIN_CH30, + GAIN_CH31, + OUTPUT_CH0, + OUTPUT_CH1, + OUTPUT_CH2, + OUTPUT_CH3, + OUTPUT_CH4, + OUTPUT_CH5, + OUTPUT_CH6, + OUTPUT_CH7, + OUTPUT_CH8, + OUTPUT_CH9, + OUTPUT_CH10, + OUTPUT_CH11, + OUTPUT_CH12, + OUTPUT_CH13, + OUTPUT_CH14, + OUTPUT_CH15, + OUTPUT_CH16, + OUTPUT_CH17, + OUTPUT_CH18, + OUTPUT_CH19, + OUTPUT_CH20, + OUTPUT_CH21, + OUTPUT_CH22, + OUTPUT_CH23, + OUTPUT_CH24, + OUTPUT_CH25, + OUTPUT_CH26, + OUTPUT_CH27, + OUTPUT_CH28, + OUTPUT_CH29, + OUTPUT_CH30, + OUTPUT_CH31, + } + + public enum DSP_TRANSCEIVER_SPEAKERMODE : int + { + AUTO = -1, + MONO = 0, + STEREO, + SURROUND, + } + + public enum DSP_TRANSCEIVER : int + { + TRANSMIT, + GAIN, + CHANNEL, + TRANSMITSPEAKERMODE + } + + public enum DSP_OBJECTPAN : int + { + _3D_POSITION, + _3D_ROLLOFF, + _3D_MIN_DISTANCE, + _3D_MAX_DISTANCE, + _3D_EXTENT_MODE, + _3D_SOUND_SIZE, + _3D_MIN_EXTENT, + OVERALL_GAIN, + OUTPUTGAIN, + ATTENUATION_RANGE, + OVERRIDE_RANGE + } +} diff --git a/Assets/Plugins/FMOD/src/fmod_dsp.cs.meta b/Assets/Plugins/FMOD/src/fmod_dsp.cs.meta new file mode 100644 index 0000000..5d5c6ab --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_dsp.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7b10c26cf550794183b926ffae615a7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/fmod_errors.cs b/Assets/Plugins/FMOD/src/fmod_errors.cs new file mode 100644 index 0000000..5276112 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_errors.cs @@ -0,0 +1,106 @@ +/* ============================================================================================== */ +/* FMOD Core / Studio API - Error string header file. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */ +/* */ +/* Use this header if you want to store or display a string version / english explanation */ +/* of the FMOD error codes. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/docs/2.02/api/core-api-common.html#fmod_result */ +/* =============================================================================================== */ + +namespace FMOD +{ + public class Error + { + public static string String(FMOD.RESULT errcode) + { + switch (errcode) + { + case FMOD.RESULT.OK: return "No errors."; + case FMOD.RESULT.ERR_BADCOMMAND: return "Tried to call a function on a data type that does not allow this type of functionality (ie calling Sound::lock on a streaming sound)."; + case FMOD.RESULT.ERR_CHANNEL_ALLOC: return "Error trying to allocate a channel."; + case FMOD.RESULT.ERR_CHANNEL_STOLEN: return "The specified channel has been reused to play another sound."; + case FMOD.RESULT.ERR_DMA: return "DMA Failure. See debug output for more information."; + case FMOD.RESULT.ERR_DSP_CONNECTION: return "DSP connection error. Connection possibly caused a cyclic dependency or connected dsps with incompatible buffer counts."; + case FMOD.RESULT.ERR_DSP_DONTPROCESS: return "DSP return code from a DSP process query callback. Tells mixer not to call the process callback and therefore not consume CPU. Use this to optimize the DSP graph."; + case FMOD.RESULT.ERR_DSP_FORMAT: return "DSP Format error. A DSP unit may have attempted to connect to this network with the wrong format, or a matrix may have been set with the wrong size if the target unit has a specified channel map."; + case FMOD.RESULT.ERR_DSP_INUSE: return "DSP is already in the mixer's DSP network. It must be removed before being reinserted or released."; + case FMOD.RESULT.ERR_DSP_NOTFOUND: return "DSP connection error. Couldn't find the DSP unit specified."; + case FMOD.RESULT.ERR_DSP_RESERVED: return "DSP operation error. Cannot perform operation on this DSP as it is reserved by the system."; + case FMOD.RESULT.ERR_DSP_SILENCE: return "DSP return code from a DSP process query callback. Tells mixer silence would be produced from read, so go idle and not consume CPU. Use this to optimize the DSP graph."; + case FMOD.RESULT.ERR_DSP_TYPE: return "DSP operation cannot be performed on a DSP of this type."; + case FMOD.RESULT.ERR_FILE_BAD: return "Error loading file."; + case FMOD.RESULT.ERR_FILE_COULDNOTSEEK: return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format."; + case FMOD.RESULT.ERR_FILE_DISKEJECTED: return "Media was ejected while reading."; + case FMOD.RESULT.ERR_FILE_EOF: return "End of file unexpectedly reached while trying to read essential data (truncated?)."; + case FMOD.RESULT.ERR_FILE_ENDOFDATA: return "End of current chunk reached while trying to read data."; + case FMOD.RESULT.ERR_FILE_NOTFOUND: return "File not found."; + case FMOD.RESULT.ERR_FORMAT: return "Unsupported file or audio format."; + case FMOD.RESULT.ERR_HEADER_MISMATCH: return "There is a version mismatch between the FMOD header and either the FMOD Studio library or the FMOD Low Level library."; + case FMOD.RESULT.ERR_HTTP: return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere."; + case FMOD.RESULT.ERR_HTTP_ACCESS: return "The specified resource requires authentication or is forbidden."; + case FMOD.RESULT.ERR_HTTP_PROXY_AUTH: return "Proxy authentication is required to access the specified resource."; + case FMOD.RESULT.ERR_HTTP_SERVER_ERROR: return "A HTTP server error occurred."; + case FMOD.RESULT.ERR_HTTP_TIMEOUT: return "The HTTP request timed out."; + case FMOD.RESULT.ERR_INITIALIZATION: return "FMOD was not initialized correctly to support this function."; + case FMOD.RESULT.ERR_INITIALIZED: return "Cannot call this command after System::init."; + case FMOD.RESULT.ERR_INTERNAL: return "An error occured in the FMOD system. Use the logging version of FMOD for more information."; + case FMOD.RESULT.ERR_INVALID_FLOAT: return "Value passed in was a NaN, Inf or denormalized float."; + case FMOD.RESULT.ERR_INVALID_HANDLE: return "An invalid object handle was used."; + case FMOD.RESULT.ERR_INVALID_PARAM: return "An invalid parameter was passed to this function."; + case FMOD.RESULT.ERR_INVALID_POSITION: return "An invalid seek position was passed to this function."; + case FMOD.RESULT.ERR_INVALID_SPEAKER: return "An invalid speaker was passed to this function based on the current speaker mode."; + case FMOD.RESULT.ERR_INVALID_SYNCPOINT: return "The syncpoint did not come from this sound handle."; + case FMOD.RESULT.ERR_INVALID_THREAD: return "Tried to call a function on a thread that is not supported."; + case FMOD.RESULT.ERR_INVALID_VECTOR: return "The vectors passed in are not unit length, or perpendicular."; + case FMOD.RESULT.ERR_MAXAUDIBLE: return "Reached maximum audible playback count for this sound's soundgroup."; + case FMOD.RESULT.ERR_MEMORY: return "Not enough memory or resources."; + case FMOD.RESULT.ERR_MEMORY_CANTPOINT: return "Can't use FMOD_OPENMEMORY_POINT on non PCM source data, or non mp3/xma/adpcm data if FMOD_CREATECOMPRESSEDSAMPLE was used."; + case FMOD.RESULT.ERR_NEEDS3D: return "Tried to call a command on a 2d sound when the command was meant for 3d sound."; + case FMOD.RESULT.ERR_NEEDSHARDWARE: return "Tried to use a feature that requires hardware support."; + case FMOD.RESULT.ERR_NET_CONNECT: return "Couldn't connect to the specified host."; + case FMOD.RESULT.ERR_NET_SOCKET_ERROR: return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere."; + case FMOD.RESULT.ERR_NET_URL: return "The specified URL couldn't be resolved."; + case FMOD.RESULT.ERR_NET_WOULD_BLOCK: return "Operation on a non-blocking socket could not complete immediately."; + case FMOD.RESULT.ERR_NOTREADY: return "Operation could not be performed because specified sound/DSP connection is not ready."; + case FMOD.RESULT.ERR_OUTPUT_ALLOCATED: return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused."; + case FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER: return "Error creating hardware sound buffer."; + case FMOD.RESULT.ERR_OUTPUT_DRIVERCALL: return "A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted."; + case FMOD.RESULT.ERR_OUTPUT_FORMAT: return "Soundcard does not support the specified format."; + case FMOD.RESULT.ERR_OUTPUT_INIT: return "Error initializing output device."; + case FMOD.RESULT.ERR_OUTPUT_NODRIVERS: return "The output device has no drivers installed. If pre-init, FMOD_OUTPUT_NOSOUND is selected as the output mode. If post-init, the function just fails."; + case FMOD.RESULT.ERR_PLUGIN: return "An unspecified error has been returned from a plugin."; + case FMOD.RESULT.ERR_PLUGIN_MISSING: return "A requested output, dsp unit type or codec was not available."; + case FMOD.RESULT.ERR_PLUGIN_RESOURCE: return "A resource that the plugin requires cannot be allocated or found. (ie the DLS file for MIDI playback)"; + case FMOD.RESULT.ERR_PLUGIN_VERSION: return "A plugin was built with an unsupported SDK version."; + case FMOD.RESULT.ERR_RECORD: return "An error occurred trying to initialize the recording device."; + case FMOD.RESULT.ERR_REVERB_CHANNELGROUP: return "Reverb properties cannot be set on this channel because a parent channelgroup owns the reverb connection."; + case FMOD.RESULT.ERR_REVERB_INSTANCE: return "Specified instance in FMOD_REVERB_PROPERTIES couldn't be set. Most likely because it is an invalid instance number or the reverb doesn't exist."; + case FMOD.RESULT.ERR_SUBSOUNDS: return "The error occurred because the sound referenced contains subsounds when it shouldn't have, or it doesn't contain subsounds when it should have. The operation may also not be able to be performed on a parent sound."; + case FMOD.RESULT.ERR_SUBSOUND_ALLOCATED: return "This subsound is already being used by another sound, you cannot have more than one parent to a sound. Null out the other parent's entry first."; + case FMOD.RESULT.ERR_SUBSOUND_CANTMOVE: return "Shared subsounds cannot be replaced or moved from their parent stream, such as when the parent stream is an FSB file."; + case FMOD.RESULT.ERR_TAGNOTFOUND: return "The specified tag could not be found or there are no tags."; + case FMOD.RESULT.ERR_TOOMANYCHANNELS: return "The sound created exceeds the allowable input channel count. This can be increased using the 'maxinputchannels' parameter in System::setSoftwareFormat."; + case FMOD.RESULT.ERR_TRUNCATED: return "The retrieved string is too long to fit in the supplied buffer and has been truncated."; + case FMOD.RESULT.ERR_UNIMPLEMENTED: return "Something in FMOD hasn't been implemented when it should be. Contact support."; + case FMOD.RESULT.ERR_UNINITIALIZED: return "This command failed because System::init or System::setDriver was not called."; + case FMOD.RESULT.ERR_UNSUPPORTED: return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified."; + case FMOD.RESULT.ERR_VERSION: return "The version number of this file format is not supported."; + case FMOD.RESULT.ERR_EVENT_ALREADY_LOADED: return "The specified bank has already been loaded."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_BUSY: return "The live update connection failed due to the game already being connected."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_MISMATCH: return "The live update connection failed due to the game data being out of sync with the tool."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_TIMEOUT: return "The live update connection timed out."; + case FMOD.RESULT.ERR_EVENT_NOTFOUND: return "The requested event, bus or vca could not be found."; + case FMOD.RESULT.ERR_STUDIO_UNINITIALIZED: return "The Studio::System object is not yet initialized."; + case FMOD.RESULT.ERR_STUDIO_NOT_LOADED: return "The specified resource is not loaded, so it can't be unloaded."; + case FMOD.RESULT.ERR_INVALID_STRING: return "An invalid string was passed to this function."; + case FMOD.RESULT.ERR_ALREADY_LOCKED: return "The specified resource is already locked."; + case FMOD.RESULT.ERR_NOT_LOCKED: return "The specified resource is not locked, so it can't be unlocked."; + case FMOD.RESULT.ERR_RECORD_DISCONNECTED: return "The specified recording driver has been disconnected."; + case FMOD.RESULT.ERR_TOOMANYSAMPLES: return "The length provided exceed the allowable limit."; + default: return "Unknown error."; + } + } + } +} diff --git a/Assets/Plugins/FMOD/src/fmod_errors.cs.meta b/Assets/Plugins/FMOD/src/fmod_errors.cs.meta new file mode 100644 index 0000000..2b15a75 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_errors.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6e0992509b0077e479d2da05c8f52eb0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/src/fmod_studio.cs b/Assets/Plugins/FMOD/src/fmod_studio.cs new file mode 100644 index 0000000..11f6ce0 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_studio.cs @@ -0,0 +1,2250 @@ +/* ======================================================================================== */ +/* FMOD Studio API - C# wrapper. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/docs/2.02/api/studio-api.html */ +/* ======================================================================================== */ + +using System; +using System.Text; +using System.Runtime.InteropServices; +using System.Collections; + +namespace FMOD.Studio +{ + public partial class STUDIO_VERSION + { +#if !UNITY_2019_4_OR_NEWER + public const string dll = "fmodstudio"; +#endif + } + + public enum STOP_MODE : int + { + ALLOWFADEOUT, + IMMEDIATE, + } + + public enum LOADING_STATE : int + { + UNLOADING, + UNLOADED, + LOADING, + LOADED, + ERROR, + } + + [StructLayout(LayoutKind.Sequential)] + public struct PROGRAMMER_SOUND_PROPERTIES + { + public StringWrapper name; + public IntPtr sound; + public int subsoundIndex; + } + + [StructLayout(LayoutKind.Sequential)] + public struct TIMELINE_MARKER_PROPERTIES + { + public StringWrapper name; + public int position; + } + + [StructLayout(LayoutKind.Sequential)] + public struct TIMELINE_BEAT_PROPERTIES + { + public int bar; + public int beat; + public int position; + public float tempo; + public int timesignatureupper; + public int timesignaturelower; + } + + [StructLayout(LayoutKind.Sequential)] + public struct TIMELINE_NESTED_BEAT_PROPERTIES + { + public GUID eventid; + public TIMELINE_BEAT_PROPERTIES properties; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ADVANCEDSETTINGS + { + public int cbsize; + public int commandqueuesize; + public int handleinitialsize; + public int studioupdateperiod; + public int idlesampledatapoolsize; + public int streamingscheduledelay; + public IntPtr encryptionkey; + } + + [StructLayout(LayoutKind.Sequential)] + public struct CPU_USAGE + { + public float update; + } + + [StructLayout(LayoutKind.Sequential)] + public struct BUFFER_INFO + { + public int currentusage; + public int peakusage; + public int capacity; + public int stallcount; + public float stalltime; + } + + [StructLayout(LayoutKind.Sequential)] + public struct BUFFER_USAGE + { + public BUFFER_INFO studiocommandqueue; + public BUFFER_INFO studiohandle; + } + + [StructLayout(LayoutKind.Sequential)] + public struct BANK_INFO + { + public int size; + public IntPtr userdata; + public int userdatalength; + public FILE_OPEN_CALLBACK opencallback; + public FILE_CLOSE_CALLBACK closecallback; + public FILE_READ_CALLBACK readcallback; + public FILE_SEEK_CALLBACK seekcallback; + } + + [Flags] + public enum SYSTEM_CALLBACK_TYPE : uint + { + PREUPDATE = 0x00000001, + POSTUPDATE = 0x00000002, + BANK_UNLOAD = 0x00000004, + LIVEUPDATE_CONNECTED = 0x00000008, + LIVEUPDATE_DISCONNECTED = 0x00000010, + ALL = 0xFFFFFFFF, + } + + public delegate RESULT SYSTEM_CALLBACK(IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata, IntPtr userdata); + + public enum PARAMETER_TYPE : int + { + GAME_CONTROLLED, + AUTOMATIC_DISTANCE, + AUTOMATIC_EVENT_CONE_ANGLE, + AUTOMATIC_EVENT_ORIENTATION, + AUTOMATIC_DIRECTION, + AUTOMATIC_ELEVATION, + AUTOMATIC_LISTENER_ORIENTATION, + AUTOMATIC_SPEED, + AUTOMATIC_SPEED_ABSOLUTE, + AUTOMATIC_DISTANCE_NORMALIZED, + MAX + } + + [Flags] + public enum PARAMETER_FLAGS : uint + { + READONLY = 0x00000001, + AUTOMATIC = 0x00000002, + GLOBAL = 0x00000004, + DISCRETE = 0x00000008, + LABELED = 0x00000010, + } + + [StructLayout(LayoutKind.Sequential)] + public struct PARAMETER_ID + { + public uint data1; + public uint data2; + } + + [StructLayout(LayoutKind.Sequential)] + public struct PARAMETER_DESCRIPTION + { + public StringWrapper name; + public PARAMETER_ID id; + public float minimum; + public float maximum; + public float defaultvalue; + public PARAMETER_TYPE type; + public PARAMETER_FLAGS flags; + public GUID guid; + } + + // This is only need for loading memory and given our C# wrapper LOAD_MEMORY_POINT isn't feasible anyway + enum LOAD_MEMORY_MODE : int + { + LOAD_MEMORY, + LOAD_MEMORY_POINT, + } + + enum LOAD_MEMORY_ALIGNMENT : int + { + VALUE = 32 + } + + [StructLayout(LayoutKind.Sequential)] + public struct SOUND_INFO + { + public IntPtr name_or_data; + public MODE mode; + public CREATESOUNDEXINFO exinfo; + public int subsoundindex; + + public string name + { + get + { + using (StringHelper.ThreadSafeEncoding encoding = StringHelper.GetFreeHelper()) + { + return ((mode & (MODE.OPENMEMORY | MODE.OPENMEMORY_POINT)) == 0) ? encoding.stringFromNative(name_or_data) : String.Empty; + } + } + } + } + + public enum USER_PROPERTY_TYPE : int + { + INTEGER, + BOOLEAN, + FLOAT, + STRING, + } + + [StructLayout(LayoutKind.Sequential)] + public struct USER_PROPERTY + { + public StringWrapper name; + public USER_PROPERTY_TYPE type; + private Union_IntBoolFloatString value; + + public int intValue() { return (type == USER_PROPERTY_TYPE.INTEGER) ? value.intvalue : -1; } + public bool boolValue() { return (type == USER_PROPERTY_TYPE.BOOLEAN) ? value.boolvalue : false; } + public float floatValue() { return (type == USER_PROPERTY_TYPE.FLOAT) ? value.floatvalue : -1; } + public string stringValue() { return (type == USER_PROPERTY_TYPE.STRING) ? value.stringvalue : ""; } + }; + + [StructLayout(LayoutKind.Explicit)] + struct Union_IntBoolFloatString + { + [FieldOffset(0)] + public int intvalue; + [FieldOffset(0)] + public bool boolvalue; + [FieldOffset(0)] + public float floatvalue; + [FieldOffset(0)] + public StringWrapper stringvalue; + } + + [Flags] + public enum INITFLAGS : uint + { + NORMAL = 0x00000000, + LIVEUPDATE = 0x00000001, + ALLOW_MISSING_PLUGINS = 0x00000002, + SYNCHRONOUS_UPDATE = 0x00000004, + DEFERRED_CALLBACKS = 0x00000008, + LOAD_FROM_UPDATE = 0x00000010, + MEMORY_TRACKING = 0x00000020, + } + + [Flags] + public enum LOAD_BANK_FLAGS : uint + { + NORMAL = 0x00000000, + NONBLOCKING = 0x00000001, + DECOMPRESS_SAMPLES = 0x00000002, + UNENCRYPTED = 0x00000004, + } + + [Flags] + public enum COMMANDCAPTURE_FLAGS : uint + { + NORMAL = 0x00000000, + FILEFLUSH = 0x00000001, + SKIP_INITIAL_STATE = 0x00000002, + } + + [Flags] + public enum COMMANDREPLAY_FLAGS : uint + { + NORMAL = 0x00000000, + SKIP_CLEANUP = 0x00000001, + FAST_FORWARD = 0x00000002, + SKIP_BANK_LOAD = 0x00000004, + } + + public enum PLAYBACK_STATE : int + { + PLAYING, + SUSTAINING, + STOPPED, + STARTING, + STOPPING, + } + + public enum EVENT_PROPERTY : int + { + CHANNELPRIORITY, + SCHEDULE_DELAY, + SCHEDULE_LOOKAHEAD, + MINIMUM_DISTANCE, + MAXIMUM_DISTANCE, + COOLDOWN, + MAX + }; + + [StructLayout(LayoutKind.Sequential)] + public struct PLUGIN_INSTANCE_PROPERTIES + { + public IntPtr name; + public IntPtr dsp; + } + + [Flags] + public enum EVENT_CALLBACK_TYPE : uint + { + CREATED = 0x00000001, + DESTROYED = 0x00000002, + STARTING = 0x00000004, + STARTED = 0x00000008, + RESTARTED = 0x00000010, + STOPPED = 0x00000020, + START_FAILED = 0x00000040, + CREATE_PROGRAMMER_SOUND = 0x00000080, + DESTROY_PROGRAMMER_SOUND = 0x00000100, + PLUGIN_CREATED = 0x00000200, + PLUGIN_DESTROYED = 0x00000400, + TIMELINE_MARKER = 0x00000800, + TIMELINE_BEAT = 0x00001000, + SOUND_PLAYED = 0x00002000, + SOUND_STOPPED = 0x00004000, + REAL_TO_VIRTUAL = 0x00008000, + VIRTUAL_TO_REAL = 0x00010000, + START_EVENT_COMMAND = 0x00020000, + NESTED_TIMELINE_BEAT = 0x00040000, + + ALL = 0xFFFFFFFF, + } + + public delegate RESULT EVENT_CALLBACK(EVENT_CALLBACK_TYPE type, IntPtr _event, IntPtr parameters); + + public delegate RESULT COMMANDREPLAY_FRAME_CALLBACK(IntPtr replay, int commandindex, float currenttime, IntPtr userdata); + public delegate RESULT COMMANDREPLAY_LOAD_BANK_CALLBACK(IntPtr replay, int commandindex, GUID bankguid, IntPtr bankfilename, LOAD_BANK_FLAGS flags, out IntPtr bank, IntPtr userdata); + public delegate RESULT COMMANDREPLAY_CREATE_INSTANCE_CALLBACK(IntPtr replay, int commandindex, IntPtr eventdescription, out IntPtr instance, IntPtr userdata); + + public enum INSTANCETYPE : int + { + NONE, + SYSTEM, + EVENTDESCRIPTION, + EVENTINSTANCE, + PARAMETERINSTANCE, + BUS, + VCA, + BANK, + COMMANDREPLAY, + } + + [StructLayout(LayoutKind.Sequential)] + public struct COMMAND_INFO + { + public StringWrapper commandname; + public int parentcommandindex; + public int framenumber; + public float frametime; + public INSTANCETYPE instancetype; + public INSTANCETYPE outputtype; + public UInt32 instancehandle; + public UInt32 outputhandle; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MEMORY_USAGE + { + public int exclusive; + public int inclusive; + public int sampledata; + } + + public struct Util + { + public static RESULT parseID(string idString, out GUID id) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_ParseID(encoder.byteFromStringUTF8(idString), out id); + } + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_ParseID(byte[] idString, out GUID id); + #endregion + } + + public struct System + { + // Initialization / system functions. + public static RESULT create(out System system) + { + return FMOD_Studio_System_Create(out system.handle, VERSION.number); + } + public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings) + { + settings.cbsize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD_Studio_System_SetAdvancedSettings(this.handle, ref settings); + } + public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings, string encryptionKey) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr userKey = settings.encryptionkey; + settings.encryptionkey = encoder.intptrFromStringUTF8(encryptionKey); + FMOD.RESULT result = setAdvancedSettings(settings); + settings.encryptionkey = userKey; + return result; + } + } + public RESULT getAdvancedSettings(out ADVANCEDSETTINGS settings) + { + settings.cbsize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD_Studio_System_GetAdvancedSettings(this.handle, out settings); + } + public RESULT initialize(int maxchannels, INITFLAGS studioflags, FMOD.INITFLAGS flags, IntPtr extradriverdata) + { + return FMOD_Studio_System_Initialize(this.handle, maxchannels, studioflags, flags, extradriverdata); + } + public RESULT release() + { + return FMOD_Studio_System_Release(this.handle); + } + public RESULT update() + { + return FMOD_Studio_System_Update(this.handle); + } + public RESULT getCoreSystem(out FMOD.System coresystem) + { + return FMOD_Studio_System_GetCoreSystem(this.handle, out coresystem.handle); + } + public RESULT getEvent(string path, out EventDescription _event) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetEvent(this.handle, encoder.byteFromStringUTF8(path), out _event.handle); + } + } + public RESULT getBus(string path, out Bus bus) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetBus(this.handle, encoder.byteFromStringUTF8(path), out bus.handle); + } + } + public RESULT getVCA(string path, out VCA vca) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetVCA(this.handle, encoder.byteFromStringUTF8(path), out vca.handle); + } + } + public RESULT getBank(string path, out Bank bank) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetBank(this.handle, encoder.byteFromStringUTF8(path), out bank.handle); + } + } + + public RESULT getEventByID(GUID id, out EventDescription _event) + { + return FMOD_Studio_System_GetEventByID(this.handle, ref id, out _event.handle); + } + public RESULT getBusByID(GUID id, out Bus bus) + { + return FMOD_Studio_System_GetBusByID(this.handle, ref id, out bus.handle); + } + public RESULT getVCAByID(GUID id, out VCA vca) + { + return FMOD_Studio_System_GetVCAByID(this.handle, ref id, out vca.handle); + } + public RESULT getBankByID(GUID id, out Bank bank) + { + return FMOD_Studio_System_GetBankByID(this.handle, ref id, out bank.handle); + } + public RESULT getSoundInfo(string key, out SOUND_INFO info) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetSoundInfo(this.handle, encoder.byteFromStringUTF8(key), out info); + } + } + public RESULT getParameterDescriptionByName(string name, out PARAMETER_DESCRIPTION parameter) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetParameterDescriptionByName(this.handle, encoder.byteFromStringUTF8(name), out parameter); + } + } + public RESULT getParameterDescriptionByID(PARAMETER_ID id, out PARAMETER_DESCRIPTION parameter) + { + return FMOD_Studio_System_GetParameterDescriptionByID(this.handle, id, out parameter); + } + public RESULT getParameterLabelByName(string name, int labelindex, out string label) + { + label = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + byte[] nameBytes = encoder.byteFromStringUTF8(name); + RESULT result = FMOD_Studio_System_GetParameterLabelByName(this.handle, nameBytes, labelindex, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + result = FMOD_Studio_System_GetParameterLabelByName(this.handle, nameBytes, labelindex, IntPtr.Zero, 0, out retrieved); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_System_GetParameterLabelByName(this.handle, nameBytes, labelindex, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + label = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getParameterLabelByID(PARAMETER_ID id, int labelindex, out string label) + { + label = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_System_GetParameterLabelByID(this.handle, id, labelindex, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + result = FMOD_Studio_System_GetParameterLabelByID(this.handle, id, labelindex, IntPtr.Zero, 0, out retrieved); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_System_GetParameterLabelByID(this.handle, id, labelindex, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + label = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getParameterByID(PARAMETER_ID id, out float value) + { + float finalValue; + return getParameterByID(id, out value, out finalValue); + } + public RESULT getParameterByID(PARAMETER_ID id, out float value, out float finalvalue) + { + return FMOD_Studio_System_GetParameterByID(this.handle, id, out value, out finalvalue); + } + public RESULT setParameterByID(PARAMETER_ID id, float value, bool ignoreseekspeed = false) + { + return FMOD_Studio_System_SetParameterByID(this.handle, id, value, ignoreseekspeed); + } + public RESULT setParameterByIDWithLabel(PARAMETER_ID id, string label, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_SetParameterByIDWithLabel(this.handle, id, encoder.byteFromStringUTF8(label), ignoreseekspeed); + } + } + public RESULT setParametersByIDs(PARAMETER_ID[] ids, float[] values, int count, bool ignoreseekspeed = false) + { + return FMOD_Studio_System_SetParametersByIDs(this.handle, ids, values, count, ignoreseekspeed); + } + public RESULT getParameterByName(string name, out float value) + { + float finalValue; + return getParameterByName(name, out value, out finalValue); + } + public RESULT getParameterByName(string name, out float value, out float finalvalue) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_GetParameterByName(this.handle, encoder.byteFromStringUTF8(name), out value, out finalvalue); + } + } + public RESULT setParameterByName(string name, float value, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_SetParameterByName(this.handle, encoder.byteFromStringUTF8(name), value, ignoreseekspeed); + } + } + public RESULT setParameterByNameWithLabel(string name, string label, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper(), + labelEncoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_SetParameterByNameWithLabel(this.handle, encoder.byteFromStringUTF8(name), labelEncoder.byteFromStringUTF8(label), ignoreseekspeed); + } + } + public RESULT lookupID(string path, out GUID id) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_LookupID(this.handle, encoder.byteFromStringUTF8(path), out id); + } + } + public RESULT lookupPath(GUID id, out string path) + { + path = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_System_LookupPath(this.handle, ref id, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_System_LookupPath(this.handle, ref id, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getNumListeners(out int numlisteners) + { + return FMOD_Studio_System_GetNumListeners(this.handle, out numlisteners); + } + public RESULT setNumListeners(int numlisteners) + { + return FMOD_Studio_System_SetNumListeners(this.handle, numlisteners); + } + public RESULT getListenerAttributes(int listener, out ATTRIBUTES_3D attributes) + { + return FMOD_Studio_System_GetListenerAttributes(this.handle, listener, out attributes, IntPtr.Zero); + } + public RESULT getListenerAttributes(int listener, out ATTRIBUTES_3D attributes, out VECTOR attenuationposition) + { + return FMOD_Studio_System_GetListenerAttributes(this.handle, listener, out attributes, out attenuationposition); + } + public RESULT setListenerAttributes(int listener, ATTRIBUTES_3D attributes) + { + return FMOD_Studio_System_SetListenerAttributes(this.handle, listener, ref attributes, IntPtr.Zero); + } + public RESULT setListenerAttributes(int listener, ATTRIBUTES_3D attributes, VECTOR attenuationposition) + { + return FMOD_Studio_System_SetListenerAttributes(this.handle, listener, ref attributes, ref attenuationposition); + } + public RESULT getListenerWeight(int listener, out float weight) + { + return FMOD_Studio_System_GetListenerWeight(this.handle, listener, out weight); + } + public RESULT setListenerWeight(int listener, float weight) + { + return FMOD_Studio_System_SetListenerWeight(this.handle, listener, weight); + } + public RESULT loadBankFile(string filename, LOAD_BANK_FLAGS flags, out Bank bank) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_LoadBankFile(this.handle, encoder.byteFromStringUTF8(filename), flags, out bank.handle); + } + } + public RESULT loadBankMemory(byte[] buffer, LOAD_BANK_FLAGS flags, out Bank bank) + { + // Manually pin the byte array. It's what the marshaller should do anyway but don't leave it to chance. + GCHandle pinnedArray = GCHandle.Alloc(buffer, GCHandleType.Pinned); + IntPtr pointer = pinnedArray.AddrOfPinnedObject(); + RESULT result = FMOD_Studio_System_LoadBankMemory(this.handle, pointer, buffer.Length, LOAD_MEMORY_MODE.LOAD_MEMORY, flags, out bank.handle); + pinnedArray.Free(); + return result; + } + public RESULT loadBankCustom(BANK_INFO info, LOAD_BANK_FLAGS flags, out Bank bank) + { + info.size = MarshalHelper.SizeOf(typeof(BANK_INFO)); + return FMOD_Studio_System_LoadBankCustom(this.handle, ref info, flags, out bank.handle); + } + public RESULT unloadAll() + { + return FMOD_Studio_System_UnloadAll(this.handle); + } + public RESULT flushCommands() + { + return FMOD_Studio_System_FlushCommands(this.handle); + } + public RESULT flushSampleLoading() + { + return FMOD_Studio_System_FlushSampleLoading(this.handle); + } + public RESULT startCommandCapture(string filename, COMMANDCAPTURE_FLAGS flags) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_StartCommandCapture(this.handle, encoder.byteFromStringUTF8(filename), flags); + } + } + public RESULT stopCommandCapture() + { + return FMOD_Studio_System_StopCommandCapture(this.handle); + } + public RESULT loadCommandReplay(string filename, COMMANDREPLAY_FLAGS flags, out CommandReplay replay) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_System_LoadCommandReplay(this.handle, encoder.byteFromStringUTF8(filename), flags, out replay.handle); + } + } + public RESULT getBankCount(out int count) + { + return FMOD_Studio_System_GetBankCount(this.handle, out count); + } + public RESULT getBankList(out Bank[] array) + { + array = null; + + RESULT result; + int capacity; + result = FMOD_Studio_System_GetBankCount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new Bank[0]; + return result; + } + + IntPtr[] rawArray = new IntPtr[capacity]; + int actualCount; + result = FMOD_Studio_System_GetBankList(this.handle, rawArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + if (actualCount > capacity) // More items added since we queried just now? + { + actualCount = capacity; + } + array = new Bank[actualCount]; + for (int i = 0; i < actualCount; ++i) + { + array[i].handle = rawArray[i]; + } + return RESULT.OK; + } + public RESULT getParameterDescriptionCount(out int count) + { + return FMOD_Studio_System_GetParameterDescriptionCount(this.handle, out count); + } + public RESULT getParameterDescriptionList(out PARAMETER_DESCRIPTION[] array) + { + array = null; + + int capacity; + RESULT result = FMOD_Studio_System_GetParameterDescriptionCount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new PARAMETER_DESCRIPTION[0]; + return RESULT.OK; + } + + PARAMETER_DESCRIPTION[] tempArray = new PARAMETER_DESCRIPTION[capacity]; + int actualCount; + result = FMOD_Studio_System_GetParameterDescriptionList(this.handle, tempArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + + if (actualCount != capacity) + { + Array.Resize(ref tempArray, actualCount); + } + + array = tempArray; + + return RESULT.OK; + } + public RESULT getCPUUsage(out CPU_USAGE usage, out FMOD.CPU_USAGE usage_core) + { + return FMOD_Studio_System_GetCPUUsage(this.handle, out usage, out usage_core); + } + public RESULT getBufferUsage(out BUFFER_USAGE usage) + { + return FMOD_Studio_System_GetBufferUsage(this.handle, out usage); + } + public RESULT resetBufferUsage() + { + return FMOD_Studio_System_ResetBufferUsage(this.handle); + } + + public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL) + { + return FMOD_Studio_System_SetCallback(this.handle, callback, callbackmask); + } + + public RESULT getUserData(out IntPtr userdata) + { + return FMOD_Studio_System_GetUserData(this.handle, out userdata); + } + + public RESULT setUserData(IntPtr userdata) + { + return FMOD_Studio_System_SetUserData(this.handle, userdata); + } + + public RESULT getMemoryUsage(out MEMORY_USAGE memoryusage) + { + return FMOD_Studio_System_GetMemoryUsage(this.handle, out memoryusage); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_Create (out IntPtr system, uint headerversion); + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_System_IsValid (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetAdvancedSettings (IntPtr system, out ADVANCEDSETTINGS settings); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_Initialize (IntPtr system, int maxchannels, INITFLAGS studioflags, FMOD.INITFLAGS flags, IntPtr extradriverdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_Release (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_Update (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetCoreSystem (IntPtr system, out IntPtr coresystem); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetEvent (IntPtr system, byte[] path, out IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBus (IntPtr system, byte[] path, out IntPtr bus); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetVCA (IntPtr system, byte[] path, out IntPtr vca); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBank (IntPtr system, byte[] path, out IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetEventByID (IntPtr system, ref GUID id, out IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBusByID (IntPtr system, ref GUID id, out IntPtr bus); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetVCAByID (IntPtr system, ref GUID id, out IntPtr vca); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBankByID (IntPtr system, ref GUID id, out IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetSoundInfo (IntPtr system, byte[] key, out SOUND_INFO info); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterDescriptionByName(IntPtr system, byte[] name, out PARAMETER_DESCRIPTION parameter); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterDescriptionByID(IntPtr system, PARAMETER_ID id, out PARAMETER_DESCRIPTION parameter); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterLabelByName (IntPtr system, byte[] name, int labelindex, IntPtr label, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterLabelByID (IntPtr system, PARAMETER_ID id, int labelindex, IntPtr label, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterByID (IntPtr system, PARAMETER_ID id, out float value, out float finalvalue); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetParameterByID (IntPtr system, PARAMETER_ID id, float value, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetParameterByIDWithLabel (IntPtr system, PARAMETER_ID id, byte[] label, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetParametersByIDs (IntPtr system, PARAMETER_ID[] ids, float[] values, int count, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterByName (IntPtr system, byte[] name, out float value, out float finalvalue); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetParameterByName (IntPtr system, byte[] name, float value, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetParameterByNameWithLabel (IntPtr system, byte[] name, byte[] label, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LookupID (IntPtr system, byte[] path, out GUID id); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LookupPath (IntPtr system, ref GUID id, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetNumListeners (IntPtr system, out int numlisteners); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetNumListeners (IntPtr system, int numlisteners); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetListenerAttributes (IntPtr system, int listener, out ATTRIBUTES_3D attributes, IntPtr zero); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetListenerAttributes (IntPtr system, int listener, out ATTRIBUTES_3D attributes, out VECTOR attenuationposition); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetListenerAttributes (IntPtr system, int listener, ref ATTRIBUTES_3D attributes, IntPtr zero); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetListenerAttributes (IntPtr system, int listener, ref ATTRIBUTES_3D attributes, ref VECTOR attenuationposition); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetListenerWeight (IntPtr system, int listener, out float weight); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetListenerWeight (IntPtr system, int listener, float weight); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LoadBankFile (IntPtr system, byte[] filename, LOAD_BANK_FLAGS flags, out IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LoadBankMemory (IntPtr system, IntPtr buffer, int length, LOAD_MEMORY_MODE mode, LOAD_BANK_FLAGS flags, out IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LoadBankCustom (IntPtr system, ref BANK_INFO info, LOAD_BANK_FLAGS flags, out IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_UnloadAll (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_FlushCommands (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_FlushSampleLoading (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_StartCommandCapture (IntPtr system, byte[] filename, COMMANDCAPTURE_FLAGS flags); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_StopCommandCapture (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_LoadCommandReplay (IntPtr system, byte[] filename, COMMANDREPLAY_FLAGS flags, out IntPtr replay); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBankCount (IntPtr system, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBankList (IntPtr system, IntPtr[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterDescriptionCount(IntPtr system, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetParameterDescriptionList(IntPtr system, [Out] PARAMETER_DESCRIPTION[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetCPUUsage (IntPtr system, out CPU_USAGE usage, out FMOD.CPU_USAGE usage_core); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetBufferUsage (IntPtr system, out BUFFER_USAGE usage); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_ResetBufferUsage (IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetCallback (IntPtr system, SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetUserData (IntPtr system, out IntPtr userdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_SetUserData (IntPtr system, IntPtr userdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_System_GetMemoryUsage (IntPtr system, out MEMORY_USAGE memoryusage); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public System(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_System_IsValid(this.handle); + } + + #endregion + } + + public struct EventDescription + { + public RESULT getID(out GUID id) + { + return FMOD_Studio_EventDescription_GetID(this.handle, out id); + } + public RESULT getPath(out string path) + { + path = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_EventDescription_GetPath(this.handle, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_EventDescription_GetPath(this.handle, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getParameterDescriptionCount(out int count) + { + return FMOD_Studio_EventDescription_GetParameterDescriptionCount(this.handle, out count); + } + public RESULT getParameterDescriptionByIndex(int index, out PARAMETER_DESCRIPTION parameter) + { + return FMOD_Studio_EventDescription_GetParameterDescriptionByIndex(this.handle, index, out parameter); + } + public RESULT getParameterDescriptionByName(string name, out PARAMETER_DESCRIPTION parameter) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventDescription_GetParameterDescriptionByName(this.handle, encoder.byteFromStringUTF8(name), out parameter); + } + } + public RESULT getParameterDescriptionByID(PARAMETER_ID id, out PARAMETER_DESCRIPTION parameter) + { + return FMOD_Studio_EventDescription_GetParameterDescriptionByID(this.handle, id, out parameter); + } + public RESULT getParameterLabelByIndex(int index, int labelindex, out string label) + { + label = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_EventDescription_GetParameterLabelByIndex(this.handle, index, labelindex, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + result = FMOD_Studio_EventDescription_GetParameterLabelByIndex(this.handle, index, labelindex, IntPtr.Zero, 0, out retrieved); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_EventDescription_GetParameterLabelByIndex(this.handle, index, labelindex, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + label = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getParameterLabelByName(string name, int labelindex, out string label) + { + label = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + byte[] nameBytes = encoder.byteFromStringUTF8(name); + RESULT result = FMOD_Studio_EventDescription_GetParameterLabelByName(this.handle, nameBytes, labelindex, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + result = FMOD_Studio_EventDescription_GetParameterLabelByName(this.handle, nameBytes, labelindex, IntPtr.Zero, 0, out retrieved); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_EventDescription_GetParameterLabelByName(this.handle, nameBytes, labelindex, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + label = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getParameterLabelByID(PARAMETER_ID id, int labelindex, out string label) + { + label = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_EventDescription_GetParameterLabelByID(this.handle, id, labelindex, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + result = FMOD_Studio_EventDescription_GetParameterLabelByID(this.handle, id, labelindex, IntPtr.Zero, 0, out retrieved); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_EventDescription_GetParameterLabelByID(this.handle, id, labelindex, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + label = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getUserPropertyCount(out int count) + { + return FMOD_Studio_EventDescription_GetUserPropertyCount(this.handle, out count); + } + public RESULT getUserPropertyByIndex(int index, out USER_PROPERTY property) + { + return FMOD_Studio_EventDescription_GetUserPropertyByIndex(this.handle, index, out property); + } + public RESULT getUserProperty(string name, out USER_PROPERTY property) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventDescription_GetUserProperty(this.handle, encoder.byteFromStringUTF8(name), out property); + } + } + public RESULT getLength(out int length) + { + return FMOD_Studio_EventDescription_GetLength(this.handle, out length); + } + public RESULT getMinMaxDistance(out float min, out float max) + { + return FMOD_Studio_EventDescription_GetMinMaxDistance(this.handle, out min, out max); + } + public RESULT getSoundSize(out float size) + { + return FMOD_Studio_EventDescription_GetSoundSize(this.handle, out size); + } + public RESULT isSnapshot(out bool snapshot) + { + return FMOD_Studio_EventDescription_IsSnapshot(this.handle, out snapshot); + } + public RESULT isOneshot(out bool oneshot) + { + return FMOD_Studio_EventDescription_IsOneshot(this.handle, out oneshot); + } + public RESULT isStream(out bool isStream) + { + return FMOD_Studio_EventDescription_IsStream(this.handle, out isStream); + } + public RESULT is3D(out bool is3D) + { + return FMOD_Studio_EventDescription_Is3D(this.handle, out is3D); + } + public RESULT isDopplerEnabled(out bool doppler) + { + return FMOD_Studio_EventDescription_IsDopplerEnabled(this.handle, out doppler); + } + public RESULT hasSustainPoint(out bool sustainPoint) + { + return FMOD_Studio_EventDescription_HasSustainPoint(this.handle, out sustainPoint); + } + + public RESULT createInstance(out EventInstance instance) + { + return FMOD_Studio_EventDescription_CreateInstance(this.handle, out instance.handle); + } + + public RESULT getInstanceCount(out int count) + { + return FMOD_Studio_EventDescription_GetInstanceCount(this.handle, out count); + } + public RESULT getInstanceList(out EventInstance[] array) + { + array = null; + + RESULT result; + int capacity; + result = FMOD_Studio_EventDescription_GetInstanceCount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new EventInstance[0]; + return result; + } + + IntPtr[] rawArray = new IntPtr[capacity]; + int actualCount; + result = FMOD_Studio_EventDescription_GetInstanceList(this.handle, rawArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + if (actualCount > capacity) // More items added since we queried just now? + { + actualCount = capacity; + } + array = new EventInstance[actualCount]; + for (int i = 0; i < actualCount; ++i) + { + array[i].handle = rawArray[i]; + } + return RESULT.OK; + } + + public RESULT loadSampleData() + { + return FMOD_Studio_EventDescription_LoadSampleData(this.handle); + } + + public RESULT unloadSampleData() + { + return FMOD_Studio_EventDescription_UnloadSampleData(this.handle); + } + + public RESULT getSampleLoadingState(out LOADING_STATE state) + { + return FMOD_Studio_EventDescription_GetSampleLoadingState(this.handle, out state); + } + + public RESULT releaseAllInstances() + { + return FMOD_Studio_EventDescription_ReleaseAllInstances(this.handle); + } + public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL) + { + return FMOD_Studio_EventDescription_SetCallback(this.handle, callback, callbackmask); + } + + public RESULT getUserData(out IntPtr userdata) + { + return FMOD_Studio_EventDescription_GetUserData(this.handle, out userdata); + } + + public RESULT setUserData(IntPtr userdata) + { + return FMOD_Studio_EventDescription_SetUserData(this.handle, userdata); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_EventDescription_IsValid (IntPtr eventdescription); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetID (IntPtr eventdescription, out GUID id); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetPath (IntPtr eventdescription, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterDescriptionCount(IntPtr eventdescription, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterDescriptionByIndex(IntPtr eventdescription, int index, out PARAMETER_DESCRIPTION parameter); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterDescriptionByName(IntPtr eventdescription, byte[] name, out PARAMETER_DESCRIPTION parameter); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterDescriptionByID(IntPtr eventdescription, PARAMETER_ID id, out PARAMETER_DESCRIPTION parameter); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterLabelByIndex(IntPtr eventdescription, int index, int labelindex, IntPtr label, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterLabelByName(IntPtr eventdescription, byte[] name, int labelindex, IntPtr label, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetParameterLabelByID (IntPtr eventdescription, PARAMETER_ID id, int labelindex, IntPtr label, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetUserPropertyCount (IntPtr eventdescription, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetUserPropertyByIndex(IntPtr eventdescription, int index, out USER_PROPERTY property); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetUserProperty (IntPtr eventdescription, byte[] name, out USER_PROPERTY property); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetLength (IntPtr eventdescription, out int length); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetMinMaxDistance (IntPtr eventdescription, out float min, out float max); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetSoundSize (IntPtr eventdescription, out float size); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_IsSnapshot (IntPtr eventdescription, out bool snapshot); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_IsOneshot (IntPtr eventdescription, out bool oneshot); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_IsStream (IntPtr eventdescription, out bool isStream); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_Is3D (IntPtr eventdescription, out bool is3D); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_IsDopplerEnabled (IntPtr eventdescription, out bool doppler); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_HasSustainPoint (IntPtr eventdescription, out bool sustainPoint); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_CreateInstance (IntPtr eventdescription, out IntPtr instance); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetInstanceCount (IntPtr eventdescription, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetInstanceList (IntPtr eventdescription, IntPtr[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_LoadSampleData (IntPtr eventdescription); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_UnloadSampleData (IntPtr eventdescription); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetSampleLoadingState (IntPtr eventdescription, out LOADING_STATE state); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_ReleaseAllInstances (IntPtr eventdescription); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_SetCallback (IntPtr eventdescription, EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_GetUserData (IntPtr eventdescription, out IntPtr userdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventDescription_SetUserData (IntPtr eventdescription, IntPtr userdata); + #endregion + #region wrapperinternal + + public IntPtr handle; + + public EventDescription(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_EventDescription_IsValid(this.handle); + } + + #endregion + } + + public struct EventInstance + { + public RESULT getDescription(out EventDescription description) + { + return FMOD_Studio_EventInstance_GetDescription(this.handle, out description.handle); + } + public RESULT getVolume(out float volume) + { + return FMOD_Studio_EventInstance_GetVolume(this.handle, out volume, IntPtr.Zero); + } + public RESULT getVolume(out float volume, out float finalvolume) + { + return FMOD_Studio_EventInstance_GetVolume(this.handle, out volume, out finalvolume); + } + public RESULT setVolume(float volume) + { + return FMOD_Studio_EventInstance_SetVolume(this.handle, volume); + } + public RESULT getPitch(out float pitch) + { + return FMOD_Studio_EventInstance_GetPitch(this.handle, out pitch, IntPtr.Zero); + } + public RESULT getPitch(out float pitch, out float finalpitch) + { + return FMOD_Studio_EventInstance_GetPitch(this.handle, out pitch, out finalpitch); + } + public RESULT setPitch(float pitch) + { + return FMOD_Studio_EventInstance_SetPitch(this.handle, pitch); + } + public RESULT get3DAttributes(out ATTRIBUTES_3D attributes) + { + return FMOD_Studio_EventInstance_Get3DAttributes(this.handle, out attributes); + } + public RESULT set3DAttributes(ATTRIBUTES_3D attributes) + { + return FMOD_Studio_EventInstance_Set3DAttributes(this.handle, ref attributes); + } + public RESULT getListenerMask(out uint mask) + { + return FMOD_Studio_EventInstance_GetListenerMask(this.handle, out mask); + } + public RESULT setListenerMask(uint mask) + { + return FMOD_Studio_EventInstance_SetListenerMask(this.handle, mask); + } + public RESULT getProperty(EVENT_PROPERTY index, out float value) + { + return FMOD_Studio_EventInstance_GetProperty(this.handle, index, out value); + } + public RESULT setProperty(EVENT_PROPERTY index, float value) + { + return FMOD_Studio_EventInstance_SetProperty(this.handle, index, value); + } + public RESULT getReverbLevel(int index, out float level) + { + return FMOD_Studio_EventInstance_GetReverbLevel(this.handle, index, out level); + } + public RESULT setReverbLevel(int index, float level) + { + return FMOD_Studio_EventInstance_SetReverbLevel(this.handle, index, level); + } + public RESULT getPaused(out bool paused) + { + return FMOD_Studio_EventInstance_GetPaused(this.handle, out paused); + } + public RESULT setPaused(bool paused) + { + return FMOD_Studio_EventInstance_SetPaused(this.handle, paused); + } + public RESULT start() + { + return FMOD_Studio_EventInstance_Start(this.handle); + } + public RESULT stop(STOP_MODE mode) + { + return FMOD_Studio_EventInstance_Stop(this.handle, mode); + } + public RESULT getTimelinePosition(out int position) + { + return FMOD_Studio_EventInstance_GetTimelinePosition(this.handle, out position); + } + public RESULT setTimelinePosition(int position) + { + return FMOD_Studio_EventInstance_SetTimelinePosition(this.handle, position); + } + public RESULT getPlaybackState(out PLAYBACK_STATE state) + { + return FMOD_Studio_EventInstance_GetPlaybackState(this.handle, out state); + } + public RESULT getChannelGroup(out FMOD.ChannelGroup group) + { + return FMOD_Studio_EventInstance_GetChannelGroup(this.handle, out group.handle); + } + public RESULT getMinMaxDistance(out float min, out float max) + { + return FMOD_Studio_EventInstance_GetMinMaxDistance(this.handle, out min, out max); + } + public RESULT release() + { + return FMOD_Studio_EventInstance_Release(this.handle); + } + public RESULT isVirtual(out bool virtualstate) + { + return FMOD_Studio_EventInstance_IsVirtual(this.handle, out virtualstate); + } + public RESULT getParameterByID(PARAMETER_ID id, out float value) + { + float finalvalue; + return getParameterByID(id, out value, out finalvalue); + } + public RESULT getParameterByID(PARAMETER_ID id, out float value, out float finalvalue) + { + return FMOD_Studio_EventInstance_GetParameterByID(this.handle, id, out value, out finalvalue); + } + public RESULT setParameterByID(PARAMETER_ID id, float value, bool ignoreseekspeed = false) + { + return FMOD_Studio_EventInstance_SetParameterByID(this.handle, id, value, ignoreseekspeed); + } + public RESULT setParameterByIDWithLabel(PARAMETER_ID id, string label, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventInstance_SetParameterByIDWithLabel(this.handle, id, encoder.byteFromStringUTF8(label), ignoreseekspeed); + } + } + public RESULT setParametersByIDs(PARAMETER_ID[] ids, float[] values, int count, bool ignoreseekspeed = false) + { + return FMOD_Studio_EventInstance_SetParametersByIDs(this.handle, ids, values, count, ignoreseekspeed); + } + public RESULT getParameterByName(string name, out float value) + { + float finalValue; + return getParameterByName(name, out value, out finalValue); + } + public RESULT getParameterByName(string name, out float value, out float finalvalue) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventInstance_GetParameterByName(this.handle, encoder.byteFromStringUTF8(name), out value, out finalvalue); + } + } + public RESULT setParameterByName(string name, float value, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventInstance_SetParameterByName(this.handle, encoder.byteFromStringUTF8(name), value, ignoreseekspeed); + } + } + public RESULT setParameterByNameWithLabel(string name, string label, bool ignoreseekspeed = false) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper(), + labelEncoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_EventInstance_SetParameterByNameWithLabel(this.handle, encoder.byteFromStringUTF8(name), labelEncoder.byteFromStringUTF8(label), ignoreseekspeed); + } + } + public RESULT keyOff() + { + return FMOD_Studio_EventInstance_KeyOff(this.handle); + } + public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL) + { + return FMOD_Studio_EventInstance_SetCallback(this.handle, callback, callbackmask); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD_Studio_EventInstance_GetUserData(this.handle, out userdata); + } + public RESULT setUserData(IntPtr userdata) + { + return FMOD_Studio_EventInstance_SetUserData(this.handle, userdata); + } + public RESULT getCPUUsage(out uint exclusive, out uint inclusive) + { + return FMOD_Studio_EventInstance_GetCPUUsage(this.handle, out exclusive, out inclusive); + } + public RESULT getMemoryUsage(out MEMORY_USAGE memoryusage) + { + return FMOD_Studio_EventInstance_GetMemoryUsage(this.handle, out memoryusage); + } + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_EventInstance_IsValid (IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetDescription (IntPtr _event, out IntPtr description); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetVolume (IntPtr _event, out float volume, IntPtr zero); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetVolume (IntPtr _event, out float volume, out float finalvolume); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetVolume (IntPtr _event, float volume); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetPitch (IntPtr _event, out float pitch, IntPtr zero); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetPitch (IntPtr _event, out float pitch, out float finalpitch); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetPitch (IntPtr _event, float pitch); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_Get3DAttributes (IntPtr _event, out ATTRIBUTES_3D attributes); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_Set3DAttributes (IntPtr _event, ref ATTRIBUTES_3D attributes); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetListenerMask (IntPtr _event, out uint mask); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetListenerMask (IntPtr _event, uint mask); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetProperty (IntPtr _event, EVENT_PROPERTY index, out float value); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetProperty (IntPtr _event, EVENT_PROPERTY index, float value); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetReverbLevel (IntPtr _event, int index, out float level); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetReverbLevel (IntPtr _event, int index, float level); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetPaused (IntPtr _event, out bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetPaused (IntPtr _event, bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_Start (IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_Stop (IntPtr _event, STOP_MODE mode); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetTimelinePosition (IntPtr _event, out int position); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetTimelinePosition (IntPtr _event, int position); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetPlaybackState (IntPtr _event, out PLAYBACK_STATE state); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetChannelGroup (IntPtr _event, out IntPtr group); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetMinMaxDistance (IntPtr _event, out float min, out float max); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_Release (IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_IsVirtual (IntPtr _event, out bool virtualstate); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetParameterByName (IntPtr _event, byte[] name, out float value, out float finalvalue); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetParameterByName (IntPtr _event, byte[] name, float value, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetParameterByNameWithLabel (IntPtr _event, byte[] name, byte[] label, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetParameterByID (IntPtr _event, PARAMETER_ID id, out float value, out float finalvalue); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetParameterByID (IntPtr _event, PARAMETER_ID id, float value, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetParameterByIDWithLabel (IntPtr _event, PARAMETER_ID id, byte[] label, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetParametersByIDs (IntPtr _event, PARAMETER_ID[] ids, float[] values, int count, bool ignoreseekspeed); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_KeyOff (IntPtr _event); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetCallback (IntPtr _event, EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask); + [DllImport (STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetUserData (IntPtr _event, out IntPtr userdata); + [DllImport (STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_SetUserData (IntPtr _event, IntPtr userdata); + [DllImport (STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetCPUUsage (IntPtr _event, out uint exclusive, out uint inclusive); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_EventInstance_GetMemoryUsage (IntPtr _event, out MEMORY_USAGE memoryusage); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public EventInstance(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_EventInstance_IsValid(this.handle); + } + + #endregion + } + + public struct Bus + { + public RESULT getID(out GUID id) + { + return FMOD_Studio_Bus_GetID(this.handle, out id); + } + public RESULT getPath(out string path) + { + path = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_Bus_GetPath(this.handle, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_Bus_GetPath(this.handle, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + + } + public RESULT getVolume(out float volume) + { + float finalVolume; + return getVolume(out volume, out finalVolume); + } + public RESULT getVolume(out float volume, out float finalvolume) + { + return FMOD_Studio_Bus_GetVolume(this.handle, out volume, out finalvolume); + } + public RESULT setVolume(float volume) + { + return FMOD_Studio_Bus_SetVolume(this.handle, volume); + } + public RESULT getPaused(out bool paused) + { + return FMOD_Studio_Bus_GetPaused(this.handle, out paused); + } + public RESULT setPaused(bool paused) + { + return FMOD_Studio_Bus_SetPaused(this.handle, paused); + } + public RESULT getMute(out bool mute) + { + return FMOD_Studio_Bus_GetMute(this.handle, out mute); + } + public RESULT setMute(bool mute) + { + return FMOD_Studio_Bus_SetMute(this.handle, mute); + } + public RESULT stopAllEvents(STOP_MODE mode) + { + return FMOD_Studio_Bus_StopAllEvents(this.handle, mode); + } + public RESULT lockChannelGroup() + { + return FMOD_Studio_Bus_LockChannelGroup(this.handle); + } + public RESULT unlockChannelGroup() + { + return FMOD_Studio_Bus_UnlockChannelGroup(this.handle); + } + public RESULT getChannelGroup(out FMOD.ChannelGroup group) + { + return FMOD_Studio_Bus_GetChannelGroup(this.handle, out group.handle); + } + public RESULT getCPUUsage(out uint exclusive, out uint inclusive) + { + return FMOD_Studio_Bus_GetCPUUsage(this.handle, out exclusive, out inclusive); + } + public RESULT getMemoryUsage(out MEMORY_USAGE memoryusage) + { + return FMOD_Studio_Bus_GetMemoryUsage(this.handle, out memoryusage); + } + public RESULT getPortIndex(out ulong index) + { + return FMOD_Studio_Bus_GetPortIndex(this.handle, out index); + } + public RESULT setPortIndex(ulong index) + { + return FMOD_Studio_Bus_SetPortIndex(this.handle, index); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_Bus_IsValid (IntPtr bus); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetID (IntPtr bus, out GUID id); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetPath (IntPtr bus, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetVolume (IntPtr bus, out float volume, out float finalvolume); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_SetVolume (IntPtr bus, float volume); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetPaused (IntPtr bus, out bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_SetPaused (IntPtr bus, bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetMute (IntPtr bus, out bool mute); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_SetMute (IntPtr bus, bool mute); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_StopAllEvents (IntPtr bus, STOP_MODE mode); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_LockChannelGroup (IntPtr bus); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_UnlockChannelGroup (IntPtr bus); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetChannelGroup (IntPtr bus, out IntPtr group); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetCPUUsage (IntPtr bus, out uint exclusive, out uint inclusive); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetMemoryUsage (IntPtr bus, out MEMORY_USAGE memoryusage); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_GetPortIndex (IntPtr bus, out ulong index); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bus_SetPortIndex (IntPtr bus, ulong index); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Bus(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_Bus_IsValid(this.handle); + } + + #endregion + } + + public struct VCA + { + public RESULT getID(out GUID id) + { + return FMOD_Studio_VCA_GetID(this.handle, out id); + } + public RESULT getPath(out string path) + { + path = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_VCA_GetPath(this.handle, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_VCA_GetPath(this.handle, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getVolume(out float volume) + { + float finalVolume; + return getVolume(out volume, out finalVolume); + } + public RESULT getVolume(out float volume, out float finalvolume) + { + return FMOD_Studio_VCA_GetVolume(this.handle, out volume, out finalvolume); + } + public RESULT setVolume(float volume) + { + return FMOD_Studio_VCA_SetVolume(this.handle, volume); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_VCA_IsValid (IntPtr vca); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_VCA_GetID (IntPtr vca, out GUID id); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_VCA_GetPath (IntPtr vca, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_VCA_GetVolume (IntPtr vca, out float volume, out float finalvolume); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_VCA_SetVolume (IntPtr vca, float volume); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public VCA(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_VCA_IsValid(this.handle); + } + + #endregion + } + + public struct Bank + { + // Property access + + public RESULT getID(out GUID id) + { + return FMOD_Studio_Bank_GetID(this.handle, out id); + } + public RESULT getPath(out string path) + { + path = null; + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_Bank_GetPath(this.handle, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_Bank_GetPath(this.handle, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT unload() + { + return FMOD_Studio_Bank_Unload(this.handle); + } + public RESULT loadSampleData() + { + return FMOD_Studio_Bank_LoadSampleData(this.handle); + } + public RESULT unloadSampleData() + { + return FMOD_Studio_Bank_UnloadSampleData(this.handle); + } + public RESULT getLoadingState(out LOADING_STATE state) + { + return FMOD_Studio_Bank_GetLoadingState(this.handle, out state); + } + public RESULT getSampleLoadingState(out LOADING_STATE state) + { + return FMOD_Studio_Bank_GetSampleLoadingState(this.handle, out state); + } + + // Enumeration + public RESULT getStringCount(out int count) + { + return FMOD_Studio_Bank_GetStringCount(this.handle, out count); + } + public RESULT getStringInfo(int index, out GUID id, out string path) + { + path = null; + id = new GUID(); + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + IntPtr stringMem = Marshal.AllocHGlobal(256); + int retrieved = 0; + RESULT result = FMOD_Studio_Bank_GetStringInfo(this.handle, index, out id, stringMem, 256, out retrieved); + + if (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringMem = Marshal.AllocHGlobal(retrieved); + result = FMOD_Studio_Bank_GetStringInfo(this.handle, index, out id, stringMem, retrieved, out retrieved); + } + + if (result == RESULT.OK) + { + path = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + + public RESULT getEventCount(out int count) + { + return FMOD_Studio_Bank_GetEventCount(this.handle, out count); + } + public RESULT getEventList(out EventDescription[] array) + { + array = null; + + RESULT result; + int capacity; + result = FMOD_Studio_Bank_GetEventCount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new EventDescription[0]; + return result; + } + + IntPtr[] rawArray = new IntPtr[capacity]; + int actualCount; + result = FMOD_Studio_Bank_GetEventList(this.handle, rawArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + if (actualCount > capacity) // More items added since we queried just now? + { + actualCount = capacity; + } + array = new EventDescription[actualCount]; + for (int i = 0; i < actualCount; ++i) + { + array[i].handle = rawArray[i]; + } + return RESULT.OK; + } + public RESULT getBusCount(out int count) + { + return FMOD_Studio_Bank_GetBusCount(this.handle, out count); + } + public RESULT getBusList(out Bus[] array) + { + array = null; + + RESULT result; + int capacity; + result = FMOD_Studio_Bank_GetBusCount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new Bus[0]; + return result; + } + + IntPtr[] rawArray = new IntPtr[capacity]; + int actualCount; + result = FMOD_Studio_Bank_GetBusList(this.handle, rawArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + if (actualCount > capacity) // More items added since we queried just now? + { + actualCount = capacity; + } + array = new Bus[actualCount]; + for (int i = 0; i < actualCount; ++i) + { + array[i].handle = rawArray[i]; + } + return RESULT.OK; + } + public RESULT getVCACount(out int count) + { + return FMOD_Studio_Bank_GetVCACount(this.handle, out count); + } + public RESULT getVCAList(out VCA[] array) + { + array = null; + + RESULT result; + int capacity; + result = FMOD_Studio_Bank_GetVCACount(this.handle, out capacity); + if (result != RESULT.OK) + { + return result; + } + if (capacity == 0) + { + array = new VCA[0]; + return result; + } + + IntPtr[] rawArray = new IntPtr[capacity]; + int actualCount; + result = FMOD_Studio_Bank_GetVCAList(this.handle, rawArray, capacity, out actualCount); + if (result != RESULT.OK) + { + return result; + } + if (actualCount > capacity) // More items added since we queried just now? + { + actualCount = capacity; + } + array = new VCA[actualCount]; + for (int i = 0; i < actualCount; ++i) + { + array[i].handle = rawArray[i]; + } + return RESULT.OK; + } + + public RESULT getUserData(out IntPtr userdata) + { + return FMOD_Studio_Bank_GetUserData(this.handle, out userdata); + } + + public RESULT setUserData(IntPtr userdata) + { + return FMOD_Studio_Bank_SetUserData(this.handle, userdata); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_Bank_IsValid (IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetID (IntPtr bank, out GUID id); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetPath (IntPtr bank, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_Unload (IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_LoadSampleData (IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_UnloadSampleData (IntPtr bank); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetLoadingState (IntPtr bank, out LOADING_STATE state); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetSampleLoadingState (IntPtr bank, out LOADING_STATE state); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetStringCount (IntPtr bank, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetStringInfo (IntPtr bank, int index, out GUID id, IntPtr path, int size, out int retrieved); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetEventCount (IntPtr bank, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetEventList (IntPtr bank, IntPtr[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetBusCount (IntPtr bank, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetBusList (IntPtr bank, IntPtr[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetVCACount (IntPtr bank, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetVCAList (IntPtr bank, IntPtr[] array, int capacity, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_GetUserData (IntPtr bank, out IntPtr userdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_Bank_SetUserData (IntPtr bank, IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Bank(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_Bank_IsValid(this.handle); + } + + #endregion + } + + public struct CommandReplay + { + // Information query + public RESULT getSystem(out System system) + { + return FMOD_Studio_CommandReplay_GetSystem(this.handle, out system.handle); + } + + public RESULT getLength(out float length) + { + return FMOD_Studio_CommandReplay_GetLength(this.handle, out length); + } + public RESULT getCommandCount(out int count) + { + return FMOD_Studio_CommandReplay_GetCommandCount(this.handle, out count); + } + public RESULT getCommandInfo(int commandIndex, out COMMAND_INFO info) + { + return FMOD_Studio_CommandReplay_GetCommandInfo(this.handle, commandIndex, out info); + } + + public RESULT getCommandString(int commandIndex, out string buffer) + { + buffer = null; + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + int stringLength = 256; + IntPtr stringMem = Marshal.AllocHGlobal(256); + RESULT result = FMOD_Studio_CommandReplay_GetCommandString(this.handle, commandIndex, stringMem, stringLength); + + while (result == RESULT.ERR_TRUNCATED) + { + Marshal.FreeHGlobal(stringMem); + stringLength *= 2; + stringMem = Marshal.AllocHGlobal(stringLength); + result = FMOD_Studio_CommandReplay_GetCommandString(this.handle, commandIndex, stringMem, stringLength); + } + + if (result == RESULT.OK) + { + buffer = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + return result; + } + } + public RESULT getCommandAtTime(float time, out int commandIndex) + { + return FMOD_Studio_CommandReplay_GetCommandAtTime(this.handle, time, out commandIndex); + } + // Playback + public RESULT setBankPath(string bankPath) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD_Studio_CommandReplay_SetBankPath(this.handle, encoder.byteFromStringUTF8(bankPath)); + } + } + public RESULT start() + { + return FMOD_Studio_CommandReplay_Start(this.handle); + } + public RESULT stop() + { + return FMOD_Studio_CommandReplay_Stop(this.handle); + } + public RESULT seekToTime(float time) + { + return FMOD_Studio_CommandReplay_SeekToTime(this.handle, time); + } + public RESULT seekToCommand(int commandIndex) + { + return FMOD_Studio_CommandReplay_SeekToCommand(this.handle, commandIndex); + } + public RESULT getPaused(out bool paused) + { + return FMOD_Studio_CommandReplay_GetPaused(this.handle, out paused); + } + public RESULT setPaused(bool paused) + { + return FMOD_Studio_CommandReplay_SetPaused(this.handle, paused); + } + public RESULT getPlaybackState(out PLAYBACK_STATE state) + { + return FMOD_Studio_CommandReplay_GetPlaybackState(this.handle, out state); + } + public RESULT getCurrentCommand(out int commandIndex, out float currentTime) + { + return FMOD_Studio_CommandReplay_GetCurrentCommand(this.handle, out commandIndex, out currentTime); + } + // Release + public RESULT release() + { + return FMOD_Studio_CommandReplay_Release(this.handle); + } + // Callbacks + public RESULT setFrameCallback(COMMANDREPLAY_FRAME_CALLBACK callback) + { + return FMOD_Studio_CommandReplay_SetFrameCallback(this.handle, callback); + } + public RESULT setLoadBankCallback(COMMANDREPLAY_LOAD_BANK_CALLBACK callback) + { + return FMOD_Studio_CommandReplay_SetLoadBankCallback(this.handle, callback); + } + public RESULT setCreateInstanceCallback(COMMANDREPLAY_CREATE_INSTANCE_CALLBACK callback) + { + return FMOD_Studio_CommandReplay_SetCreateInstanceCallback(this.handle, callback); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD_Studio_CommandReplay_GetUserData(this.handle, out userdata); + } + public RESULT setUserData(IntPtr userdata) + { + return FMOD_Studio_CommandReplay_SetUserData(this.handle, userdata); + } + + #region importfunctions + [DllImport(STUDIO_VERSION.dll)] + private static extern bool FMOD_Studio_CommandReplay_IsValid (IntPtr replay); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetSystem (IntPtr replay, out IntPtr system); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetLength (IntPtr replay, out float length); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetCommandCount (IntPtr replay, out int count); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetCommandInfo (IntPtr replay, int commandindex, out COMMAND_INFO info); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetCommandString (IntPtr replay, int commandIndex, IntPtr buffer, int length); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetCommandAtTime (IntPtr replay, float time, out int commandIndex); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetBankPath (IntPtr replay, byte[] bankPath); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_Start (IntPtr replay); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_Stop (IntPtr replay); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SeekToTime (IntPtr replay, float time); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SeekToCommand (IntPtr replay, int commandIndex); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetPaused (IntPtr replay, out bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetPaused (IntPtr replay, bool paused); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetPlaybackState (IntPtr replay, out PLAYBACK_STATE state); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetCurrentCommand (IntPtr replay, out int commandIndex, out float currentTime); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_Release (IntPtr replay); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetFrameCallback (IntPtr replay, COMMANDREPLAY_FRAME_CALLBACK callback); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetLoadBankCallback (IntPtr replay, COMMANDREPLAY_LOAD_BANK_CALLBACK callback); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetCreateInstanceCallback(IntPtr replay, COMMANDREPLAY_CREATE_INSTANCE_CALLBACK callback); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_GetUserData (IntPtr replay, out IntPtr userdata); + [DllImport(STUDIO_VERSION.dll)] + private static extern RESULT FMOD_Studio_CommandReplay_SetUserData (IntPtr replay, IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public CommandReplay(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + public bool isValid() + { + return hasHandle() && FMOD_Studio_CommandReplay_IsValid(this.handle); + } + + #endregion + } +} // FMOD diff --git a/Assets/Plugins/FMOD/src/fmod_studio.cs.meta b/Assets/Plugins/FMOD/src/fmod_studio.cs.meta new file mode 100644 index 0000000..a6aac50 --- /dev/null +++ b/Assets/Plugins/FMOD/src/fmod_studio.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae7eb0b6a2bff364b9c1fae52173e74c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset index 27287fe..a46c11f 100644 --- a/ProjectSettings/AudioManager.asset +++ b/ProjectSettings/AudioManager.asset @@ -12,8 +12,9 @@ AudioManager: m_DSPBufferSize: 1024 m_VirtualVoiceCount: 512 m_RealVoiceCount: 32 + m_EnableOutputSuspension: 1 m_SpatializerPlugin: m_AmbisonicDecoderPlugin: - m_DisableAudio: 0 + m_DisableAudio: 1 m_VirtualizeEffects: 1 m_RequestedDSPBufferSize: 0