soundvision/UnityProject/Assets/Editor/PdConsole.cs
Chikashi Miyama f29a1549c5 close #29
2019-09-28 20:29:31 +02:00

50 lines
1.3 KiB
C#

using UnityEditor;
namespace cylvester
{
public class PdConsole : EditorWindow
{
private IEditorToggle dspToggle_;
private ITogglePresenter togglePresenter_;
private IPdBackend pdBackend_;
[MenuItem("SoundVision/Pd console %#p")]
static void Init()
{
var window = (PdConsole)GetWindow(typeof(PdConsole));
window.Show();
}
private void OnEnable()
{
var foundObjects = FindObjectsOfType(typeof(PdBackend));
if (foundObjects.Length != 1)
return;
pdBackend_ = (IPdBackend) foundObjects[0];
dspToggle_ = new EditorToggle();
togglePresenter_ = new TogglePresenter(dspToggle_, pdBackend_);
}
private void OnGUI ()
{
if(!ValidatePdBackend(pdBackend_))
return;
dspToggle_.State = EditorGUILayout.Toggle("Pure Data Process", dspToggle_.State);
}
private bool ValidatePdBackend(IPdBackend pdBackend)
{
var exist = pdBackend_ != null;
if (!exist)
{
EditorGUILayout.LabelField("No Pd backend found in the scene");
}
return exist;
}
}
}