This commit is contained in:
Chikashi Miyama 2019-09-28 20:29:31 +02:00
parent 78023946cd
commit f29a1549c5
2 changed files with 23 additions and 10 deletions

View file

@ -1,5 +1,4 @@
using UnityEditor; using UnityEditor;
using UnityEngine;
namespace cylvester namespace cylvester
{ {
@ -18,19 +17,34 @@ namespace cylvester
private void OnEnable() private void OnEnable()
{ {
object[] foundObjects = FindObjectsOfType(typeof(PdBackend)); var foundObjects = FindObjectsOfType(typeof(PdBackend));
if (foundObjects.Length != 1)
return;
pdBackend_ = (IPdBackend) foundObjects[0];
dspToggle_ = new EditorToggle(); dspToggle_ = new EditorToggle();
togglePresenter_ = new TogglePresenter(dspToggle_, pdBackend_);
togglePresenter_ = new TogglePresenter(dspToggle_, pdBackend_);
} }
void OnGUI () private void OnGUI ()
{ {
foundObjects. if(!ValidatePdBackend(pdBackend_))
return;
dspToggle_.State = EditorGUILayout.Toggle("Pure Data Process", dspToggle_.State); 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;
}
} }
} }

View file

@ -20,8 +20,7 @@ namespace cylvester
onToggleChanged_ = () => onToggleChanged_ = () =>
{ {
var state = editorToggle_.State; pdBackend.State = editorToggle_.State;
// apply state to pd backend;
}; };
editorToggle_.ToggleStateChanged += onToggleChanged_; editorToggle_.ToggleStateChanged += onToggleChanged_;