Пример #1
0
    private static AkWwiseProjectData.WorkUnit ReplaceWwuEntry(string in_currentPhysicalPath, AssetType in_type, out int out_wwuIndex)
    {
        var list = AkWwiseProjectInfo.GetData().GetWwuListByString(in_type.RootDirectoryName);

        out_wwuIndex = list.BinarySearch(new AkWwiseProjectData.WorkUnit {
            PhysicalPath = in_currentPhysicalPath
        });
        var out_wwu = CreateWorkUnit(in_type.Type);

        if (out_wwuIndex < 0)
        {
            out_wwuIndex = ~out_wwuIndex;
            list.Insert(out_wwuIndex, out_wwu);
        }
        else
        {
            list[out_wwuIndex] = out_wwu;
        }

        return(out_wwu);
    }
    public override string UpdateIds(Guid[] in_guid)
    {
        for (int i = 0; i < AkWwiseProjectInfo.GetData().EventWwu.Count; i++)
        {
            AkWwiseProjectData.Event e = AkWwiseProjectInfo.GetData().EventWwu[i].List.Find(x => new Guid(x.Guid).Equals(in_guid[0]));

            if (e != null)
            {
                if (target != null)
                {
                    serializedObject.Update();
                    eventID.intValue = e.ID;
                    serializedObject.ApplyModifiedProperties();
                }

                return(e.Name);
            }
        }

        return(string.Empty);
    }
Пример #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        GUILayout.BeginVertical();
        EditorGUILayout.PropertyField(m_basePath, new GUIContent("Base Path"));
        EditorGUILayout.PropertyField(m_language, new GUIContent("Language"));
        EditorGUILayout.PropertyField(m_defaultPoolSize, new GUIContent("Default Pool Size (KB)"));
        EditorGUILayout.PropertyField(m_lowerPoolSize, new GUIContent("Lower Pool Size (KB)"));
        EditorGUILayout.PropertyField(m_streamingPoolSize, new GUIContent("Streaming Pool Size (KB)"));
        EditorGUILayout.PropertyField(m_preparePoolSize, new GUIContent("Prepare Pool Size (KB)"));
        EditorGUILayout.PropertyField(m_memoryCutoffThreshold, new GUIContent("Memory Cutoff Threshold"));
        EditorGUILayout.PropertyField(m_engineLogging, new GUIContent("Enable Wwise engine logging"));
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
        if (GUI.changed)
        {
            AkWwiseProjectInfo.GetData().SaveInitSettings(m_AkInit);
        }
    }
Пример #4
0
    public byte[][] GetSwitchGuidByName(string in_groupName, string in_valueName)
    {
        byte[][] guids = new byte[][] { new byte[16], new byte[16] };

        for (int i = 0; i < AkWwiseProjectInfo.GetData().SwitchWwu.Count; i++)
        {
            AkWwiseProjectData.GroupValue switchGroup = AkWwiseProjectInfo.GetData().SwitchWwu[i].List.Find(x => x.Name.Equals(in_groupName));

            if (switchGroup != null)
            {
                guids[0] = switchGroup.Guid;

                int index = switchGroup.values.FindIndex(x => x == in_valueName);
                guids[1] = switchGroup.ValueGuids[index].bytes;

                return(guids);
            }
        }

        return(null);
    }
Пример #5
0
    private string GetWwuPathAndIcons(
        string in_parentRelativePhysicalPath
        , string in_wwuType
        , string in_relativePhysicalPath
        , out System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> out_PathAndIcons
        )
    {
        var wwuRelPath        = in_parentRelativePhysicalPath;
        var currentPathInProj = string.Empty;

        out_PathAndIcons = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>();

        while (!wwuRelPath.Equals(string.Empty))
        {
            //Add work unit name to the hierarchy
            var wwuName = System.IO.Path.GetFileNameWithoutExtension(wwuRelPath);
            currentPathInProj = System.IO.Path.Combine(wwuName, currentPathInProj);
            //Add work unit icon to the hierarchy
            out_PathAndIcons.AddFirst(new AkWwiseProjectData.PathElement(wwuName, WwiseObjectType.WorkUnit));

            //Get the physical path of the parent work unit if any
            var list  = AkWwiseProjectInfo.GetData().GetWwuListByString(in_wwuType);
            var index = list.BinarySearch(new AkWwiseProjectData.WorkUnit {
                PhysicalPath = wwuRelPath
            });
            wwuRelPath = (list[index] as AkWwiseProjectData.WorkUnit).ParentPath;
        }

        //Add physical folders to the hierarchy if the work unit isn't in the root folder
        var physicalPath = in_relativePhysicalPath.Split(System.IO.Path.DirectorySeparatorChar);

        for (var i = physicalPath.Length - 2; i > 0; i--)
        {
            out_PathAndIcons.AddFirst(
                new AkWwiseProjectData.PathElement(physicalPath[i], WwiseObjectType.PhysicalFolder));
            currentPathInProj = System.IO.Path.Combine(physicalPath[i], currentPathInProj);
        }

        return(currentPathInProj);
    }
Пример #6
0
    private void UpdateWorkUnit(string in_parentRelativePath, string in_wwuFullPath, string in_wwuType,
                                string in_relativePath)
    {
        var wwuRelPath = in_parentRelativePath;

        var PathAndIcons = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>();

        //We need to build the work unit's hierarchy to display it in the right place in the picker
        var currentPathInProj = string.Empty;

        while (!wwuRelPath.Equals(string.Empty))
        {
            //Add work unit name to the hierarchy
            var wwuName = System.IO.Path.GetFileNameWithoutExtension(wwuRelPath);
            currentPathInProj = System.IO.Path.Combine(wwuName, currentPathInProj);
            //Add work unit icon to the hierarchy
            PathAndIcons.AddFirst(new AkWwiseProjectData.PathElement(wwuName, AkWwiseProjectData.WwiseObjectType.WORKUNIT));

            //Get the physical path of the parent work unit if any
            var list  = AkWwiseProjectInfo.GetData().GetWwuListByString(in_wwuType);
            var index = list.BinarySearch(new AkWwiseProjectData.WorkUnit(wwuRelPath),
                                          AkWwiseProjectData.s_compareByPhysicalPath);
            wwuRelPath = (list[index] as AkWwiseProjectData.WorkUnit).ParentPhysicalPath;
        }

        //Add physical folders to the hierarchy if the work unit isn't in the root folder
        var physicalPath = in_relativePath.Split(System.IO.Path.DirectorySeparatorChar);

        for (var i = physicalPath.Length - 2; i > 0; i--)
        {
            PathAndIcons.AddFirst(
                new AkWwiseProjectData.PathElement(physicalPath[i], AkWwiseProjectData.WwiseObjectType.PHYSICALFOLDER));
            currentPathInProj = System.IO.Path.Combine(physicalPath[i], currentPathInProj);
        }

        //Parse the work unit file
        RecurseWorkUnit(GetAssetTypeByRootDir(in_wwuType), new System.IO.FileInfo(in_wwuFullPath), currentPathInProj,
                        in_relativePath.Remove(in_relativePath.LastIndexOf(System.IO.Path.DirectorySeparatorChar)), PathAndIcons,
                        in_parentRelativePath);
    }
