Beispiel #1
0
    public void OnEnable()
    {
        if (m_treeViewState == null)
        {
            m_treeViewState = new UnityEditor.IMGUI.Controls.TreeViewState();
        }

        var multiColumnHeaderState = AkWwiseTreeView.CreateDefaultMultiColumnHeaderState();
        var multiColumnHeader      = new UnityEditor.IMGUI.Controls.MultiColumnHeader(multiColumnHeaderState);

        m_treeView = new AkWwiseTreeView(m_treeViewState, multiColumnHeader, AkWwiseProjectInfo.GetTreeData());
        m_treeView.SetDoubleClickFunction(PlayPauseItem);

        m_treeView.dirtyDelegate = RequestRepaint;

        m_SearchField = new UnityEditor.IMGUI.Controls.SearchField();
        m_SearchField.downOrUpArrowKeyPressed += m_treeView.SetFocusAndEnsureSelectedItem;
        m_SearchField.SetFocus();
    }
Beispiel #2
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());
        }
    }