该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

36 行
1019 B

using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(SoundDef))]
public class SoundDefEditor : Editor
{
static AudioSource testSource = null;
public override void OnInspectorGUI()
{
if (testSource == null)
{
var go = new GameObject("testSource");
go.hideFlags = HideFlags.HideAndDontSave;
testSource = go.AddComponent<AudioSource>();
}
var sd = (SoundDef)target;
// Allow playing audio even when sounddef is readonly
var oldEnabled = GUI.enabled;
GUI.enabled = true;
if (testSource.isPlaying && GUILayout.Button("Stop []"))
{
testSource.Stop();
}
else if (!testSource.isPlaying && GUILayout.Button("Play >"))
{
SoundSystemBase.StartSource(testSource, sd);
}
GUI.enabled = oldEnabled;
DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" });
serializedObject.ApplyModifiedProperties();
}
}