2019-10-07 16:53:36 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class LevelEvent : UnityEvent<float>
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PdLevelBind : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private PdBackend pdbackend;
|
|
|
|
|
[SerializeField, Range(1, 16)] private int channel = 1;
|
2019-10-07 22:03:16 +00:00
|
|
|
|
[SerializeField] private LevelEvent levelChanged;
|
2019-11-22 17:38:28 +00:00
|
|
|
|
[SerializeField] bool logLevel;
|
2019-10-07 16:53:36 +00:00
|
|
|
|
private float level_;
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
var level = pdbackend.LevelArray.Data[channel - 1];
|
|
|
|
|
|
|
|
|
|
if (level_ != level)
|
|
|
|
|
{
|
|
|
|
|
level_ = level;
|
2019-10-07 22:03:16 +00:00
|
|
|
|
levelChanged.Invoke(level_);
|
2019-11-22 17:38:28 +00:00
|
|
|
|
|
|
|
|
|
if (logLevel)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Level:" + level_);
|
|
|
|
|
}
|
2019-10-07 16:53:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|