2019-09-28 18:17:39 +00:00
|
|
|
|
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()
|
2019-09-28 18:29:31 +00:00
|
|
|
|
{
|
|
|
|
|
var foundObjects = FindObjectsOfType(typeof(PdBackend));
|
|
|
|
|
if (foundObjects.Length != 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pdBackend_ = (IPdBackend) foundObjects[0];
|
2019-09-28 18:17:39 +00:00
|
|
|
|
dspToggle_ = new EditorToggle();
|
2019-09-28 18:29:31 +00:00
|
|
|
|
|
|
|
|
|
togglePresenter_ = new TogglePresenter(dspToggle_, pdBackend_);
|
2019-09-28 18:17:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 18:29:31 +00:00
|
|
|
|
private void OnGUI ()
|
2019-09-28 18:17:39 +00:00
|
|
|
|
{
|
2019-09-28 18:29:31 +00:00
|
|
|
|
if(!ValidatePdBackend(pdBackend_))
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-28 18:17:39 +00:00
|
|
|
|
dspToggle_.State = EditorGUILayout.Toggle("Pure Data Process", dspToggle_.State);
|
|
|
|
|
|
|
|
|
|
}
|
2019-09-28 18:29:31 +00:00
|
|
|
|
|
|
|
|
|
private bool ValidatePdBackend(IPdBackend pdBackend)
|
|
|
|
|
{
|
|
|
|
|
var exist = pdBackend_ != null;
|
|
|
|
|
if (!exist)
|
|
|
|
|
{
|
|
|
|
|
EditorGUILayout.LabelField("No Pd backend found in the scene");
|
|
|
|
|
}
|
|
|
|
|
return exist;
|
|
|
|
|
}
|
2019-09-28 18:17:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|