Пример #7
0
    private static void PostImportFunction()
    {
#if UNITY_2018_1_OR_NEWER
        UnityEditor.EditorApplication.hierarchyChanged += CheckWwiseGlobalExistance;
#else
        UnityEditor.EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance;
#endif
        UnityEditor.EditorApplication.delayCall += CheckPicker;

        if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isCompiling)
        {
            return;
        }

        try
        {
            if (System.IO.File.Exists(UnityEngine.Application.dataPath + System.IO.Path.DirectorySeparatorChar +
                                      WwiseSettings.WwiseSettingsFilename))
            {
                WwiseSetupWizard.Settings = WwiseSettings.LoadSettings();
                AkWwiseProjectInfo.GetData();
            }

            if (!string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                AkWwisePicker.PopulateTreeview();
                if (AkWwiseProjectInfo.GetData().autoPopulateEnabled)
                {
                    AkWwiseWWUBuilder.StartWWUWatcher();
                }
            }
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.Log(e.ToString());
        }

        //Check if a WwiseGlobal object exists in the current scene
        CheckWwiseGlobalExistance();
    }
Пример #8
0
    static bool SerialiseMaxAttenuation(System.Xml.XmlNode node)
    {
        bool bChanged = false;

        for (int i = 0; i < AkWwiseProjectInfo.GetData().EventWwu.Count; i++)
        {
            for (int j = 0; j < AkWwiseProjectInfo.GetData().EventWwu[i].List.Count; j++)
            {
                if (node.Attributes["MaxAttenuation"] != null && node.Attributes["Name"].InnerText == AkWwiseProjectInfo.GetData().EventWwu[i].List[j].Name)
                {
                    float radius = float.Parse(node.Attributes["MaxAttenuation"].InnerText);
                    if (AkWwiseProjectInfo.GetData().EventWwu[i].List[j].maxAttenuation != radius)
                    {
                        AkWwiseProjectInfo.GetData().EventWwu[i].List[j].maxAttenuation = radius;
                        bChanged = true;
                    }
                    break;
                }
            }
        }
        return(bChanged);
    }
Пример #9
0
    private static void Tick()
    {
        isTicking = true;

        if (AkWwiseProjectInfo.GetData() != null)
        {
            if (System.DateTime.Now.Subtract(s_lastFileCheck).Seconds > s_SecondsBetweenChecks &&
                !UnityEditor.EditorApplication.isCompiling && !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode &&
                AkWwiseProjectInfo.GetData().autoPopulateEnabled)
            {
                AkWwisePicker.treeView.SaveExpansionStatus();
                if (Populate())
                {
                    AkWwisePicker.PopulateTreeview();
                    //Make sure that the Wwise picker and the inspector are updated
                    AkUtilities.RepaintInspector();
                }

                s_lastFileCheck = System.DateTime.Now;
            }
        }
    }
    static AkWwisePostImportCallbackSetup()
    {
        var arguments = System.Environment.GetCommandLineArgs();

        if (System.Array.IndexOf(arguments, "-nographics") != -1 &&
            System.Array.IndexOf(arguments, "-wwiseEnableWithNoGraphics") == -1)
        {
            return;
        }

        UnityEditor.EditorApplication.delayCall += CheckMigrationStatus;

        AkUtilities.GetEventDurations = (uint eventID, ref float maximum, ref float minimum) =>
        {
            var eventInfo = AkWwiseProjectInfo.GetData().GetEventInfo(eventID);
            if (eventInfo != null)
            {
                minimum = eventInfo.minDuration;
                maximum = eventInfo.maxDuration;
            }
        };
    }
    private static void Tick()
    {
        isTicking = true;

        if (AkWwiseProjectInfo.GetData() != null)
        {
            if (System.DateTime.Now.Subtract(s_lastFileCheck).Seconds > s_SecondsBetweenChecks &&
                !UnityEditor.EditorApplication.isCompiling && !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode &&
                AkWwiseProjectInfo.GetData().autoPopulateEnabled)
            {
                if (Populate())
                {
                    AkWwiseXMLBuilder.Populate();
                    //check if WAAPI or not
                    AkWwisePicker.Refresh(ignoreIfWaapi: true);
                    //Make sure that the Wwise picker and the inspector are updated
                    AkUtilities.RepaintInspector();
                }

                s_lastFileCheck = System.DateTime.Now;
            }
        }
    }
