Ejemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            SetupSerializedProperties(property);

            // Draw label
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            /************************************************Update Properties**************************************************/
            Guid[] componentGuid = new Guid[m_guidProperty.Length];
            for (int i = 0; i < componentGuid.Length; i++)
            {
                byte[] guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
                componentGuid[i] = guidBytes == null ? Guid.Empty : new Guid(guidBytes);
            }

            string componentName = UpdateIds(componentGuid);
            /*******************************************************************************************************************/


            /********************************************Draw GUI***************************************************************/
            var style = new GUIStyle(GUI.skin.button);

            style.alignment = TextAnchor.MiddleLeft;
            style.fontStyle = FontStyle.Normal;

            if (string.IsNullOrEmpty(componentName))
            {
                SetEmptyComponentName(ref componentName, ref style);
            }

            if (GUI.Button(position, componentName, style))
            {
                m_pressedPosition  = position;
                m_buttonWasPressed = true;

                // We don't want to set object as dirty only because we clicked the button.
                // It will be set as dirty if the wwise object has been changed by the tree view.
                GUI.changed = false;
            }

            var currentEvent = UnityEngine.Event.current;

            if (currentEvent.type == EventType.Repaint && m_buttonWasPressed && m_pressedPosition.Equals(position))
            {
                m_serializedObject = property.serializedObject;
                m_pickerPos        = GetLastRectAbsolute();

                EditorApplication.delayCall += DelayCreateCall;
                m_buttonWasPressed           = false;
            }

            HandleDragAndDrop(currentEvent, position);

            EditorGUI.EndProperty();
        }
Ejemplo n.º 2
0
    public static void PerformMigration(int migrateStart)
    {
        UpdateProgressBar(0);

        UnityEngine.Debug.Log("WwiseUnity: Migrating from Unity Integration Version " + migrateStart + " to " + AkUtilities.MigrationStopIndex);

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // Get the name of the currently opened scene.
        var activeScene     = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        var loadedScenePath = activeScene.path;

        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            AkBasePathGetter.FixSlashes(ref loadedScenePath, '\\', '/', false);
        }

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);

        // obtain a list of ScriptableObjects before any migration is performed
        ScriptableObjectGuids = UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject", new[] { "Assets" });

        AkUtilities.BeginMigration(migrateStart);
        AkWwiseProjectInfo.GetData().Migrate();
        AkWwiseWWUBuilder.UpdateWwiseObjectReferenceData();

        MigratePrefabs();
        MigrateScenes();
        MigrateScriptableObjects();

        UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
        AkUtilities.EndMigration();

        UpdateProgressBar(TotalNumberOfSections);

        // Reopen the scene that was opened before the migration process started.
        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            UnityEditor.SceneManagement.EditorSceneManager.OpenScene(loadedScenePath);
        }

        UnityEngine.Debug.Log("WwiseUnity: Removing lock for launcher.");

        // TODO: Moving one folder up is not nice at all. How to find the current project path?
        try
        {
            System.IO.File.Delete(UnityEngine.Application.dataPath + "/../.WwiseLauncherLockFile");
        }
        catch (System.Exception)
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }
Ejemplo n.º 3
0
    static public IDictionary <string, string> GetAllBankPaths()
    {
        WwiseSettings Settings             = WwiseSettings.LoadSettings();
        string        WwiseProjectFullPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);

        UpdateSoundbanksDestinationFolders(WwiseProjectFullPath);
        return(s_ProjectBankPaths);
    }
Ejemplo n.º 4
0
    /// Load a language-specific bank from WWW object
    public void LoadLocalizedBank(string in_bankFilename)
    {
        var bankPath = "file://" + System.IO.Path.Combine(
            System.IO.Path.Combine(AkUtilities.GetWiseBankFolder_Full(), AkSoundEngine.GetCurrentLanguage()),
            in_bankFilename);

        DoLoadBank(bankPath);
    }
