Beispiel #1
0
    public FMOD.RESULT loadEventFromFile(FmodEventAudioSource src)
    {
        FmodEvent      evt   = src.getSource();
        FmodEventAsset asset = evt.getAsset();

        FMOD.RESULT         result    = FMOD.RESULT.OK;
        FMOD.EVENT_LOADINFO loadInfo  = new FMOD.EVENT_LOADINFO();
        FMOD.EventProject   project   = null;
        FMOD.Event          fmodEvent = null;

        _loadFile(asset.getMediaPath(), asset.getName(), ref loadInfo, ref project);
        _loadEventGroup(evt);
        result = _loadEvent(evt, ref fmodEvent);
        ERRCHECK(result);
        if (result == FMOD.RESULT.OK)
        {
            src.SetEvent(fmodEvent);
        }
        return(result);
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        FmodEventAsset asset           = this.serializedObject.targetObject as FmodEventAsset;
        List <string>  soundBankList   = asset.getSoundBankList();
        string         currentPath     = asset.getMediaPath();
        string         projectRootPath = System.IO.Path.GetDirectoryName(Application.dataPath);
        string         totalPath       = "";
        bool           soundBankExists = false;

        EditorGUILayout.LabelField("Name", asset.getName());
        EditorGUILayout.LabelField("Sound banks referenced");
        EditorGUI.indentLevel += 1;
        if (soundBankList.Count == 0)
        {
            EditorGUILayout.LabelField("No Sound banks referenced in this file");
        }
        else
        {
            foreach (string soundBank in soundBankList)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(projectRootPath);
                sb.Append("/");
                sb.Append(currentPath);
                sb.Append("/");
                sb.Append(soundBank);
                sb.Append(@".fsb");
                sb.Replace('/', '\\');

                totalPath = sb.ToString();
//				totalPath = string.Concat(projectRootPath, "/", currentPath, "/", soundBank, @".fsb");
//				totalPath = totalPath.Replace("/", "\\");
                soundBankExists = System.IO.File.Exists(totalPath);
                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
                EditorGUILayout.PrefixLabel(soundBank);
                if (soundBankExists)
                {
                    EditorGUILayout.HelpBox("(Found)", MessageType.None);
                }
                else
                {
                    EditorGUILayout.HelpBox("The sound bank could not be found at path '" + totalPath + "'. The events relying on it won't work.", MessageType.Error);
                }
                EditorGUILayout.EndHorizontal();
            }
            if (GUILayout.Button("Refresh"))
            {
                AssetDatabase.ImportAsset(currentPath, ImportAssetOptions.ForceUpdate);
                Repaint();
            }
        }
        EditorGUI.indentLevel -= 1;
        EditorGUILayout.HelpBox("Drag the event name onto the scene to create a source ; Alt + Drag for adding the source as component to target GameObject", MessageType.Info);
        m_showEvents  = EditorGUILayout.Foldout(m_showEvents, "Events");
        m_curNbEvents = 0;
        if (m_showEvents)
        {
            EditorGUI.indentLevel += 1;
            foreach (FmodEventGroup eventGroup in asset.getEventGroups())
            {
                _eventHierarchyGUI(eventGroup);
            }
            EditorGUI.indentLevel -= 1;
        }
        _SetupDragAndDrop(asset);
        EditorGUILayout.Separator();
        EditorGUILayout.HelpBox("Drag the reverb name onto the scene to create a reverb zone", MessageType.Info);
        m_showReverbs = EditorGUILayout.Foldout(m_showReverbs, "Reverb presets");
        if (m_showReverbs)
        {
            if (asset.getReverbs().Count > 0)
            {
                int curNbReverbs = 0;

                EditorGUI.indentLevel += 2;
                foreach (FmodReverb reverb in asset.getReverbs())
                {
                    EditorGUILayout.LabelField(reverb.getName());
                    if (Event.current.type == EventType.Repaint)
                    {
                        Rect lastRect = GUILayoutUtility.GetLastRect();
                        m_reverbsRectangle[curNbReverbs++].Set(lastRect.xMin, lastRect.yMin, lastRect.width, lastRect.height);
                    }
                }
                EditorGUI.indentLevel -= 2;
            }
            else
            {
                EditorGUILayout.LabelField("No reverb preset in this file");
            }
        }
    }