Пример #12
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();
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        treeView.DisplayTreeView(TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (GUI.changed && WwiseProjectFound)
        {
            EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
Пример #13
0
    bool GatherModifiedFiles()
    {
        bool bChanged     = false;
        int  iBasePathLen = s_wwiseProjectPath.Length + 1;

        foreach (string dir in FoldersOfInterest)
        {
            List <int> deleted      = new List <int>();
            ArrayList  knownFiles   = AkWwiseProjectInfo.GetData().GetWwuListByString(dir);
            int        cKnownBefore = knownFiles.Count;

            DirectoryInfo di    = null;
            FileInfo[]    files = null;
            try
            {
                //Get all Wwus in this folder.
                di    = new DirectoryInfo(Path.Combine(s_wwiseProjectPath, dir));
                files = di.GetFiles("*.wwu", SearchOption.AllDirectories);
            }
            catch (Exception)
            {
                return(false);
            }
            Array.Sort(files, new FileInfo_CompareByPath());

            //Walk both arrays
            int iKnown = 0;
            int iFound = 0;

            while (iFound < files.Length && iKnown < knownFiles.Count)
            {
                AkWwiseProjectData.WorkUnit workunit = knownFiles[iKnown] as AkWwiseProjectData.WorkUnit;
                string foundRelPath = files[iFound].FullName.Substring(iBasePathLen);
                switch (workunit.PhysicalPath.CompareTo(foundRelPath))
                {
                case 0:
                {
                    //File was there and is still there.  Check the FileTimes.
                    try
                    {
                        DateTime lastParsed = workunit.GetLastTime();
                        if (files[iFound].LastWriteTime > lastParsed)
                        {
                            //File has been changed!
                            //If this file had a parent, parse recursively the parent itself
                            m_WwuToProcess.Add(files[iFound].FullName);
                            bChanged = true;
                        }
                    }
                    catch (Exception)
                    {
                        //Access denied probably (file does exists since it was picked up by GetFiles).
                        //Just ignore this file.
                    }
                    iFound++;
                    iKnown++;
                } break;

                case 1:
                {
                    m_WwuToProcess.Add(files[iFound].FullName);
                    iFound++;
                } break;

                case -1:
                {
                    //A file was deleted.  Can't process it now, it would change the array indices.
                    deleted.Add(iKnown);
                    iKnown++;
                } break;
                }
            }

            //The remainder from the files found on disk are all new files.
            for (; iFound < files.Length; iFound++)
            {
                m_WwuToProcess.Add(files[iFound].FullName);
            }

            //All the remainder is deleted.  From the end, of course.
            if (iKnown < knownFiles.Count)
            {
                knownFiles.RemoveRange(iKnown, knownFiles.Count - iKnown);
            }

            //Delete those tagged.
            for (int i = deleted.Count - 1; i >= 0; i--)
            {
                knownFiles.RemoveAt(deleted[i]);
            }

            bChanged |= cKnownBefore != knownFiles.Count;
        }
        return(bChanged || m_WwuToProcess.Count > 0);
    }
Пример #14
0
 public bool GetExpansionStatus(string in_path)
 {
     return(AkWwiseProjectInfo.GetData().ExpandedItems.BinarySearch(in_path) >= 0);
 }
Пример #15
0
    public static void AutoPopulate()
    {
        //Set the total number of work units to process for the progress bar
        s_currentWwuCnt = 0;
        s_totWwuCnt     = s_deletedWwu.Count + s_createdWwu.Count + s_changedWwu.Count;

        //Remove deleted work units from our data structures
        for (int i = 0; i < s_deletedWwu.Count; i++)
        {
            string relativePath = s_deletedWwu[i].Remove(0, s_wwiseProjectPath.Length + 1);
            string wwuType      = relativePath.Split(Path.DirectorySeparatorChar)[0];

            ArrayList list = AkWwiseProjectInfo.GetData().GetWwuListByString(wwuType);
            if (list != null)
            {
                int index = list.BinarySearch(new AkWwiseProjectData.WorkUnit(relativePath), AkWwiseProjectData.s_compareByPhysicalPath);

                if (index >= 0)
                {
                    list.RemoveAt(index);
                }
            }

            //update progress bar
            s_currentWwuCnt++;
        }
        s_deletedWwu.Clear();


        //Update changed work units
        for (int i = 0; i < s_changedWwu.Count; i++)
        {
            string relativePath = s_changedWwu[i].Remove(0, s_wwiseProjectPath.Length + 1);
            string wwuType      = relativePath.Split(Path.DirectorySeparatorChar)[0];

            ArrayList list = AkWwiseProjectInfo.GetData().GetWwuListByString(wwuType);
            if (list != null)
            {
                int index = list.BinarySearch(new AkWwiseProjectData.WorkUnit(relativePath), AkWwiseProjectData.s_compareByPhysicalPath);
                //We assume that the work unit already exist, if it doesn't we skip it
                if (index >= 0)
                {
                    createWorkUnit(relativePath, wwuType, s_changedWwu[i]);
                }
            }

            //update progress bar
            s_currentWwuCnt++;
        }
        s_changedWwu.Clear();


        //Add newly created work units to our data structures
        for (int i = 0; i < s_createdWwu.Count; i++)
        {
            string relativePath = s_createdWwu[i].Remove(0, s_wwiseProjectPath.Length + 1);
            string wwuType      = relativePath.Split(Path.DirectorySeparatorChar)[0];

            if (AkWwiseProjectInfo.GetData().IsSupportedWwuType(wwuType))
            {
                createWorkUnit(relativePath, wwuType, s_createdWwu[i]);
            }

            //update progress bar
            s_currentWwuCnt++;
        }
        s_createdWwu.Clear();


        EditorUtility.ClearProgressBar();

        //Save the currrent time
        AkWwiseProjectInfo.GetData().SetLastPopulateTime(DateTime.Now);
    }
Пример #16
0
    public static void Populate()
    {
        try
        {
            if (EditorApplication.isPlaying)
            {
                return;
            }

            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

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

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

            if (!Directory.Exists(s_wwiseProjectPath))
            {
                AkWwisePicker.WwiseProjectFound = false;
                return;
            }
            else
            {
                AkWwisePicker.WwiseProjectFound = true;
            }

            AkWwiseProjectInfo.GetData().EventWwu.Clear();
            AkWwiseProjectInfo.GetData().AuxBusWwu.Clear();
            AkWwiseProjectInfo.GetData().StateWwu.Clear();
            AkWwiseProjectInfo.GetData().SwitchWwu.Clear();
            AkWwiseProjectInfo.GetData().BankWwu.Clear();



            s_currentWwuCnt = 0;

            List <AssetType> AssetsToParse = new List <AssetType>();
            AssetsToParse.Add(new AssetType("Events", "Event", ""));
            AssetsToParse.Add(new AssetType("States", "StateGroup", "State"));
            AssetsToParse.Add(new AssetType("Switches", "SwitchGroup", "Switch"));
            AssetsToParse.Add(new AssetType("Master-Mixer Hierarchy", "AuxBus", ""));
            AssetsToParse.Add(new AssetType("SoundBanks", "SoundBank", ""));

            s_totWwuCnt = GetNumOfWwus(AssetsToParse);

            foreach (AssetType asset in AssetsToParse)
            {
                bool bSuccess = PopulateListOfType(asset);
                if (!bSuccess)
                {
                    Debug.LogError("Error when parsing the work units for " + asset.XmlElementName + " .");
                }
                else
                {
                    AkWwiseProjectInfo.GetData().GetWwuListByString(asset.RootDirectoryName).Sort(AkWwiseProjectData.s_compareByPhysicalPath);
                }
            }

            EditorUtility.ClearProgressBar();

            AkWwiseProjectInfo.GetData().SetLastPopulateTime(DateTime.Now);
        }
        catch (Exception e)
        {
            Debug.LogError(e.ToString());
            EditorUtility.ClearProgressBar();
        }
    }
        private void DelayCall()
        {
            if (s_componentPicker != null)
            {
                return;
            }

            s_componentPicker = CreateInstance <AkWwiseComponentPicker>();

            //position the window below the button
            var pos = new UnityEngine.Rect(pickerPosition.x, pickerPosition.yMax, 0, 0);

            //If the window gets out of the screen, we place it on top of the button instead
            if (pickerPosition.yMax > UnityEngine.Screen.currentResolution.height / 2)
            {
                pos.y = pickerPosition.y - UnityEngine.Screen.currentResolution.height / 2;
            }

            //We show a drop down window which is automatically destroyed when focus is lost
            s_componentPicker.ShowAsDropDown(pos,
                                             new UnityEngine.Vector2(pickerPosition.width >= 250 ? pickerPosition.width : 250,
                                                                     UnityEngine.Screen.currentResolution.height / 2));

            s_componentPicker.m_selectedItemGuid = guidProperty;
            s_componentPicker.m_selectedItemID   = idProperty;
            s_componentPicker.m_serializedObject = serializedObject;
            s_componentPicker.m_type             = objectType;

            //Make a backup of the tree's expansion status and replace it with an empty list to make sure nothing will get expanded
            //when we populate the tree
            var expandedItemsBackUp = AkWwiseProjectInfo.GetData().ExpandedItems;

            AkWwiseProjectInfo.GetData().ExpandedItems = new System.Collections.Generic.List <string>();

            s_componentPicker.m_treeView.AssignDefaults();
            s_componentPicker.m_treeView.SetRootItem(
                System.IO.Path.GetFileNameWithoutExtension(WwiseSetupWizard.Settings.WwiseProjectPath),
                AkWwiseProjectData.WwiseObjectType.PROJECT);

            //Populate the tree with the correct type
            if (objectType == AkWwiseProjectData.WwiseObjectType.EVENT)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Events",
                                                          AkWwiseProjectInfo.GetData().EventWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.SWITCH)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Switches",
                                                          AkWwiseProjectInfo.GetData().SwitchWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.STATE)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "States",
                                                          AkWwiseProjectInfo.GetData().StateWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.SOUNDBANK)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Banks",
                                                          AkWwiseProjectInfo.GetData().BankWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.AUXBUS)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Auxiliary Busses",
                                                          AkWwiseProjectInfo.GetData().AuxBusWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.GAMEPARAMETER)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Game Parameters",
                                                          AkWwiseProjectInfo.GetData().RtpcWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.TRIGGER)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Triggers",
                                                          AkWwiseProjectInfo.GetData().TriggerWwu);
            }
            else if (objectType == AkWwiseProjectData.WwiseObjectType.ACOUSTICTEXTURE)
            {
                s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Virtual Acoustics",
                                                          AkWwiseProjectInfo.GetData().AcousticTextureWwu);
            }

            AK.Wwise.TreeView.TreeViewItem item = null;

            var byteArray = AkUtilities.GetByteArrayProperty(guidProperty[0]);

            if (byteArray != null)
            {
                item = s_componentPicker.m_treeView.GetItemByGuid(new System.Guid(byteArray));
            }

            if (item != null)
            {
                item.ParentControl.SelectedItem = item;

                var itemIndexFromRoot = 0;

                //Expand all the parents of the selected item.
                //Count the number of items that are displayed before the selected item
                while (true)
                {
                    item.IsExpanded = true;

                    if (item.Parent != null)
                    {
                        itemIndexFromRoot += item.Parent.Items.IndexOf(item) + 1;
                        item = item.Parent;
                    }
                    else
                    {
                        break;
                    }
                }

                //Scroll down the window to make sure that the selected item is always visible when the window opens
                //there seems to be 1 pixel between each item so we add 2 pixels(top and bottom)
                var itemHeight = item.ParentControl.m_skinSelected.button.CalcSize(new UnityEngine.GUIContent(item.Header)).y + 2.0f;
                s_componentPicker.m_treeView.SetScrollViewPosition(new UnityEngine.Vector2(0.0f,
                                                                                           itemHeight * itemIndexFromRoot - UnityEngine.Screen.currentResolution.height / 4));
            }

            //Restore the tree's expansion status
            AkWwiseProjectInfo.GetData().ExpandedItems = expandedItemsBackUp;
        }
