48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using CG.Framework;
|
||
|
|
using CG.UTility;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
/*******************************************************************************
|
||
|
|
*Create By CG
|
||
|
|
*Function
|
||
|
|
*******************************************************************************/
|
||
|
|
namespace ZXK.GYJQR
|
||
|
|
{
|
||
|
|
public class ShowTitleUIPrefab : 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)
|
||
|
|
{
|
||
|
|
Text textTemp = transform.Find("TxtBG/Text").GetComponent<Text>();
|
||
|
|
if (UtilitiesMng.GetTransCharNum(content) > 68)
|
||
|
|
{
|
||
|
|
textTemp.alignment = TextAnchor.MiddleLeft;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
textTemp.alignment = TextAnchor.MiddleCenter;
|
||
|
|
}
|
||
|
|
textTemp.text = content;
|
||
|
|
if (string.IsNullOrEmpty(audName)) return;
|
||
|
|
string audioPath = Application.streamingAssetsPath + "/Audios/NiuTips/" + audName + ".mp3";
|
||
|
|
CG.UTility.UtilitiesMng.LoadAudio(audioPath, (AudioClip clip) =>
|
||
|
|
{
|
||
|
|
if (clip)
|
||
|
|
{
|
||
|
|
GetComponent<AudioSource>().clip = clip;
|
||
|
|
GetComponent<AudioSource>().Play();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|