コード例 #1
0
        private void GetPlayersInScene()
        {
            playersInScene.Clear();

            UdonBehaviour[] udonBehaviours = FindObjectsOfType <UdonBehaviour>();

            List <string> names = new List <string>();

            foreach (UdonBehaviour ub in udonBehaviours)
            {
                if (ub.programSource == playerProgram)
                {
                    names.Add($"{ub.name} (ID: {ub.GetInstanceID()})");

                    playersInScene.Add(ub.GetUdonSharpComponent <Tunify>());
                }
            }

            playerNames = names.ToArray();

            if (playersInScene.Count == 0)
            {
                player = null; return;
            }

            if (player == null)
            {
                player = playersInScene[0];
            }

            RefreshPlayerStats();
        }
コード例 #2
0
        private void DrawFieldMusicPlayers()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("Active Music Player:", GUILayout.Width(120));

            DrawFieldHighlightPanel(player);

            EditorGUI.BeginChangeCheck();

            player = (Tunify)EditorGUILayout.ObjectField(player, typeof(Tunify), true);

            if (EditorGUI.EndChangeCheck())
            {
                GetPlayerIndex();

                RefreshPlayerStats();
            }

            EditorGUI.BeginChangeCheck();

            playerIndex = EditorGUILayout.Popup(playerIndex, playerNames, GUILayout.Width(120));

            if (EditorGUI.EndChangeCheck())
            {
                player = playersInScene[playerIndex];

                so.ApplyModifiedProperties();

                RefreshPlayerStats();
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label($"Songs: {playerSongCount} | Playlists: {playerPlaylistCount}");

            EditorGUI.BeginDisabledGroup(player == null);

            if (GUILayout.Button("Save To File", GUILayout.MaxWidth(85)))
            {
                SavePlayerPlaylistsToLibrary();
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }