using rtc; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AvatarToggle : MonoBehaviour { public Toggle avatartoggle; public RawImage image; private Texture tex; private string avatar; private void Start() { avatartoggle.onValueChanged.AddListener(ValueChange); ToggleGroup toggleGroup = transform.parent.GetComponent(); if (toggleGroup) { avatartoggle.group = toggleGroup; } if (!string.IsNullOrEmpty(this.avatar)) { if (UserInfo.avatar == this.avatar) { avatartoggle.isOn = true; } } } private void ValueChange(bool isOn) { if (isOn) { Debug.Log("PP"); if (tex != null) { UserSystem.swithAvatarAction?.Invoke(tex); UserInfo.avatar = this.avatar; UserInfo.textIcon = this.tex; } } } public void Init(Texture tex) { if (tex != null) { image.texture = tex; this.tex = tex; } } public void Init(string avatar) { if (!string.IsNullOrEmpty(avatar)) { this.avatar = avatar; } } }