Ejemplo n.º 5
0
    public void OnGUI()
    {
        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            AkWwiseProjectInfo.GetData().autoPopulateEnabled =
                UnityEngine.GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

            if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& AkUtilities.IsWwiseProjectAvailable)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
            else
            {
                AkWwiseWWUBuilder.StopWWUWatcher();
            }
            UnityEngine.GUILayout.FlexibleSpace();
            if (UnityEngine.GUILayout.Button("Refresh Project", UnityEngine.GUILayout.Width(200)))
            {
                treeView.SaveExpansionStatus();
                if (AkWwiseProjectInfo.Populate())
                {
                    PopulateTreeview();
                }
            }

            if (UnityEngine.GUILayout.Button("Generate SoundBanks", UnityEngine.GUILayout.Width(200)))
            {
                if (AkUtilities.IsSoundbankGenerationAvailable())
                {
                    AkUtilities.GenerateSoundbanks();
                }
                else
                {
                    string errorMessage;

#if UNITY_EDITOR_WIN
                    errorMessage =
                        "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Windows Installation Path from the Edit > Wwise Settings... menu.";
#elif UNITY_EDITOR_OSX
                    errorMessage =
                        "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Application from the Edit > Wwise Settings... menu.";
#endif

                    UnityEngine.Debug.LogError(errorMessage);
                }
            }
        }

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        treeView.DisplayTreeView(AK.Wwise.TreeView.TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (UnityEngine.GUI.changed && AkUtilities.IsWwiseProjectAvailable)
        {
            UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
Ejemplo n.º 6
0
        public static void SetupSoundbankSetting()
        {
            var WprojPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath);

            AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);

            UnityEditor.EditorApplication.update  += RunOnce;
            AkWwiseXMLWatcher.Instance.XMLUpdated += UpdateAllClips;
        }
Ejemplo n.º 7
0
    public override void OnInspectorGUI()
    {
        if (Event.current.type == EventType.DragExited && m_isInDropArea && DragAndDrop.paths.Length >= 4 && DragAndDrop.paths[3].Equals(m_typeName))
        {
            AkUtilities.SetByteArrayProperty(m_guidProperty[1], new System.Guid(DragAndDrop.paths[4]).ToByteArray());
        }

        base.OnInspectorGUI();
    }
Ejemplo n.º 8
0
        public void TryWriteToFile()
        {
            if (!Active)
            {
                return;
            }

            string RelativePath;
            string CppText;

            if (Target == UnityEditor.BuildTarget.iOS)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AkiOSPlugins.cpp";
                CppText      = "#define AK_IOS";
            }
            else if (Target == UnityEditor.BuildTarget.tvOS)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AktvOSPlugins.cpp";
                CppText      = "#define AK_IOS";
            }
            else if (Target == SwitchBuildTarget)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AkSwitchPlugins.cpp";
                CppText      = "#define AK_NX";
            }
            else
            {
                return;
            }

            CppText += @"
namespace AK { class PluginRegistration; };
#define AK_STATIC_LINK_PLUGIN(_pluginName_) \
extern AK::PluginRegistration _pluginName_##Registration; \
void *_pluginName_##_fp = (void*)&_pluginName_##Registration;

";

            foreach (var filename in FactoriesHeaderFilenames)
            {
                CppText += "#include \"" + filename + "\"\n";
            }

            try
            {
                var FullPath = System.IO.Path.GetFullPath(AkUtilities.GetPathInPackage(WwisePluginFolder + RelativePath));
                System.IO.File.WriteAllText(FullPath, CppText);
            }
            catch (System.Exception e)
            {
                UnityEngine.Debug.LogError("WwiseUnity: Could not write <" + RelativePath + ">. Exception: " + e.Message);
                return;
            }

            UnityEditor.AssetDatabase.Refresh();
        }
