//-------------------------------------------------------------------------- /// This function updates our static pipePrintToConsole variable when the /// public one changes, and ensures all other active LibPdInstances are /// updated too. private void OnValidate() { if (pipePrintToConsoleStatic != pipePrintToConsole) { pipePrintToConsoleStatic = pipePrintToConsole; LibPdInstance[] activePatches = FindObjectsOfType <LibPdInstance>(); for (int i = 0; i < activePatches.Length; ++i) { activePatches[i].pipePrintToConsole = pipePrintToConsoleStatic; } } #if UNITY_EDITOR string lastName = patchName; //We use this to store the name of our PD patch as a string, as we need //to feed the filename and directory into libpd. if (patch != null) { patchName = patch.name; } if ((lastName != patchName) || ((patch != null) && (patchDir == null)) || ((patch != null) && (patchDir != null) && (patchDir.IndexOf("StreamingAssets") != -1))) //This is unfortunately necessary to upgrade the serialised data saved from versions of LibPdIntegration < v2.0.1. { patchDir = AssetDatabase.GetAssetPath(patch.GetInstanceID()); //Strip out "Assets/StreamingAssets", as the files won't be in the //Assets folder in a built version, only when running in the editor. patchDir = patchDir.Substring(patchDir.IndexOf("Assets/StreamingAssets") + 22); //Remove the name of the patch, as we only need the directory. patchDir = patchDir.Substring(0, patchDir.LastIndexOf('/') + 1); } #endif }
//-------------------------------------------------------------------------- /// This function updates our static pipePrintToConsole variable when the /// public one changes, and ensures all other active LibPdInstances are /// updated too. private void OnValidate() { if (pipePrintToConsoleStatic != pipePrintToConsole) { pipePrintToConsoleStatic = pipePrintToConsole; LibPdInstance[] activePatches = FindObjectsOfType <LibPdInstance>(); for (int i = 0; i < activePatches.Length; ++i) { activePatches[i].pipePrintToConsole = pipePrintToConsoleStatic; } } #if UNITY_EDITOR string lastName = patchName; //We use this to store the name of our PD patch as a string, as we need //to feed the filename and directory into libpd. if (patch != null) { patchName = patch.name; } if (lastName != patchName) { patchDir = AssetDatabase.GetAssetPath(patch.GetInstanceID()); //Strip out "Assets", as the files won't be in the Assets folder in //a built version, only when running in the editor. patchDir = patchDir.Substring(patchDir.IndexOf("Assets") + 6); //Remove the name of the patch, as we only need the directory. patchDir = patchDir.Substring(0, patchDir.LastIndexOf('/') + 1); } #endif }