I rewrote the way CsoundUnity reads the csd, the idea is this: as you drag the file in the inspector, store a reference of the csd code as a string. Then recompile and reparse just when the file is changed on disk (I have a reference of the filepath and I can look with a FileWatcher when its hash changes).
On build the string should be saved by the editor.
So the problem about csd obfuscation is solved!
Also the channels should be saved, and maybe also their values.
And so also the channel values saving could be solved!
But for now I still have some problems, and no sound at all.
Now Csound starts like this:
//instead of this
//int ret = Csound6.NativeMethods.csoundCompile(csound, 4, runargs);
Csound6.NativeMethods.csoundSetOption(csound, $"--sample-rate={AudioSettings.outputSampleRate}");
Csound6.NativeMethods.csoundSetOption(csound, "--ksmps=32");
Csound6.NativeMethods.csoundSetOption(csound, "-n");
Csound6.NativeMethods.csoundStart(csound);
// csdFile now holds the csd code
int ret = Csound6.NativeMethods.csoundCompileCsdText(csound, csdFile);
compiledOk = ret == 0 ? true : false;
Iām not sure how to set the sample-rate and ksmps, I have lots of warnings. But it compiles, so I think I am on the right track!