Ejemplo n.º 9
0
    public void OnGUI()
    {
        GUILayout.BeginHorizontal("Box");

        AkWwiseProjectInfo.GetData().autoPopulateEnabled = GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

        if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& WwiseProjectFound)
        {
            AkWwiseWWUBuilder.StartWWUWatcher();
        }
        else
        {
            AkWwiseWWUBuilder.StopWWUWatcher();
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Refresh Project", GUILayout.Width(200)))
        {
            treeView.SaveExpansionStatus();
            if (AkWwiseProjectInfo.Populate())
            {
                PopulateTreeview();
            }
        }

        if (GUILayout.Button("Generate SoundBanks", GUILayout.Width(200)))
        {
            if (AkUtilities.IsSoundbankGenerationAvailable())
            {
                AkUtilities.GenerateSoundbanks();
            }
            else
            {
                string errorMessage;

#if UNITY_EDITOR_WIN
                errorMessage = "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Windows Installation Path from the Edit > Wwise Settings... menu.";
#elif UNITY_EDITOR_OSX
                errorMessage = "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Application from the Edit > Wwise Settings... menu.";
#endif

                Debug.LogError(errorMessage);
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        treeView.DisplayTreeView(TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (GUI.changed && WwiseProjectFound)
        {
            EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
Ejemplo n.º 10
0
    void GenerateWwiseIDsCsFile()
    {
        string SoundbankPath = AkUtilities.GetFullPath(Application.streamingAssetsPath, Settings.SoundbankPath);

        if (File.Exists(Path.Combine(SoundbankPath, "Wwise_IDs.h")))
        {
            AkWwiseIDConverter converter = new AkWwiseIDConverter(SoundbankPath);
            converter.Convert(false);
        }
    }
Ejemplo n.º 11
0
 private void CallbackHandler(object in_cookie, AkCallbackType in_type, object in_info)
 {
     if (in_type == AkCallbackType.AK_EndOfEvent)
     {
         var akEvent = in_cookie as AkEvent;
         UnityEngine.Debug.Log("RemoveAkEvent(): " + akEvent.gameObject.name);
         RemoveAkEvent(akEvent);
         AkUtilities.RepaintInspector();
     }
 }
Ejemplo n.º 12
0
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.WwiseTypes_v2018_1_6))
        {
            return(false);
        }

        return(AK.Wwise.TypeMigration.ProcessSingleGuidType(obj.FindProperty("data.WwiseObjectReference"), WwiseObjectType.Soundbank,
                                                            obj.FindProperty("valueGuidInternal"), obj.FindProperty("bankNameInternal")));
    }
Ejemplo n.º 13
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            var fullWwiseProjectPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath);
            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(fullWwiseProjectPath);

            AkUtilities.IsWwiseProjectAvailable = System.IO.File.Exists(fullWwiseProjectPath);
            if (!AkUtilities.IsWwiseProjectAvailable || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (WwiseObjectReference.migrate == null && !builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();

            if (WwiseObjectReference.migrate != null)
            {
                UpdateWwiseObjectReferenceData();
                PopulateWwiseObjectReferences();

                UnityEditor.AssetDatabase.SaveAssets();

                var currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(currentScene);
            }

            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
            return(true);
        }
    }
Ejemplo n.º 14
0
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.NewScriptableObjectFolder_v2019_2_0))
        {
            return(false);
        }

        UnityEditor.Undo.AddComponent <AkRoomAwareObject>(gameObject);

        return(true);
    }
Ejemplo n.º 15
0
        private void HandleDragAndDrop(UnityEngine.Rect dropArea)
        {
            var currentEvent = UnityEngine.Event.current;

            if (currentEvent.type == UnityEngine.EventType.DragExited)
            {
                UnityEditor.DragAndDrop.PrepareStartDrag();
            }
            else if (currentEvent.type == UnityEngine.EventType.DragUpdated ||
                     currentEvent.type == UnityEngine.EventType.DragPerform)
            {
                if (dropArea.Contains(currentEvent.mousePosition))
                {
                    var DDData = GetAkDragDropData();

                    if (currentEvent.type == UnityEngine.EventType.DragUpdated)
                    {
                        UnityEditor.DragAndDrop.visualMode = DDData != null
                                                        ? UnityEditor.DragAndDropVisualMode.Link
                                                        : UnityEditor.DragAndDropVisualMode.Rejected;
                    }
                    else
                    {
                        UnityEditor.DragAndDrop.AcceptDrag();

                        if (DDData != null)
                        {
                            AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray());
                            m_IDProperty[0].intValue = DDData.ID;

                            var DDGroupData = DDData as AkDragDropGroupData;
                            if (DDGroupData != null)
                            {
                                if (m_guidProperty.Length > 1)
                                {
                                    AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray());
                                }

                                if (m_IDProperty.Length > 1)
                                {
                                    m_IDProperty[1].intValue = DDGroupData.groupID;
                                }
                            }

                            // needed for the undo operation to work
                            UnityEngine.GUIUtility.hotControl = 0;
                        }
                    }

                    currentEvent.Use();
                }
            }
        }
