Open diemildefreude opened 7 years ago
You can try adding this line of code to any of your scripts.
HeavyScript.SetFloatParameter(Hv_XXXX_AudioLib.Parameter.YY, value);
(Heavy Scipt is a variable with HV_XXX script assigned)
Hi @atahoualpi , thanks for your reply. I see, so doing it that way makes sure the value is clamped within the correct min and max value. Otherwise, you can just as well use
GetComponent<Hv_XXXX_AudioLib>().YY = value;
I guess this would be slower, though, because you're not changing the Parameter directly, but are sending a are going through the Unity editor's displayed value. Is that correct?
Hi @diemildefreude , both ways make sure the value is clamped. I don't really know how Heavy sets the parameters since I'm just a user, so I cannot say which of the two ways is faster
Right, I just assume everyone who posts here knows more than I. Thanks, @atahoualpi
Hey @diemildefreude are you sure you're not getting confused by Unity's inspector behaviour?
You can change the default value for a gameobject's property. Just make sure you're not in play mode otherwise unity will revert it back to the value before pressing play.
You shouldn't have to call SetFloatParameter
if you just want to change the starting value. That interface is for setting the value via a script.
Maybe the issue is that you can't hear the change in the parameter until you press play. But this is a pretty typical Unity experience... :)
One thing I should really look into is processing the plugin entirely within the editor, so you basically don't have to press play to hear it. Although I don't think I'll get a chance anytime soon.
@diplojocus Yeah, it's working fine now, so I must have been doing something dumb like that... I do need to set the parameters via script anyway since I'll be adding HV components during runtime and setting their parameters then (as seen here: https://github.com/enzienaudio/heavy/issues/194). Is there a difference between using the SetFloat method and setting the value directly (i.e. GetComponent
Hmm actually just looking over the code I think the public float variables for parameters are legacy, and actually aren't even used anymore. I'll have to do some testing but I think I can remove them now.
SetFloatParameter
is definitely the only way to update parameters inside your patch.
Hi @diplojocus
It would seem I'm still having the same problem as before. I'm definitely not in PlayMode when I change the Hv_ parameters in the editor, but when I press play, they revert to the 'c' in [r XX @hv_param a b c].
It's possible that the reason I thought that it WAS working (when I wrote my previous comment) is that I tried changing the parameters to values that I was using another script to assign anyway. When I try it with parameters that I'm not using another script to change, I still have this problem.
Can you try recording a video/gif of that behaviour? I've not seen that before.
Hey @diplojocus , I've finally made a video of the problem: https://youtu.be/uhNSmQH4qHo
Also, regarding the three non-Heavy scripts that I disabled: they have almost nothing in their Awake() functions - definitely nothing that should be affecting the demonstrated value changes.
@diplojocus It seems that if I click on "apply" after changing a parameter, the value will remain thus when I enter play mode. This would mean that you can't change the values of prefab instances individually except via scripting. Is this expected behavior?
Hmm good point, it could be that the editor scripts are not playing nice with prefabs. Can you double check that if you add the script manually to a gameobject (i.e. not from a prefab) that you can save the parameter changes correctly?
Yes, @diplojocus, it the parameter value does NOT revert upon entering Play Mode, if the game object is not a prefab. It's a prefab-specific problem. I just didn't notice this before because I was only using prefabs.
After exposing parameters via @hv_param receive messages and setting the min, max and default values, they appear in the Unity editor with the default value. However, if you change the value in the editor before pressing play, it reverts to the default value at play. You can change it after play is pressed, but for experimenting with different starting values for parameters (or use different values for different instances of the plugin), there must surely be some way to change the default value without having to re-upload the patch. I didn't see anything about this in the documentation, though. I imagine you can do this via a script that changes the value at runtime. Is this the only way?