示例#1
0
    private void completedPlaylist(string playlist, string type)
    {
        string key = "";

        foreach (KeyValuePair <string, SoundPlaylist> pl in playlists)
        {
            if (pl.Value.samplename == playlist)
            {
                key = pl.Key;
            }
        }

        if (key != "")
        {
            SoundPlaylist cp = playlists[playlist];
            cp.callback(playlist, "complete");
            playlists.Remove(key);
            cp.dispose();
        }
    }
示例#2
0
        public override object OnGUI(GUIContent label, object obj, bool isSceneObject, params object[] attributes)
        {
            var fsmMusicPlaylistName = (FsmSoundPlaylistName)obj;

            fsmMusicPlaylistName.from = (FsmSoundPlaylistName.FromType)EditField(" ", typeof(FsmSoundPlaylistName.FromType), fsmMusicPlaylistName.from, attributes);

            switch (fsmMusicPlaylistName.from)
            {
            case FsmSoundPlaylistName.FromType.Playlist:
                if (!mPlaylist)
                {
                    //manually grab
                    mPlaylist = AssetDatabase.LoadAssetAtPath <SoundPlaylist>(SoundPlaylist.assetPath);
                    if (!mPlaylist)
                    {
                        //grab first instance of type from assets (there should only be one anyhow)
                        var guids = AssetDatabase.FindAssets("t:" + typeof(SoundPlaylist).Name);
                        if (guids.Length > 0)
                        {
                            mPlaylist = AssetDatabase.LoadAssetAtPath <SoundPlaylist>(AssetDatabase.GUIDToAssetPath(guids[0]));
                        }
                    }
                }

                if (mPlaylist)
                {
                    //generate names
                    var musicNameList = new List <string>();
                    musicNameList.Add("<None>");
                    for (int i = 0; i < mPlaylist.sounds.Length; i++)
                    {
                        musicNameList.Add(mPlaylist.sounds[i].name);
                    }

                    var curMusicName = fsmMusicPlaylistName.GetString();

                    //get current take name list index
                    int index = -1;
                    if (string.IsNullOrEmpty(curMusicName))
                    {
                        index = 0;
                    }
                    else
                    {
                        for (int i = 1; i < musicNameList.Count; i++)
                        {
                            if (musicNameList[i] == curMusicName)
                            {
                                index = i;
                                break;
                            }
                        }
                    }

                    //select
                    fsmMusicPlaylistName.stringRef.UseVariable = false;

                    index = EditorGUILayout.Popup(" ", index, musicNameList.ToArray());
                    if (index >= 1 && index < musicNameList.Count)
                    {
                        fsmMusicPlaylistName.stringRef.Value = musicNameList[index];
                    }
                    else
                    {
                        fsmMusicPlaylistName.stringRef.Value = "";
                    }
                }
                else
                {
                    EditField("stringRef", " ", fsmMusicPlaylistName.stringRef, attributes);
                }
                break;

            case FsmSoundPlaylistName.FromType.StringRef:
                EditField("stringRef", " ", fsmMusicPlaylistName.stringRef, attributes);
                break;
            }

            return(obj);
        }