Пример #18
0
    private bool CreateWorkUnit(string in_relativePath, string in_wwuType, string in_fullPath)
    {
        var ParentID = string.Empty;

        try
        {
            using (var reader = System.Xml.XmlReader.Create(in_fullPath))
            {
                reader.MoveToContent();

                //We check if the current work unit has a parent and save its guid if its the case
                while (!reader.EOF && reader.ReadState == System.Xml.ReadState.Interactive)
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("WorkUnit"))
                    {
                        if (reader.GetAttribute("PersistMode").Equals("Nested"))
                        {
                            ParentID = reader.GetAttribute("OwnerID");
                        }
                        break;
                    }

                    reader.Read();
                }
            }
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.Log("WwiseUnity: A changed Work unit wasn't found. It must have been deleted " + in_fullPath);
            return(false);
        }

        if (!string.IsNullOrEmpty(ParentID))
        {
            var parentGuid = System.Guid.Empty;

            try
            {
                parentGuid = new System.Guid(ParentID);
            }
            catch
            {
                UnityEngine.Debug.LogWarning("WwiseUnity: \"OwnerID\" in <" + in_fullPath + "> cannot be converted to a GUID (" + ParentID + ")");
                return(false);
            }

            var    list                     = AkWwiseProjectInfo.GetData().GetWwuListByString(in_wwuType);
            var    PathAndIcons             = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>();
            string PathInProj               = string.Empty;
            AkWwiseProjectData.WorkUnit wwu = null;

            if (parentGuid != System.Guid.Empty)
            {
                for (var i = 0; i < list.Count; i++)
                {
                    wwu = list[i] as AkWwiseProjectData.WorkUnit;
                    if (wwu.Guid.Equals(parentGuid))
                    {
                        PathInProj   = wwu.ParentPath;
                        PathAndIcons = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>(wwu.PathAndIcons);
                        break;
                    }
                    else
                    {
                        var WwuChildren = wwu.GetChildrenArrayList();
                        foreach (AkWwiseProjectData.AkInformation child in WwuChildren)
                        {
                            if (child.Guid.Equals(parentGuid))
                            {
                                PathInProj   = child.Path;
                                PathAndIcons = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>(child.PathAndIcons);
                                break;
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(PathInProj))
            {
                RecurseWorkUnit(AssetType.Create(in_wwuType), new System.IO.FileInfo(in_fullPath), PathInProj,
                                in_relativePath.Remove(in_relativePath.LastIndexOf(System.IO.Path.DirectorySeparatorChar)), PathAndIcons,
                                wwu.PhysicalPath);
                return(true);
            }

            //Not found.  Wait for it to load
            return(false);
        }

        //Root Wwu
        UpdateWorkUnit(in_fullPath, in_wwuType, in_relativePath);
        return(true);
    }
Пример #19
0
    private static void AddElementToList(string in_currentPathInProj, System.Xml.XmlReader in_reader, AssetType in_type,
                                         System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, int in_wwuIndex, WwiseObjectType in_LeafType = WwiseObjectType.None)
    {
        switch (in_type.Type)
        {
        case WwiseObjectType.Folder:
        case WwiseObjectType.Bus:
        case WwiseObjectType.AuxBus:
        case WwiseObjectType.Event:
        case WwiseObjectType.Soundbank:
        case WwiseObjectType.GameParameter:
        case WwiseObjectType.Trigger:
        case WwiseObjectType.AcousticTexture:
        {
            var LeafType   = in_LeafType == WwiseObjectType.None ? in_type.Type : in_LeafType;
            var name       = in_reader.GetAttribute("Name");
            var valueToAdd = in_type.Type == WwiseObjectType.Event ? new AkWwiseProjectData.Event() : new AkWwiseProjectData.AkInformation();
            valueToAdd.Name         = name;
            valueToAdd.Guid         = new System.Guid(in_reader.GetAttribute("ID"));
            valueToAdd.PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            FlagForInsertion(valueToAdd, in_type.Type);

            switch (LeafType)
            {
            case WwiseObjectType.AuxBus:
            case WwiseObjectType.Bus:
            case WwiseObjectType.Folder:
                valueToAdd.Path = in_currentPathInProj;
                break;

            default:
                valueToAdd.Path = System.IO.Path.Combine(in_currentPathInProj, name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(name, in_type.Type));
                break;
            }

            switch (in_type.Type)
            {
            case WwiseObjectType.AuxBus:
                AkWwiseProjectInfo.GetData().AuxBusWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.Event:
                AkWwiseProjectInfo.GetData().EventWwu[in_wwuIndex].List.Add(valueToAdd as AkWwiseProjectData.Event);
                break;

            case WwiseObjectType.Soundbank:
                AkWwiseProjectInfo.GetData().BankWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.GameParameter:
                AkWwiseProjectInfo.GetData().RtpcWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.Trigger:
                AkWwiseProjectInfo.GetData().TriggerWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.AcousticTexture:
                AkWwiseProjectInfo.GetData().AcousticTextureWwu[in_wwuIndex].List.Add(valueToAdd);
                break;
            }
        }

            in_reader.Read();
            break;

        case WwiseObjectType.StateGroup:
        case WwiseObjectType.SwitchGroup:
        {
            var valueToAdd = new AkWwiseProjectData.GroupValue();
            if (in_LeafType == WwiseObjectType.Folder)
            {
                valueToAdd.Name         = in_reader.GetAttribute("Name");
                valueToAdd.Guid         = new System.Guid(in_reader.GetAttribute("ID"));
                valueToAdd.PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons);
                valueToAdd.Path         = in_currentPathInProj;

                FlagForInsertion(valueToAdd, in_type.Type);
                in_reader.Read();
            }
            else
            {
                var XmlElement      = System.Xml.Linq.XNode.ReadFrom(in_reader) as System.Xml.Linq.XElement;
                var ChildrenList    = System.Xml.Linq.XName.Get("ChildrenList");
                var ChildrenElement = XmlElement.Element(ChildrenList);
                if (ChildrenElement != null)
                {
                    var name = XmlElement.Attribute("Name").Value;
                    valueToAdd.Name         = name;
                    valueToAdd.Guid         = new System.Guid(XmlElement.Attribute("ID").Value);
                    valueToAdd.Path         = System.IO.Path.Combine(in_currentPathInProj, name);
                    valueToAdd.PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons);
                    valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(name, in_type.Type));

                    FlagForInsertion(valueToAdd, in_type.Type);

                    var ChildElem = System.Xml.Linq.XName.Get(in_type.ChildElementName);
                    foreach (var element in ChildrenElement.Elements(ChildElem))
                    {
                        if (element.Name != in_type.ChildElementName)
                        {
                            continue;
                        }

                        var elementName = element.Attribute("Name").Value;
                        var childValue  = new AkWwiseProjectData.AkBaseInformation
                        {
                            Name = elementName,
                            Guid = new System.Guid(element.Attribute("ID").Value),
                        };
                        childValue.PathAndIcons.Add(new AkWwiseProjectData.PathElement(elementName, in_type.ChildType));
                        valueToAdd.values.Add(childValue);

                        FlagForInsertion(childValue, in_type.ChildType);
                    }
                }
                else
                {
                    valueToAdd = null;
                }
            }

            if (valueToAdd != null)
            {
                switch (in_type.Type)
                {
                case WwiseObjectType.StateGroup:
                    AkWwiseProjectInfo.GetData().StateWwu[in_wwuIndex].List.Add(valueToAdd);
                    break;

                case WwiseObjectType.SwitchGroup:
                    AkWwiseProjectInfo.GetData().SwitchWwu[in_wwuIndex].List.Add(valueToAdd);
                    break;
                }
            }
        }
        break;

        default:
            UnityEngine.Debug.LogError("WwiseUnity: Unknown asset type in WWU parser");
            break;
        }
    }