Ejemplo n.º 16
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                                         WwiseSetupWizard.Settings.WwiseProjectPath));

            if (!System.IO.File.Exists(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                               WwiseSetupWizard.Settings.WwiseProjectPath)))
            {
                AkWwisePicker.WwiseProjectFound = false;
                return(false);
            }

            AkWwisePicker.WwiseProjectFound = true;

            if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (!builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();
            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
        }

        return(true);        //There was an error, assume that we need to refresh.
    }
Ejemplo n.º 17
0
    public override void DisplayTreeView(DisplayTypes displayType)
    {
        if (AkWwisePicker.WwiseProjectFound)
        {
            var filterString = m_filterString;

            if (m_filterBoxStyle == null)
            {
                m_filterBoxStyle = UnityEngine.Object
                                   .Instantiate(UnityEditor.EditorGUIUtility.GetBuiltinSkin(UnityEditor.EditorSkin.Inspector))
                                   .FindStyle("SearchTextField");
                m_filterBoxCancelButtonStyle = UnityEngine.Object
                                               .Instantiate(UnityEditor.EditorGUIUtility.GetBuiltinSkin(UnityEditor.EditorSkin.Inspector))
                                               .FindStyle("SearchCancelButton");
            }

            UnityEngine.GUILayout.BeginHorizontal("Box");
            {
                m_filterString = UnityEngine.GUILayout.TextField(m_filterString, m_filterBoxStyle);
                if (UnityEngine.GUILayout.Button("", m_filterBoxCancelButtonStyle))
                {
                    m_filterString = "";
                }
            }
            UnityEngine.GUILayout.EndHorizontal();

            if (!m_filterString.Equals(filterString))
            {
                if (filterString.Equals(string.Empty))
                {
                    SaveExpansionStatus();
                }

                FilterTreeview(RootItem);

                if (m_filterString.Equals(string.Empty))
                {
                    var path = "";
                    RestoreExpansionStatus(RootItem, ref path);
                }
            }

            base.DisplayTreeView(displayType);
        }
        else
        {
            UnityEngine.GUILayout.Label("Wwise Project not found at path:");
            UnityEngine.GUILayout.Label(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                WwiseSetupWizard.Settings.WwiseProjectPath));
            UnityEngine.GUILayout.Label("Wwise Picker will not be usable.");
        }
    }
    public static string GetDecodedBankFullPath()
    {
//#if UNITY_SWITCH && !UNITY_EDITOR
//		// Calling Application.persistentDataPath crashes Switch
//		return null;
//#elif (UNITY_ANDROID || PLATFORM_LUMIN || UNITY_IOS) && !UNITY_EDITOR
//		// This is for platforms that only have a specific file location for persistent data.
//		return System.IO.Path.Combine(UnityEngine.Application.persistentDataPath, GetDecodedBankFolder());
//#else
//        return System.IO.Path.Combine(AkBasePathGetter.GetPlatformBasePath(), GetDecodedBankFolder());
//#endif
        return(AkUtilities.GetWiseBankFolder_Full_Decode());
    }
Ejemplo n.º 19
0
    public static void Tick()
    {
        if (s_populateNow)
        {
            AkWwisePicker.treeView.SaveExpansionStatus();
            AutoPopulate();
            AkWwisePicker.PopulateTreeview();
            s_populateNow = false;

            //Make sure that the Wwise picker and the inspector are updated
            AkUtilities.RepaintInspector();
        }
    }
