add state message pass from unity to pd
This commit is contained in:
parent
6db4dac502
commit
964ab7f2ee
12 changed files with 163 additions and 37 deletions
|
@ -62,6 +62,7 @@
|
||||||
<Compile Include="Assets\Editor\PdSpectrumBindEditor.cs" />
|
<Compile Include="Assets\Editor\PdSpectrumBindEditor.cs" />
|
||||||
<Compile Include="Assets\Editor\RectangularSelection.cs" />
|
<Compile Include="Assets\Editor\RectangularSelection.cs" />
|
||||||
<Compile Include="Assets\Editor\SpectrumGeneratorEditMode.cs" />
|
<Compile Include="Assets\Editor\SpectrumGeneratorEditMode.cs" />
|
||||||
|
<Compile Include="Assets\Editor\StateManagerEditor.cs" />
|
||||||
<Compile Include="Assets\Editor\UnitTest\UnitTest_ChangeObserver.cs" />
|
<Compile Include="Assets\Editor\UnitTest\UnitTest_ChangeObserver.cs" />
|
||||||
<Compile Include="Assets\Editor\UnitTest\UnitTest_RectangularSelection.cs" />
|
<Compile Include="Assets\Editor\UnitTest\UnitTest_RectangularSelection.cs" />
|
||||||
<Compile Include="Assets\Editor\UnitTest\UnitTest_SpectrumGeneratorEditMode.cs" />
|
<Compile Include="Assets\Editor\UnitTest\UnitTest_SpectrumGeneratorEditMode.cs" />
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
<Compile Include="Assets\Scenes\Examples\MIDI\script\PositionBind.cs" />
|
<Compile Include="Assets\Scenes\Examples\MIDI\script\PositionBind.cs" />
|
||||||
<Compile Include="Assets\Scenes\Examples\PdBackend\script\BoomBall.cs" />
|
<Compile Include="Assets\Scenes\Examples\PdBackend\script\BoomBall.cs" />
|
||||||
<Compile Include="Assets\Scenes\Examples\PostProcessing\script\BokehBind.cs" />
|
<Compile Include="Assets\Scenes\Examples\PostProcessing\script\BokehBind.cs" />
|
||||||
<Compile Include="Assets\Scenes\Examples\TextToPd\script\TextToPd.cs" />
|
|
||||||
<Compile Include="Assets\Scenes\Examples\Texture\TextureMapper.cs" />
|
<Compile Include="Assets\Scenes\Examples\Texture\TextureMapper.cs" />
|
||||||
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\FlareBind.cs" />
|
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\FlareBind.cs" />
|
||||||
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\SmokeBind.cs" />
|
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\SmokeBind.cs" />
|
||||||
|
@ -90,6 +89,7 @@
|
||||||
<Compile Include="Assets\Scripts\PdConnection\Spectrogram.cs" />
|
<Compile Include="Assets\Scripts\PdConnection\Spectrogram.cs" />
|
||||||
<Compile Include="Assets\Scripts\PdConnection\SpectrumGeneratorPlayMode.cs" />
|
<Compile Include="Assets\Scripts\PdConnection\SpectrumGeneratorPlayMode.cs" />
|
||||||
<Compile Include="Assets\Scripts\PdConnection\Waveform.cs" />
|
<Compile Include="Assets\Scripts\PdConnection\Waveform.cs" />
|
||||||
|
<Compile Include="Assets\Scripts\StateManagement\StateManager.cs" />
|
||||||
<Compile Include="Assets\Scripts\TemplateLibrary\ChangeObserver.cs" />
|
<Compile Include="Assets\Scripts\TemplateLibrary\ChangeObserver.cs" />
|
||||||
<Compile Include="Assets\Scripts\Versioning\VersionToggleBehaviour.cs" />
|
<Compile Include="Assets\Scripts\Versioning\VersionToggleBehaviour.cs" />
|
||||||
<Compile Include="Assets\Scripts\VideoInput\ComponentFactory.cs" />
|
<Compile Include="Assets\Scripts\VideoInput\ComponentFactory.cs" />
|
||||||
|
|
34
UnityProject/Assets/Editor/StateManagerEditor.cs
Normal file
34
UnityProject/Assets/Editor/StateManagerEditor.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace cylvester
|
||||||
|
{
|
||||||
|
|
||||||
|
[CustomEditor(typeof(StateManager))]
|
||||||
|
public class StateManagerEditor : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI ()
|
||||||
|
{
|
||||||
|
var csvFileName = serializedObject.FindProperty("csvFileName");
|
||||||
|
var onStateChanged = serializedObject.FindProperty("onStateChanged");
|
||||||
|
var sceneSelection = serializedObject.FindProperty("sceneSelection");
|
||||||
|
|
||||||
|
serializedObject.Update();
|
||||||
|
EditorGUILayout.PropertyField(csvFileName);
|
||||||
|
EditorGUILayout.PropertyField(onStateChanged);
|
||||||
|
if (Application.isPlaying)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.LabelField("Current State");
|
||||||
|
var newValue = EditorGUILayout.Popup(sceneSelection.intValue, ((IStateManager) target).StateTitles);
|
||||||
|
if (newValue != sceneSelection.intValue)
|
||||||
|
((IStateManager) target).State = newValue;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
3
UnityProject/Assets/Editor/StateManagerEditor.cs.meta
Normal file
3
UnityProject/Assets/Editor/StateManagerEditor.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8eaff1249cf94769bca9c4e2b8bdaad4
|
||||||
|
timeCreated: 1572206629
|
|
@ -507,7 +507,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1788337934}
|
- component: {fileID: 1788337934}
|
||||||
- component: {fileID: 1788337933}
|
- component: {fileID: 1788337933}
|
||||||
- component: {fileID: 1788337935}
|
- component: {fileID: 1788337936}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: PdBackend
|
m_Name: PdBackend
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -548,7 +548,7 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1788337935
|
--- !u!114 &1788337936
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
@ -557,7 +557,22 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 1788337932}
|
m_GameObject: {fileID: 1788337932}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: af763e011f6b2f04eaa8391f28e21b56, type: 3}
|
m_Script: {fileID: 11500000, guid: e6be1ae37d9581545a6d213046b19b8c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
pdBackend: {fileID: 1788337933}
|
csvFileName: qlist
|
||||||
|
onStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 1788337933}
|
||||||
|
m_MethodName: Message
|
||||||
|
m_Mode: 0
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
|
sceneSelection: 0
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
using cylvester;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class TextToPd : MonoBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField] private PdBackend pdBackend;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
pdBackend.Message("Hello world\n");
|
|
||||||
}
|
|
||||||
}
|
|
8
UnityProject/Assets/Scripts/StateManagement.meta
Normal file
8
UnityProject/Assets/Scripts/StateManagement.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cbd13b741aa49d847926f84123719d95
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
64
UnityProject/Assets/Scripts/StateManagement/StateManager.cs
Normal file
64
UnityProject/Assets/Scripts/StateManagement/StateManager.cs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
|
||||||
|
namespace cylvester
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class UnityStateEvent : UnityEvent<string>
|
||||||
|
{}
|
||||||
|
|
||||||
|
public interface IStateManager
|
||||||
|
{
|
||||||
|
int State { set; }
|
||||||
|
string[] StateTitles { get; }
|
||||||
|
void Next();
|
||||||
|
void Rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StateManager : MonoBehaviour, IStateManager
|
||||||
|
{
|
||||||
|
[SerializeField] private string csvFileName = "qlist";
|
||||||
|
[SerializeField] private UnityStateEvent onStateChanged;
|
||||||
|
[SerializeField] private int sceneSelection;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
var content = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/" + csvFileName + ".csv");
|
||||||
|
var lines = content.Split("\n"[0]);
|
||||||
|
StateTitles = new string[lines.Length - 1];
|
||||||
|
for (var i = 1; i < lines.Length; ++i)
|
||||||
|
{
|
||||||
|
var columns = (lines[i].Trim()).Split(","[0]);
|
||||||
|
StateTitles[i-1] = columns[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string[] StateTitles { get; private set; }
|
||||||
|
|
||||||
|
public int State
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
sceneSelection = value;
|
||||||
|
onStateChanged.Invoke(StateTitles[sceneSelection]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Next()
|
||||||
|
{
|
||||||
|
if (sceneSelection >= StateTitles.Length - 1) return;
|
||||||
|
sceneSelection++;
|
||||||
|
onStateChanged.Invoke(StateTitles[sceneSelection]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Rewind()
|
||||||
|
{
|
||||||
|
if (sceneSelection == 0) return;
|
||||||
|
sceneSelection = 0;
|
||||||
|
onStateChanged.Invoke(StateTitles[sceneSelection]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: af763e011f6b2f04eaa8391f28e21b56
|
guid: e6be1ae37d9581545a6d213046b19b8c
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,4 +1,4 @@
|
||||||
#N canvas 758 125 1031 487 10;
|
#N canvas -44 328 1031 487 10;
|
||||||
#X obj 142 343 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
|
#X obj 142 343 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
|
||||||
#X obj 72 384 dac~, f 6;
|
#X obj 72 384 dac~, f 6;
|
||||||
#N canvas 215 619 730 390 analyzers_______________________________
|
#N canvas 215 619 730 390 analyzers_______________________________
|
||||||
|
@ -194,26 +194,30 @@
|
||||||
0.000244498 0.000150442 9.39965e-005 3.75807e-005 1.87755e-005;
|
0.000244498 0.000150442 9.39965e-005 3.75807e-005 1.87755e-005;
|
||||||
#X coords 0 1 1023 0 300 100 1 0 0;
|
#X coords 0 1 1023 0 300 100 1 0 0;
|
||||||
#X restore 39 32 graph;
|
#X restore 39 32 graph;
|
||||||
#X restore 550 21 pd window;
|
#X restore 412 18 pd window;
|
||||||
#N canvas 561 588 332 292 commands_from_unity 1;
|
#N canvas 333 794 332 292 commands_from_unity 1;
|
||||||
#X obj 66 31 inlet;
|
#X obj 66 31 inlet;
|
||||||
#X obj 155 197 s sample_playback;
|
#X obj 162 248 s sample_playback;
|
||||||
#X text 150 55 1 ... sample playback;
|
#X text 150 55 1 ... sample playback;
|
||||||
#X text 149 38 0 ... dsp start/stop;
|
#X text 149 38 0 ... dsp start/stop;
|
||||||
#X msg 25 198 \; pd dsp \$1;
|
#X msg 25 198 \; pd dsp \$1;
|
||||||
#X obj 108 195 sel 1;
|
#X obj 108 195 sel 1;
|
||||||
#X obj 111 234 outlet;
|
#X obj 111 234 outlet;
|
||||||
#X text 150 69 2 ... text message;
|
#X text 150 69 2 ... text message;
|
||||||
#X obj 171 149 print;
|
|
||||||
#X obj 27 141 t f;
|
#X obj 27 141 t f;
|
||||||
#X obj 70 94 route processing sample message;
|
#X obj 70 94 route processing sample message;
|
||||||
#X connect 0 0 10 0;
|
#X obj 196 211 s state;
|
||||||
|
#X obj 180 137 list prepend label;
|
||||||
|
#X obj 200 179 list trim;
|
||||||
|
#X connect 0 0 9 0;
|
||||||
#X connect 5 0 6 0;
|
#X connect 5 0 6 0;
|
||||||
#X connect 9 0 4 0;
|
#X connect 8 0 4 0;
|
||||||
#X connect 10 0 5 0;
|
#X connect 9 0 5 0;
|
||||||
#X connect 10 0 9 0;
|
#X connect 9 0 8 0;
|
||||||
#X connect 10 1 1 0;
|
#X connect 9 1 1 0;
|
||||||
#X connect 10 2 8 0;
|
#X connect 9 2 11 0;
|
||||||
|
#X connect 11 0 12 0;
|
||||||
|
#X connect 12 0 10 0;
|
||||||
#X restore 248 58 pd commands_from_unity;
|
#X restore 248 58 pd commands_from_unity;
|
||||||
#N canvas 667 603 480 371 sample_playback 0;
|
#N canvas 667 603 480 371 sample_playback 0;
|
||||||
#X obj 86 166 readsf~;
|
#X obj 86 166 readsf~;
|
||||||
|
@ -251,19 +255,21 @@ Roses_Front.wav;
|
||||||
#X obj 103 197 list prepend send;
|
#X obj 103 197 list prepend send;
|
||||||
#X obj 103 221 list trim;
|
#X obj 103 221 list trim;
|
||||||
#X obj 103 173 midiin;
|
#X obj 103 173 midiin;
|
||||||
#X msg 427 113 23 31;
|
#X msg 423 145 23 31;
|
||||||
#X msg 474 113 80 84, f 10;
|
#X msg 470 145 80 84, f 10;
|
||||||
#X text 439 87 sample CC;
|
#X text 435 119 sample CC;
|
||||||
#X msg 441 159 send 176 \$1 \$2;
|
#X msg 437 191 send 176 \$1 \$2;
|
||||||
#X text 440 181 176... control channel 1;
|
#X text 436 213 176... control channel 1;
|
||||||
#N canvas 695 332 450 300 level 0;
|
#N canvas 695 332 450 300 level 0;
|
||||||
#X obj 90 182 table level 16;
|
#X obj 90 182 table level 16;
|
||||||
#X obj 89 152 shmem level 16;
|
#X obj 89 152 shmem level 16;
|
||||||
#X obj 89 127 r shmemupdate;
|
#X obj 89 127 r shmemupdate;
|
||||||
#X connect 2 0 1 0;
|
#X connect 2 0 1 0;
|
||||||
#X restore 549 53 pd level;
|
#X restore 411 50 pd level;
|
||||||
#X obj 12 173 midirealtimein;
|
#X obj 12 173 midirealtimein;
|
||||||
#X obj 248 20 netreceive -u 54345;
|
#X obj 248 20 netreceive -u 54345;
|
||||||
|
#X obj 519 348 cnv 15 100 60 empty state Dark 20 12 0 45 -262144 -66577
|
||||||
|
0;
|
||||||
#X connect 0 0 2 0;
|
#X connect 0 0 2 0;
|
||||||
#X connect 0 1 2 1;
|
#X connect 0 1 2 1;
|
||||||
#X connect 0 2 2 2;
|
#X connect 0 2 2 2;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Scene Title,Notes
|
Scene Title,Notes
|
||||||
Intro,cool intro
|
Intro,cool intro
|
||||||
Dark Soul,we should start with something dark
|
Dark_Soul,we should start with something dark
|
||||||
Biohazard,many people are eaten by the zombies
|
Biohazard,many people are eaten by the zombies
|
||||||
Silent Hill,and zombies become fat
|
Silent_Hill,and zombies become fat
|
||||||
Outro,zombies starts work out
|
Outro,zombies starts work out
|
|
7
UnityProject/Assets/StreamingAssets/qlist.csv.meta
Normal file
7
UnityProject/Assets/StreamingAssets/qlist.csv.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 935a0bdc80383094aab30c895b25cf89
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in a new issue