Пример #20
0
    private void UpdateFiles()
    {
        m_totWwuCnt = m_WwuToProcess.Count;

        var iBasePathLen = s_wwiseProjectPath.Length + 1;
        var iUnprocessed = 0;

        while (m_WwuToProcess.Count - iUnprocessed > 0)
        {
            System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator();
            for (var i = 0; i < iUnprocessed + 1; i++)
            {
                e.MoveNext();
            }

            var fullPath = e.Current as string;
            var relPath  = fullPath.Substring(iBasePathLen);
            var typeStr  = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar));
            if (!CreateWorkUnit(relPath, typeStr, fullPath))
            {
                iUnprocessed++;
            }
        }

        //Add the unprocessed directly.  This can happen if we don't find the parent WorkUnit.
        //Normally, it should never happen, this is just a safe guard.
        while (m_WwuToProcess.Count > 0)
        {
            System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator();
            e.MoveNext();
            var fullPath = e.Current as string;
            var relPath  = fullPath.Substring(iBasePathLen);
            var typeStr  = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar));
            UpdateWorkUnit(fullPath, typeStr, relPath);
        }

        foreach (var pair in _WwiseObjectsToAdd)
        {
            System.Collections.Generic.List <AkWwiseProjectData.AkBaseInformation> removeList = null;
            if (!_WwiseObjectsToRemove.TryGetValue(pair.Key, out removeList))
            {
                continue;
            }

            removeList.Sort(AkWwiseProjectData.AkBaseInformation.CompareByGuid);
            foreach (var info in pair.Value)
            {
                var index = removeList.BinarySearch(info, AkWwiseProjectData.AkBaseInformation.CompareByGuid);
                if (index >= 0)
                {
                    removeList.RemoveAt(index);
                }
            }
        }

        foreach (var pair in _WwiseObjectsToRemove)
        {
            var type      = pair.Key;
            var childType = type == WwiseObjectType.StateGroup ? WwiseObjectType.State : WwiseObjectType.Switch;

            foreach (var info in pair.Value)
            {
                var groupValue = info as AkWwiseProjectData.GroupValue;
                if (groupValue != null)
                {
                    foreach (var value in groupValue.values)
                    {
                        WwiseObjectReference.DeleteWwiseObject(childType, value.Guid);
                    }
                }

                WwiseObjectReference.DeleteWwiseObject(type, info.Guid);
            }
        }

        UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        UnityEditor.EditorUtility.ClearProgressBar();
    }
 public override void SaveExpansionStatus(List <int> expandedItems)
 {
     AkWwiseProjectInfo.GetData().ExpandedFileSystemItemIds = expandedItems;
 }