Ejemplo n.º 20
0
    /// <summary>
    /// Tries to communicate with Wwise and compares the current open project with the project path specified in the Unity Wwise Editor settings.
    /// </summary>
    /// <returns>True if the correct wwise project is open in Wwise.</returns>
    private async static Task <bool> CheckProjectLoaded()
    {
        try
        {
            var result = await GetProjectInfo();

            if (result.Count == 0)
            {
                throw new Wamp.ErrorException("Did not get a response from Wwise project");
            }
            var projectInfo = result[0];
#if UNITY_EDITOR_OSX
            var d1 = AkUtilities.ParseOsxPathFromWinePath(projectInfo.filePath);
#else
            var d1 = projectInfo.filePath;
#endif
            var d2 = AkUtilities.GetFullPath(dataPath, AkWwiseEditorSettings.Instance.WwiseProjectPath);
            d1 = d1.Replace("/", "\\");
            d2 = d2.Replace("/", "\\");
            if (d1 != d2)
            {
                ConnectionFailed($"The wrong project({projectInfo.name}) is open in Wwise");
                return(false);
            }
        }

        catch (Wamp.ErrorException e)
        {
            if (e.Json != null)
            {
                ErrorMessage msg = UnityEngine.JsonUtility.FromJson <ErrorMessage>(e.Json);
                if (msg != null)
                {
                    if (msg.message != null)
                    {
                        ErrorMessage = msg.message;
                    }
                }
            }
            if (e.Uri == "ak.wwise.locked")
            {
                return(true);
            }


            ConnectionFailed($"No project is open in Wwise yet");
            return(false);
        }

        return(true);
    }
Ejemplo n.º 21
0
    /// <summary>
    /// Uses a waapi call to get the SoundBank's generated bank path, then opens the containing folder in the system's file browser.
    /// </summary>
    /// <param name="guid">GUID of the object to be found.</param>
    /// <returns>Awaitable Task.</returns>
    private static async Task OpenSoundBankInExplorerAsync(System.Guid guid)
    {
        var args    = new WaqlArgs($"from object \"{guid:B}\"");
        var options = new ReturnOptions(new string[] { "soundbankBnkFilePath" });
        var result  = await WaapiClient.Call([email protected], args, options);

        var ret      = UnityEngine.JsonUtility.FromJson <ReturnWwiseObjects>(result);
        var filePath = ret.@return[0].soundbankBnkFilePath;

#if UNITY_EDITOR_OSX
        filePath = AkUtilities.ParseOsxPathFromWinePath(filePath);
#endif
        UnityEditor.EditorUtility.RevealInFinder(filePath);
    }
Ejemplo n.º 22
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        WwiseSettings Settings  = WwiseSettings.LoadSettings();
        string        WprojPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);
        AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);
#endif
        var playable = ScriptPlayable <AkEventPlayableBehavior> .Create(graph);

        playable.SetInputCount(inputCount);
        setFadeTimes();
        setOwnerClips();
        return(playable);
    }
Ejemplo n.º 23
0
 public override void OnInspectorGUI()
 {
     object[] DDInfo = (object[])DragAndDrop.GetGenericData("AKWwiseDDInfo");
     if (DDInfo != null && DDInfo.Length >= 4)
     {
         string DDTypeName = (string)DDInfo[3];
         if (Event.current.type == EventType.DragExited && m_isInDropArea && DDTypeName.Equals(m_typeName))
         {
             Guid DDGuid = (Guid)DDInfo[4];
             AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGuid.ToByteArray());
         }
     }
     base.OnInspectorGUI();
 }
