using System; using System.IO; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Serialization; using Agora.Rtc; using Agora.Util; using Logger = Agora.Util.Logger; namespace Agora_RTC_Plugin.API_Example.Examples.Advanced.AudioSpectrum { public class AudioSpectrum : MonoBehaviour { [FormerlySerializedAs("appIdInput")] [SerializeField] private AppIdInput _appIdInput; [Header("_____________Basic Configuration_____________")] [FormerlySerializedAs("APP_ID")] [SerializeField] private string _appID = ""; [FormerlySerializedAs("TOKEN")] [SerializeField] private string _token = ""; [FormerlySerializedAs("CHANNEL_NAME")] [SerializeField] private string _channelName = ""; public Text LogText; public RectTransform spectrums; public List data = new List(); internal Logger Log; internal IRtcEngine RtcEngine = null; internal IMediaPlayer MediaPlayer = null; private const string MPK_URL = "https://agoracdn.s3.us-west-1.amazonaws.com/videos/Agora.io-Interactions.mp4"; private Button _button1; private Button _button2; private Button _button3; private Button _button4; private Button _button5; private Toggle _urlToggle; // Use this for initialization private void Start() { LoadAssetData(); if (CheckAppId()) { SetUpUI(); EnableUI(false); InitEngine(); InitMediaPlayer(); JoinChannelWithMPK(); } } // Update is called once per frame private void Update() { PermissionHelper.RequestMicrophontPermission(); PermissionHelper.RequestCameraPermission(); lock (data) { if (data.Count > 0) { for (var i = 0; i < this.data.Count; i++) { var height = (-data[i] + 1); if (height <= 1) height = 1; var child = (RectTransform)this.spectrums.GetChild(i); child.sizeDelta = new Vector2(15, height); } } data.Clear(); } } private void SetUpUI() { _button1 = GameObject.Find("Button1").GetComponent