Пример #22
0
    static public void CheckWwiseGlobalExistance()
    {
        WwiseSettings settings = WwiseSettings.LoadSettings();

#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2
        if (!settings.OldProject && (String.IsNullOrEmpty(EditorApplication.currentScene) || s_CurrentScene != EditorApplication.currentScene))
#else
        string activeSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
        if (!settings.OldProject && s_CurrentScene != activeSceneName)
#endif
        {
            // Look for a game object which has the initializer component
            AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[];
            if (AkInitializers.Length == 0)
            {
                if (settings.CreateWwiseGlobal == true)
                {
                    //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded
                    //in the wrong order.
                    GameObject objWwise = new GameObject("WwiseGlobal");

                    //Attach initializer and terminator components
                    AkInitializer init = objWwise.AddComponent <AkInitializer>();
                    AkWwiseProjectInfo.GetData().CopyInitSettings(init);
                }
            }
            else
            {
                if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal")
                {
                    GameObject.DestroyImmediate(AkInitializers[0].gameObject);
                }
                //All scenes will share the same initializer.  So expose the init settings consistently across scenes.
                AkWwiseProjectInfo.GetData().CopyInitSettings(AkInitializers[0]);
            }

            AkAudioListener[] akAudioListeners = UnityEngine.Object.FindObjectsOfType(typeof(AkAudioListener)) as AkAudioListener[];
            if (akAudioListeners.Length == 0)
            {
                // Remove the audio listener script
                if (Camera.main != null && settings.CreateWwiseListener == true)
                {
                    AudioListener listener = Camera.main.gameObject.GetComponent <AudioListener>();
                    if (listener != null)
                    {
                        Component.DestroyImmediate(listener);
                    }

                    // Add the AkAudioListener script
                    if (Camera.main.gameObject.GetComponent <AkAudioListener>() == null)
                    {
                        Camera.main.gameObject.AddComponent <AkAudioListener>();
                    }
                }
            }
            else
            {
                foreach (AkAudioListener akListener in akAudioListeners)
                {
                    if (settings.CreateWwiseListener == false && akListener.gameObject == Camera.main.gameObject)
                    {
                        Component.DestroyImmediate(akListener);
                    }
                }
            }


#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            s_CurrentScene = EditorApplication.currentScene;
#else
            s_CurrentScene = activeSceneName;
#endif
        }
    }
Пример #23
0
    static void AddElementToList(string in_currentPathInProj, XmlReader in_reader, AssetType in_type, LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, int in_wwuIndex)
    {
        if (in_type.RootDirectoryName == "Events" || in_type.RootDirectoryName == "Master-Mixer Hierarchy" || in_type.RootDirectoryName == "SoundBanks")
        {
            AkWwiseProjectData.Event valueToAdd = new AkWwiseProjectData.Event();

            valueToAdd.Name         = in_reader.GetAttribute("Name");
            valueToAdd.Guid         = new Guid(in_reader.GetAttribute("ID")).ToByteArray();
            valueToAdd.ID           = (int)AkUtilities.ShortIDGenerator.Compute(valueToAdd.Name);
            valueToAdd.Path         = in_type.RootDirectoryName == "Master-Mixer Hierarchy" ? in_currentPathInProj : Path.Combine(in_currentPathInProj, valueToAdd.Name);
            valueToAdd.PathAndIcons = new List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            if (in_type.RootDirectoryName == "Events")
            {
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.EVENT));
                AkWwiseProjectInfo.GetData().EventWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else if (in_type.RootDirectoryName == "SoundBanks")
            {
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.SOUNDBANK));
                AkWwiseProjectInfo.GetData().BankWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else
            {
                AkWwiseProjectInfo.GetData().AuxBusWwu[in_wwuIndex].List.Add(valueToAdd);
            }

            in_reader.Read();
        }
        else if (in_type.RootDirectoryName == "States" || in_type.RootDirectoryName == "Switches")
        {
            var XmlElement = XNode.ReadFrom(in_reader) as XElement;

            AkWwiseProjectData.GroupValue      valueToAdd = new AkWwiseProjectData.GroupValue();
            AkWwiseProjectData.WwiseObjectType SubElemIcon;
            valueToAdd.Name         = XmlElement.Attribute("Name").Value;
            valueToAdd.Guid         = new Guid(XmlElement.Attribute("ID").Value).ToByteArray();
            valueToAdd.ID           = (int)AkUtilities.ShortIDGenerator.Compute(valueToAdd.Name);
            valueToAdd.Path         = Path.Combine(in_currentPathInProj, valueToAdd.Name);
            valueToAdd.PathAndIcons = new List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            if (in_type.RootDirectoryName == "States")
            {
                SubElemIcon = AkWwiseProjectData.WwiseObjectType.STATE;
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.STATEGROUP));
            }
            else
            {
                SubElemIcon = AkWwiseProjectData.WwiseObjectType.SWITCH;
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.SWITCHGROUP));
            }

            XName ChildrenList = XName.Get("ChildrenList");
            XName ChildElem    = XName.Get(in_type.ChildElementName);

            XElement ChildrenElement = XmlElement.Element(ChildrenList);
            if (ChildrenElement != null)
            {
                foreach (var element in ChildrenElement.Elements(ChildElem))
                {
                    if (element.Name == in_type.ChildElementName)
                    {
                        string elementName = element.Attribute("Name").Value;
                        valueToAdd.values.Add(elementName);
                        valueToAdd.ValueGuids.Add(new AkWwiseProjectData.ByteArrayWrapper(new Guid(element.Attribute("ID").Value).ToByteArray()));
                        valueToAdd.valueIDs.Add((int)AkUtilities.ShortIDGenerator.Compute(elementName));
                        valueToAdd.ValueIcons.Add(new AkWwiseProjectData.PathElement(elementName, SubElemIcon));
                    }
                }
            }

            if (in_type.RootDirectoryName == "States")
            {
                AkWwiseProjectInfo.GetData().StateWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else
            {
                AkWwiseProjectInfo.GetData().SwitchWwu[in_wwuIndex].List.Add(valueToAdd);
            }
        }
        else
        {
            Debug.LogError("WwiseUnity: Unknown asset type in WWU parser");
        }
    }
