AudioReverbPreset Expose Properties

Hello,

So I am trying to expose the properties of the AudioReverbPreset’s., such as General, Room, Etc., ideally i’d like to just reference those like so:

Code

public AudioReverbPreset initReverbPreset;

public ReverbProps initReverbProps;

    [System.Serializable]
    public class ReverbProps {
 
        [Range(-10000, 0)]
        public int room;
    
        [Range(-10000, 0)]
        public int roomHF;
    
        [Range(-10000, 0)]
        public int roomLF;
    
        [Range(0.1f, 20)]
        public float decayTime;
    
        [Range(0.1f, 2)]
        public float decayHFRatio;
    
        [Range(-10000, 1000)]
        public int reflections;
    
        [Range(0, 0.3f)]
        public float reflectionsDelay;
    
        [Range(-10000, 2000)]
        public int reverb;
    
        [Range(0, 0.1f)]
        public float reverbDelay;
    
        [Range(1000, 20000)]
        public float hfReference;
    
        [Range(20, 1000)]
        public float lfReference;
    
        [Range(0, 100)]
        public float diffusion;
    
        [Range(0, 100)]
        public float density;
    
    }//ReverbProps

initReverbProps.room = initReverbPreset.room;

initReverbProps.room = initReverbPreset.room;

But obviously that doesn’t work, storing the properties in a separate class to display them inside of a custom editor is my only work around so far but in order to do that i need to have an object with the reverb zone active in the game scene and update that specific component to retreive the proper values per reverb preset.

Instead of creating and destroying a gameobject/reverb component over and over again after every editor value update, it would be more ideal to simply grab the preset default values and refer to those.

The question is, how? There is no api that i can see that suggests you can do this.

The only thing i have found is here: Unity - Scripting API: AudioReverbZone.reverbPreset

Which suggest you can “Get reverb preset properties.” yet provides no api to do so.

Thoughts?

Alright so digging into this more, it seems the default preset values aren’t even stored in AudioReverbPresets or AudioReverbZone

https://github.com/jamesjlinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/AudioReverbPreset.cs

https://github.com/jamesjlinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/AudioReverbZone.cs

So where exactly are they stored at? :stuck_out_tongue:

Honestly if that solves your problem and it’s only an editor time thing, jeez, that’s nothing, just code it that way and get back to working on fun stuff. You can DestroyImmediate() and Instantiate() quite a lot of stuff at editor time without too much sweat.

Yea technically i could, just concerned about crashes due to too many destroys being called.

Unless there is a bug in Destroy, I don’t believe this is a thing.

You’d hope not :stuck_out_tongue: but better to be safe than sorry.

I’m sorry, you have lost me with this line of reasoning. This line of reasoning would naturally lead to “let’s just not call ANY functions because we might crash.”

Good luck!

Well it makes perfect sense if you are making a custom asset that you would sell for others to use :stuck_out_tongue:

It would be ideal that the custom asset should cause as little problems as possible and not introduce engine crashing instances, as the user could be doing anything, possible not have saved their scene in a while and then bam, engine crashes.

Thus the best approach would be to make a custom asset that performs well and does what’s needed, without an extra impact on the users opened instance of the engine/project.

So yes it makes perfect sense, however if it were a personal asset, i would still be concerned, lazy coding is not something i agree with :stuck_out_tongue: