soundvision/UnityProject/Assets/Scripts/PdConnection/PdBackend.cs

45 lines
941 B
C#
Raw Normal View History

2019-09-28 18:17:39 +00:00
using System;
using System.Threading;
2019-09-28 18:17:39 +00:00
using UnityEngine;
namespace cylvester
{
public interface IPdBackend
{
bool State { set; get; }
event Action StateChanged;
2019-09-28 18:17:39 +00:00
}
[ExecuteInEditMode]
public class PdBackend : MonoBehaviour, IPdBackend
{
[SerializeField] string mainPatch;
[SerializeField] int inchannels = 2;
private Action onToggled_;
private void OnEnable()
{
PdProcess.Instance.Start(mainPatch, inchannels);
Thread.Sleep(500);
2019-09-28 18:17:39 +00:00
}
private void OnDisable()
{
PdProcess.Instance.Stop();
}
public bool State
{
set
{
enabled = value;
if(StateChanged != null)
StateChanged.Invoke();
}
get => enabled;
2019-09-28 18:17:39 +00:00
}
public event Action StateChanged;
2019-09-28 18:17:39 +00:00
}
}