Пример #24
0
    public void OnGUI()
    {
        AkWwiseProjectInfo.DataSourceType ds;
        var buttonWidth = 150;

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            ds = (AkWwiseProjectInfo.DataSourceType)UnityEditor.EditorGUILayout.EnumPopup(
                AkWwiseProjectInfo.GetData().currentDataSource, UnityEngine.GUILayout.Width(buttonWidth));
            UnityEngine.GUILayout.Space(5);

            var projectData = AkWwiseProjectInfo.GetData();

            if (ds != projectData.currentDataSource)
            {
                projectData.currentDataSource = ds;
                m_treeView.SetDataSource(AkWwiseProjectInfo.GetTreeData());
            }

            if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
            {
                projectData.autoPopulateEnabled =
                    UnityEngine.GUILayout.Toggle(projectData.autoPopulateEnabled, "Auto populate");
            }
            else
            {
                projectData.AutoSyncSelection =
                    UnityEngine.GUILayout.Toggle(projectData.AutoSyncSelection, "Autosync selection");
                AkWwiseProjectInfo.WaapiPickerData.AutoSyncSelection = projectData.AutoSyncSelection;
            }

            UnityEngine.GUILayout.FlexibleSpace();

            if (UnityEngine.GUILayout.Button("Refresh Project", UnityEngine.GUILayout.Width(buttonWidth)))
            {
                if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
                {
                    AkWwiseProjectInfo.Populate();
                }
                Refresh();
            }


            if (UnityEngine.GUILayout.Button("Generate SoundBanks", UnityEngine.GUILayout.Width(buttonWidth)))
            {
                if (AkUtilities.IsSoundbankGenerationAvailable())
                {
                    AkUtilities.GenerateSoundbanks();
                }
                else
                {
                    UnityEngine.Debug.LogError("Access to Wwise is required to generate the SoundBanks. Please go to Edit > Project Settings... and set the Wwise Application Path found in the Wwise Editor view.");
                }
            }

            if (projectData.autoPopulateEnabled && AkUtilities.IsWwiseProjectAvailable)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
            else
            {
                AkWwiseWWUBuilder.StopWWUWatcher();
            }
        }

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            var search_width = System.Math.Max(position.width / 3, buttonWidth * 2);

            if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
            {
                m_treeView.StoredSearchString = m_SearchField.OnGUI(UnityEngine.GUILayoutUtility.GetRect(search_width, 20), m_treeView.StoredSearchString);
                UnityEngine.GUILayout.FlexibleSpace();
            }

            else
            {
                m_treeView.StoredSearchString = m_SearchField.OnGUI(UnityEngine.GUILayoutUtility.GetRect(search_width, 20), m_treeView.StoredSearchString);
                UnityEngine.GUILayout.FlexibleSpace();

                var labelStyle = new UnityEngine.GUIStyle();
                labelStyle.richText = true;
                UnityEngine.GUILayout.Label(AkWaapiUtilities.GetStatusString(), labelStyle);
            }
        }

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


        UnityEngine.GUILayout.FlexibleSpace();
        UnityEngine.Rect lastRect = UnityEngine.GUILayoutUtility.GetLastRect();
        m_treeView.OnGUI(new UnityEngine.Rect(lastRect.x, lastRect.y, position.width, lastRect.height));

        if (UnityEngine.GUI.changed && AkUtilities.IsWwiseProjectAvailable)
        {
            UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
    }
Пример #25
0
 static void SerialiseMaxAttenuation(XmlNode node)
 {
     for (int i = 0; i < AkWwiseProjectInfo.GetData().EventWwu.Count; i++)
     {
         for (int j = 0; j < AkWwiseProjectInfo.GetData().EventWwu[i].List.Count; j++)
         {
             if (node.Attributes["MaxAttenuation"] != null && node.Attributes["Name"].InnerText == AkWwiseProjectInfo.GetData().EventWwu[i].List[j].Name)
             {
                 AkWwiseProjectInfo.GetData().EventWwu[i].List[j].maxAttenuation = float.Parse(node.Attributes["MaxAttenuation"].InnerText);
                 break;
             }
         }
     }
 }
Пример #26
0
    public static void UpdateWwiseObjectReferenceData()
    {
        UnityEngine.Debug.Log("WwiseUnity: Updating Wwise Object References");

        WwiseObjectReference.ClearWwiseObjectDataMap();
        UpdateWwiseObjectReference(WwiseObjectType.AuxBus, AkWwiseProjectInfo.GetData().AuxBusWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Event, AkWwiseProjectInfo.GetData().EventWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Soundbank, AkWwiseProjectInfo.GetData().BankWwu);
        UpdateWwiseObjectReference(WwiseObjectType.GameParameter, AkWwiseProjectInfo.GetData().RtpcWwu);
        UpdateWwiseObjectReference(WwiseObjectType.Trigger, AkWwiseProjectInfo.GetData().TriggerWwu);
        UpdateWwiseObjectReference(WwiseObjectType.AcousticTexture, AkWwiseProjectInfo.GetData().AcousticTextureWwu);
        UpdateWwiseObjectReference(WwiseObjectType.StateGroup, WwiseObjectType.State, AkWwiseProjectInfo.GetData().StateWwu);
        UpdateWwiseObjectReference(WwiseObjectType.SwitchGroup, WwiseObjectType.Switch, AkWwiseProjectInfo.GetData().SwitchWwu);
    }