Ejemplo n.º 24
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
                                   UnityEngine.GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            SetupSerializedProperties(property);

            // Draw label
            position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                         UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive), label);

            var componentGuid = new System.Guid[m_guidProperty.Length];

            for (var i = 0; i < componentGuid.Length; i++)
            {
                var guidBytes = AkUtilities.GetByteArrayProperty(m_guidProperty[i]);
                componentGuid[i] = guidBytes == null ? System.Guid.Empty : new System.Guid(guidBytes);
            }

            var componentName = UpdateIds(componentGuid);
            var style         = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            if (string.IsNullOrEmpty(componentName))
            {
                SetEmptyComponentName(ref componentName, ref style);
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType       = m_objectType,
                    guidProperty     = m_guidProperty,
                    idProperty       = m_IDProperty,
                    pickerPosition   = AkUtilities.GetLastRectAbsolute(position),
                    serializedObject = property.serializedObject
                };

                AkWwiseComponentPicker.LastFocusedWindow = UnityEditor.EditorWindow.focusedWindow;
            }

            HandleDragAndDrop(position);

            UnityEditor.EditorGUI.EndProperty();
        }
Ejemplo n.º 25
0
    void SetGuid(TreeViewItem in_item)
    {
        m_serializedObject.Update();

        //we set the items guid
        AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], (in_item.DataContext as AkWwiseTreeView.AkTreeInfo).Guid);

        //When its a State or a Switch, we set the group's guid
        if (m_selectedItemGuid.Length == 2)
        {
            AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], (in_item.Parent.DataContext as AkWwiseTreeView.AkTreeInfo).Guid);
        }

        m_serializedObject.ApplyModifiedProperties();
    }
Ejemplo n.º 26
0
    public static void Tick()
    {
        if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& DateTime.Now.Subtract(s_lastFileCheck).Seconds > s_SecondsBetweenChecks && !EditorApplication.isCompiling && !EditorApplication.isPlayingOrWillChangePlaymode)
        {
            AkWwisePicker.treeView.SaveExpansionStatus();
            if (AutoPopulate())
            {
                AkWwisePicker.PopulateTreeview();
                //Make sure that the Wwise picker and the inspector are updated
                AkUtilities.RepaintInspector();
            }

            s_lastFileCheck = DateTime.Now;
        }
    }
Ejemplo n.º 27
0
    public override UnityEngine.Playables.Playable CreateTrackMixer(UnityEngine.Playables.PlayableGraph graph,
                                                                    UnityEngine.GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        var Settings  = WwiseSettings.LoadSettings();
        var WprojPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);
        AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);
#endif
        var playable = UnityEngine.Playables.ScriptPlayable <AkEventPlayableBehavior> .Create(graph);

        UnityEngine.Playables.PlayableExtensions.SetInputCount(playable, inputCount);
        setFadeTimes();
        setOwnerClips();
        return(playable);
    }
Ejemplo n.º 28
0
    /// <summary>
    ///     Determines the platform base path for use within the Editor.
    /// </summary>
    /// <param name="platformName">The platform name.</param>
    /// <returns>The full path to the sound banks for use within the Editor.</returns>
    public static string GetPlatformBasePathEditor(string platformName)
    {
        var Settings             = WwiseSettings.LoadSettings();
        var WwiseProjectFullPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);
        var SoundBankDest        = AkUtilities.GetWwiseSoundBankDestinationFolder(platformName, WwiseProjectFullPath);

        try
        {
            if (System.IO.Path.GetPathRoot(SoundBankDest) == "")
            {
                // Path is relative, make it full
                SoundBankDest = AkUtilities.GetFullPath(System.IO.Path.GetDirectoryName(WwiseProjectFullPath), SoundBankDest);
            }
        }
        catch
        {
            SoundBankDest = string.Empty;
        }

        if (string.IsNullOrEmpty(SoundBankDest))
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: The platform SoundBank subfolder within the Wwise project could not be found.");
        }
        else
        {
            try
            {
                // Verify if there are banks in there
                var di         = new System.IO.DirectoryInfo(SoundBankDest);
                var foundBanks = di.GetFiles("*.bnk", System.IO.SearchOption.AllDirectories);
                if (foundBanks.Length == 0)
                {
                    SoundBankDest = string.Empty;
                }
                else if (!SoundBankDest.Contains(platformName))
                {
                    UnityEngine.Debug.LogWarning(
                        "WwiseUnity: The platform SoundBank subfolder does not match your platform name. You will need to create a custom platform name getter for your game. See section \"Using Wwise Custom Platforms in Unity\" of the Wwise Unity integration documentation for more information");
                }
            }
            catch
            {
                SoundBankDest = string.Empty;
            }
        }

        return(SoundBankDest);
    }
