gongyejiqiren/Assets/_Scripts/Application/UI/ShowToastUIPrefab.cs

38 lines
1.3 KiB
C#

using CG.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/*******************************************************************************
*Create By CG
*Function
*******************************************************************************/
namespace ZXK.GYJQR
{
public class ShowToastUIPrefab : UIBase
{
private AudioEffectCtrl _audioClipCtrl = null;
protected override void Awake()
{
base.Awake();
if (!transform.TryGetComponent( out _audioClipCtrl))
{
_audioClipCtrl = gameObject.AddComponent<AudioEffectCtrl>();
}
}
public void SetTextAudMsg(string content,string audName)
{
transform.Find("TxtBG/Text").GetComponent<Text>().text = content;
string audioPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Audios", GameManager.Instance._CurSystemType.ToString() + "Tips", audName + ".mp3");
CG.UTility.UtilitiesMng.LoadAudio(audioPath, (AudioClip clip) =>
{
if (clip)
{
GetComponent<AudioSource>().clip = clip;
GetComponent<AudioSource>().Play();
}
});
}
}
}