Пример #27
0
    public void RenderAttenuationSpheres()
    {
        if (currentAttSphereOp == AttenuationSphereOptions.Dont_Show)
        {
            return;
        }

        if (currentAttSphereOp == AttenuationSphereOptions.Current_Event_Only)
        {
            // Get the max attenuation for the event (if available)
            var radius = AkWwiseProjectInfo.GetData().GetEventMaxAttenuation(m_AkAmbient.eventID);

            if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.Simple_Mode)
            {
                DrawSphere(m_AkAmbient.gameObject.transform.position, radius);
            }
            else if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.Large_Mode)
            {
                UnityEditor.Handles.matrix = m_AkAmbient.transform.localToWorldMatrix;

                for (var i = 0; i < m_AkAmbient.multiPositionArray.Count; i++)
                {
                    DrawSphere(m_AkAmbient.multiPositionArray[i], radius);
                }
            }
            else
            {
                var akAmbiants = FindObjectsOfType <AkAmbient>();

                for (var i = 0; i < akAmbiants.Length; i++)
                {
                    if (akAmbiants[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode &&
                        akAmbiants[i].eventID == m_AkAmbient.eventID)
                    {
                        DrawSphere(akAmbiants[i].gameObject.transform.position, radius);
                    }
                }
            }
        }
        else
        {
            var akAmbiants = FindObjectsOfType <AkAmbient>();

            for (var i = 0; i < akAmbiants.Length; i++)
            {
                // Get the max attenuation for the event (if available)
                var radius = AkWwiseProjectInfo.GetData().GetEventMaxAttenuation(akAmbiants[i].eventID);

                if (akAmbiants[i].multiPositionTypeLabel == MultiPositionTypeLabel.Large_Mode)
                {
                    UnityEditor.Handles.matrix = akAmbiants[i].transform.localToWorldMatrix;

                    for (var j = 0; j < akAmbiants[i].multiPositionArray.Count; j++)
                    {
                        DrawSphere(akAmbiants[i].multiPositionArray[j], radius);
                    }

                    UnityEditor.Handles.matrix = UnityEngine.Matrix4x4.identity;
                }
                else
                {
                    DrawSphere(akAmbiants[i].gameObject.transform.position, radius);
                }
            }
        }
    }
Пример #28
0
    private static void FlagForRemoval(WwiseObjectType type, int wwuIndex)
    {
        switch (type)
        {
        case WwiseObjectType.AuxBus:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().AuxBusWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.Event:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().EventWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.Soundbank:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().BankWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.GameParameter:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().RtpcWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.Trigger:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().TriggerWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.AcousticTexture:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().AcousticTextureWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.StateGroup:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().StateWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;

        case WwiseObjectType.SwitchGroup:
            foreach (var wwobject in AkWwiseProjectInfo.GetData().SwitchWwu[wwuIndex].List)
            {
                FlagForRemoval(wwobject, type);
            }
            break;
        }
    }
 public override List <int> LoadExpansionSatus()
 {
     return(AkWwiseProjectInfo.GetData().ExpandedFileSystemItemIds);
 }
Пример #30
0
    private bool GatherModifiedFiles()
    {
        _WwiseObjectsToRemove.Clear();
        _WwiseObjectsToAdd.Clear();

        var bChanged     = false;
        var iBasePathLen = s_wwiseProjectPath.Length + 1;

        foreach (var scannedAsset in AssetType.ScannedAssets)
        {
            var dir          = scannedAsset.RootDirectoryName;
            var deleted      = new System.Collections.Generic.List <int>();
            var knownFiles   = AkWwiseProjectInfo.GetData().GetWwuListByString(dir);
            var cKnownBefore = knownFiles.Count;

            try
            {
                //Get all Wwus in this folder.
                var di    = new System.IO.DirectoryInfo(System.IO.Path.Combine(s_wwiseProjectPath, dir));
                var files = di.GetFiles("*.wwu", System.IO.SearchOption.AllDirectories);
                System.Array.Sort(files, s_FileInfo_CompareByPath);

                //Walk both arrays
                var iKnown = 0;
                var iFound = 0;

                while (iFound < files.Length && iKnown < knownFiles.Count)
                {
                    var workunit     = knownFiles[iKnown] as AkWwiseProjectData.WorkUnit;
                    var foundRelPath = files[iFound].FullName.Substring(iBasePathLen);
                    switch (workunit.PhysicalPath.CompareTo(foundRelPath))
                    {
                    case 0:
                        //File was there and is still there.  Check the FileTimes.
                        try
                        {
                            if (files[iFound].LastWriteTime > workunit.LastTime)
                            {
                                //File has been changed!
                                //If this file had a parent, parse recursively the parent itself
                                m_WwuToProcess.Add(files[iFound].FullName);
                                FlagForRemoval(scannedAsset.Type, iKnown);
                                bChanged = true;
                            }
                        }
                        catch
                        {
                            //Access denied probably (file does exists since it was picked up by GetFiles).
                            //Just ignore this file.
                        }

                        iFound++;
                        iKnown++;
                        break;

                    case 1:
                        m_WwuToProcess.Add(files[iFound].FullName);
                        iFound++;
                        break;

                    case -1:
                        //A file was deleted.  Can't process it now, it would change the array indices.
                        deleted.Add(iKnown);
                        iKnown++;
                        break;
                    }
                }

                //The remainder from the files found on disk are all new files.
                for (; iFound < files.Length; iFound++)
                {
                    m_WwuToProcess.Add(files[iFound].FullName);
                }

                //All the remainder is deleted.  From the end, of course.
                if (iKnown < knownFiles.Count)
                {
                    for (var i = iKnown; i < knownFiles.Count; ++i)
                    {
                        FlagForRemoval(scannedAsset.Type, i);
                    }

                    knownFiles.RemoveRange(iKnown, knownFiles.Count - iKnown);
                }

                //Delete those tagged.
                for (var i = deleted.Count - 1; i >= 0; i--)
                {
                    FlagForRemoval(scannedAsset.Type, deleted[i]);
                    knownFiles.RemoveAt(deleted[i]);
                }

                bChanged |= cKnownBefore != knownFiles.Count;
            }
            catch
            {
                return(false);
            }
        }

        return(bChanged || m_WwuToProcess.Count > 0);
    }