您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
42 行
913 B
42 行
913 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
|
|
[System.Serializable]
|
|
public class WeakSoundDef : Weak<SoundDef>
|
|
{
|
|
public bool IsValid() { return guid != ""; }
|
|
}
|
|
|
|
[CreateAssetMenu(fileName = "Sound", menuName = "SampleGame/Audio/SoundBank", order = 10000)]
|
|
public class SoundBank : ScriptableObject
|
|
{
|
|
public List<SoundDef> soundDefs;
|
|
|
|
public List<string> soundDefGuids;
|
|
|
|
public SoundDef FindByName(string name)
|
|
{
|
|
foreach(var s in soundDefs)
|
|
{
|
|
if (s.name == name)
|
|
return s;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
void OnValidate()
|
|
{
|
|
soundDefGuids.Clear();
|
|
foreach(var s in soundDefs)
|
|
{
|
|
var p = AssetDatabase.GetAssetPath(s);
|
|
soundDefGuids.Add(AssetDatabase.AssetPathToGUID(p));
|
|
}
|
|
}
|
|
#endif
|
|
}
|