Ejemplo n.º 29
0
    void OnEnable()
    {
        if (string.IsNullOrEmpty(WwiseSettings.LoadSettings().WwiseProjectPath))
        {
            return;
        }

        string[] dir = { "Events", "States", "Switches", "Master-Mixer Hierarchy", "SoundBanks" };
        string   wwiseProjectPath = Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath));

        try
        {
            for (int i = 0; i < dir.Length; i++)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(wwiseProjectPath, dir[i]));
                FileInfo[]    files   = dirInfo.GetFiles("*.wwu", SearchOption.AllDirectories);

                ArrayList     list     = AkWwiseProjectInfo.GetData().GetWwuListByString(dir[i]);
                List <string> pathList = new List <string>(list.Count);
                for (int j = 0; j < list.Count; j++)
                {
                    pathList.Add(Path.Combine(wwiseProjectPath, (list[j] as AkWwiseProjectData.WorkUnit).PhysicalPath));
                }

                foreach (FileInfo file in files)
                {
                    if (file.LastWriteTime.CompareTo(AkWwiseProjectInfo.GetData().GetLastPopulateTime()) > 0)
                    {
                        AkWwiseWWUBuilder.s_createdWwu.Add(file.FullName);
                    }

                    pathList.Remove(file.FullName);
                }

                AkWwiseWWUBuilder.s_deletedWwu.AddRange(pathList);
            }
            if (AkWwiseWWUBuilder.s_createdWwu.Count != 0 || AkWwiseWWUBuilder.s_deletedWwu.Count != 0)
            {
                treeView.SaveExpansionStatus();
                AkWwiseWWUBuilder.AutoPopulate();
                PopulateTreeview();
            }
        }
        catch (Exception)
        {
            WwiseProjectFound = false;
        }
    }
Ejemplo n.º 30
0
    // Load the WwiseSettings structure from a serialized XML file
    public static WwiseSettings LoadSettings(bool ForceLoad = false)
    {
        if (s_Instance != null && !ForceLoad)
        {
            return(s_Instance);
        }

        WwiseSettings Settings = new WwiseSettings();

        try
        {
            if (File.Exists(Path.Combine(Application.dataPath, WwiseSettingsFilename)))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(Settings.GetType());
                FileStream    xmlFileStream = new FileStream(Application.dataPath + "/" + WwiseSettingsFilename, FileMode.Open, FileAccess.Read);
                Settings = (WwiseSettings)xmlSerializer.Deserialize(xmlFileStream);
                xmlFileStream.Close();
            }
            else
            {
                string   projectDir         = Path.GetDirectoryName(Application.dataPath);
                string[] foundWwiseProjects = Directory.GetFiles(projectDir, "*.wproj", SearchOption.AllDirectories);

                if (foundWwiseProjects.Length == 0)
                {
                    Settings.WwiseProjectPath = "";
                }
                else
                {
                    // MONO BUG: https://github.com/mono/mono/pull/471
                    // In the editor, Application.dataPath returns <Project Folder>/Assets. There is a bug in
                    // mono for method Uri.GetRelativeUri where if the path ends in a folder, it will
                    // ignore the last part of the path. Thus, we need to add fake depth to get the "real"
                    // relative path.
                    Settings.WwiseProjectPath = AkUtilities.MakeRelativePath(Application.dataPath + "/fake_depth", foundWwiseProjects[0]);
                }

                Settings.SoundbankPath = AkInitializer.c_DefaultBasePath;
            }

            s_Instance = Settings;
        }
        catch (Exception)
        {
        }

        return(Settings);
    }