1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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<ToggleGroup>();
- 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;
- }
- }
- }
|