同步进度
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
public enum AudioType
|
||||
{
|
||||
None,
|
||||
BG,
|
||||
FX,
|
||||
|
||||
}
|
||||
public class AudioManager : Singleton<AudioManager>
|
||||
{
|
||||
public bool nan;
|
||||
Dictionary<AudioType,AudioSource> dic_audioList=new Dictionary<AudioType, AudioSource> ();
|
||||
public AudioMixer audioMixer;
|
||||
//public AudioMixer mixer;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
var v = UIManager.Instance.transform.GetChild(0).GetComponents<AudioSource>();
|
||||
dic_audioList.Add(AudioType.BG, v[0]);
|
||||
dic_audioList.Add(AudioType.FX, v[1]);
|
||||
int a = PlayerPrefs.GetInt("first");
|
||||
if (a==0)
|
||||
{
|
||||
PlayerPrefs.SetFloat("slider_AudioBG",1f);
|
||||
PlayerPrefs.SetFloat("slider_FX", 1f);
|
||||
PlayerPrefs.SetInt("first",1);
|
||||
|
||||
}
|
||||
float value = PlayerPrefs.GetFloat("slider_AudioBG");
|
||||
audioMixer.SetFloat("BGVolume", value * 100 - 80);
|
||||
|
||||
value = PlayerPrefs.GetFloat("slider_FX");
|
||||
audioMixer.SetFloat("FXVolume", value*100-80);
|
||||
dic_audioList[AudioType.BG].outputAudioMixerGroup = audioMixer.FindMatchingGroups("Master/BG")[0];
|
||||
dic_audioList[AudioType.FX].outputAudioMixerGroup = audioMixer.FindMatchingGroups("Master/FX")[0];
|
||||
}
|
||||
public AudioSource GetAudioSource(AudioType audioType)
|
||||
{
|
||||
if (dic_audioList.ContainsKey(audioType))
|
||||
{
|
||||
return dic_audioList[audioType];
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
public void ChangeBG(AudioClip audioClip)
|
||||
{
|
||||
AudioType audioType=AudioType.BG;
|
||||
if (dic_audioList.ContainsKey(audioType))
|
||||
{
|
||||
dic_audioList[audioType].clip = audioClip;
|
||||
dic_audioList[audioType].Play();
|
||||
|
||||
}
|
||||
}
|
||||
public void PlayFX(AudioClip audioClip)
|
||||
{
|
||||
AudioType audioType = AudioType.FX;
|
||||
if (dic_audioList.ContainsKey(audioType))
|
||||
{
|
||||
dic_audioList[audioType].PlayOneShot(audioClip);
|
||||
|
||||
}
|
||||
}
|
||||
public bool UpdateAudioClip(AudioType audioType,AudioClip audioClip)
|
||||
{
|
||||
if (dic_audioList.ContainsKey(audioType))
|
||||
{
|
||||
dic_audioList[audioType].clip=audioClip;
|
||||
dic_audioList[audioType].Play();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool PlayOneShot(AudioType audioType, AudioClip audioClip)
|
||||
{
|
||||
if (dic_audioList.ContainsKey(audioType))
|
||||
{
|
||||
dic_audioList[audioType].PlayOneShot(audioClip);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b6274f58a6279d48ad7b7045f1d80e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,7 +13,10 @@ public class SubUIManager
|
||||
private readonly Transform parent;
|
||||
private readonly Dictionary<UIPanel, SubUIBase> panels = new Dictionary<UIPanel, SubUIBase>();
|
||||
private readonly Dictionary<UIPanel, string> addressMap = new Dictionary<UIPanel, string>();
|
||||
|
||||
public T Get<T>(UIPanel type) where T : UIBase
|
||||
{
|
||||
return panels.TryGetValue(type, out var panel) ? panel as T : null;
|
||||
}
|
||||
public SubUIManager(Transform parent, UIPanelAddressConfig uIPanelAddressConfig)
|
||||
{
|
||||
this.parent = parent;
|
||||
|
||||
@@ -6,9 +6,12 @@ using Unity.VisualScripting.FullSerializer;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using System.Net;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
//ui面板枚举 这里要求分类 Main *00 *00-*99 整数为主界面尾数为子界面
|
||||
public enum UIPanel
|
||||
{
|
||||
None=9999,
|
||||
LoginPanel = 0,
|
||||
HomeMainPanel = 1,
|
||||
MainGamePanelDefault = 2,
|
||||
@@ -131,6 +134,42 @@ public class UIManager : MonoSingleton<UIManager>
|
||||
{
|
||||
return StartCoroutine(CoShow(type, args, onShown));
|
||||
}
|
||||
public GameObject BoardPanelParefab;
|
||||
public void ShowBoard(string str)
|
||||
{
|
||||
|
||||
StartCoroutine(IEShowBoard(str));
|
||||
|
||||
}
|
||||
IEnumerator IEShowBoard(string str)
|
||||
{
|
||||
var obj = Instantiate(BoardPanelParefab, uiRoot);
|
||||
obj.transform.SetAsLastSibling();
|
||||
obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = str;
|
||||
yield return new WaitForSeconds(1);
|
||||
float a = 1;
|
||||
Color c;
|
||||
TextMeshProUGUI t = obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
Image i = obj.GetComponent<Image>();
|
||||
while (true)
|
||||
{
|
||||
a-=Time.deltaTime;
|
||||
yield return null;
|
||||
c = i.color;
|
||||
c.a=a;
|
||||
i.color = c;
|
||||
|
||||
c = t.color;
|
||||
c.a = a;
|
||||
t.color = c;
|
||||
if (a<0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
Destroy(obj);
|
||||
|
||||
}
|
||||
private IEnumerator CoShow(UIPanel type, object args, Action<UIBase> onShown)
|
||||
{
|
||||
if (addressMap.ContainsKey(type))
|
||||
|
||||
Reference in New Issue
Block a user