diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 9d49f97..4598d31 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -76,6 +76,7 @@ + C:/Users/Niall Moody/Programming/Unity/LibPdIntegrationExamples/Library/ScriptAssemblies/UnityEngine.Purchasing.dll diff --git a/Assets/05-Readme LibPd2UnityScene.txt b/Assets/05-Readme LibPd2UnityScene.txt new file mode 100644 index 0000000..90c3b0e --- /dev/null +++ b/Assets/05-Readme LibPd2UnityScene.txt @@ -0,0 +1,51 @@ +Unity2LibPdScene Notes +---------------------- +This scene demonstrates how to communicate from libpd to Unity. + +In our PD patch this is relatively simple: we just create a send object to send +data to Unity. + + +On the Unity end, however, things are a bit more complicated. The required steps +are: + +1.) Bind() to the desired send object. libpd will not make send signals + available to Unity by default. We need to tell it we are interested in + specific signals. We do this using the Bind() function in LibPdInstance, + e.g. pdPatch.Bind("BangTest"); (if BangTest is the name of our send object). + +2.) Write a function that will be called whenever that send object sends a + signal to us. The signature of that function will have to match the + signature LibPdInstance is expecting. For instance, a function that reacts + to bang signals would look like this: + + public void BangReceive(string name) + + And a function that reacts to float (or number) signals would look like + this: + + public void FloatReceive(string name, float value) + + Where name is the name of the send object, and value is the float value that + was sent from your PD patch. + + You can see a full list of function signatures on the wiki: + https://github.com/LibPdIntegration/LibPdIntegration/wiki/libpd2unity#unityevents + +3.) Connect your LibPdInstance Component to the above function. LibPdInstance + uses Unity events for this. If you expand the Pure Data Events header you + will see a list of 5 UnityEvent widgets, one for each of the signal types + which can be sent from your PD patch. + + To connect to your function, you need to click the + button for your + desired signal type, then drag the GameObject containing your receive + script into the 'None (object)' box. + + Then, if you click the drop-down that says 'No Function', you will get a + list of possible destinations. Select your receiving script/Component, and + then, under the Dynamic header, select the receive function you created in + the previous step. + + Note: You will see 2 copies of your function in that final menu: one under + 'Dynamic', one under 'Static'. It is important that you select the entry + under 'Dynamic'; the one under 'Static' will not work for our purposes. diff --git a/Assets/05-Readme LibPd2UnityScene.txt.meta b/Assets/05-Readme LibPd2UnityScene.txt.meta new file mode 100644 index 0000000..360769f --- /dev/null +++ b/Assets/05-Readme LibPd2UnityScene.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1d793fff838094a4692ae7004fd58b38 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/LibPd2UnityScene.unity b/Assets/Scenes/LibPd2UnityScene.unity index 8d95d50..4c5bce4 100644 --- a/Assets/Scenes/LibPd2UnityScene.unity +++ b/Assets/Scenes/LibPd2UnityScene.unity @@ -328,7 +328,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 14496bc842cc2dd40b3da723e07b976d, type: 3} m_Name: m_EditorClassIdentifier: - patchName: FloatExample + patchName: SineEnvelope patchDir: /PdAssets/LibPd2UnityPatches/ patch: {fileID: 102900000, guid: 9ab0089af2eeb0c419b1315779d38b33, type: 3} pipePrintToConsole: 1