Recently I found that you can create prefabs in Unity, that save all the settings on a Unity component and later you can load those presets using a script call.
I tried it with csoundUnity, and even though it loads the sliders values based on the preset, it doesn’t update the sound. after loading the preset all the sliders moved but the sound played the same. If I move a slider with the mouse it will update, but only that slider.
To try recreating this issue, move some sliders in csoundUnity, then click on the little slider icon on the top of the component to save the changes as a preset. To call the preset from a script I used :
I can confirm this behaviour, the channels are not updated after loading a preset at runtime.
It should work if you load the preset before pressing play.
I’ll have a look in the next days to see if I find an easy fix that doesn’t require complex scripting on the user side.
Also please note that Unity presets are not meant to be used at runtime (they will work in PlayMode on editor for default types but once you build you won’t be able to call ApplyTo), have a look at this thread: https://forum.unity.com/threads/presets-feature.491263/page-2#post-3552503
That’s super interesting.
Now I understand why it worked perfectly on transform, but not on a more complex system.
Im trying to find a method to saving “preset” (like you would do in a DAW) but in Unity, basically a setup for a synth with specific values, but be able to change the preset based on the object that is generating the sound.
Lets say I tweaked a synth to a sound I really like, and I want to save those settings and use it in Unity, but in the scene I have multiple objects, each one with a different sound generated by the same synth. I want to be able to load presets onto a synth based on the object I interact with. Maybe the solution would be multiple instruments, but I feel like there is a way to optimize something like that.
I have already made some prototype some months ago, I will add a specific “CsoundUnityPreset” class that can be serialized and saved as json in the persistent folder, or as asset in the editor, and loaded also at runtime.
I will notify you as soon as I have something to test, so that we can discuss about it
Btw it is just a matter of getting the serialized CsoundUnity.channels, save them in the preset, and restoring them when desired.
We could also think about a more complex system that allows for hyper vectorial synthesis, morphing between 2 or more presets (ie snapshots): Hyper Vectorial Synthesis
Hi @Sh_dev, I can confirm there was an issue when setting comboboxes at runtime, I just pushed an hotfix to both master and the preset branches.
I will push an updated preset sample probably today.
Thanks for your tests!