How make a script that will print the different parameters AND its variables

I arrived at a point where I can print all parameters present in my Fmod project using
var allParams = studio.project.model.ParameterPreset.findInstances(); and using a forloop.
I was wondering if there is a way to get the parameters values out of that. I can’t figure a way to do it
I am not a real coder so that might be why.
This would be specially useful for all enum type of parameters

I basically want to add all of those in the .cs file that is executed with “exportGUIDsHeader” and have all of those parameters here as public enums.

Hi,

Are you looking for the Initial Value of the parameter or its current value?
image

Hey sorry for the late reply I didnt see the notification.
No I was looking for all available values of a parameters (this is specifically related to labelled parameters).
I actually ended up creating an event that contains a reference to every single parameter my Fmod uses, and access this within unity to print out all parameters ID as well getting there available values if they were labelled parameters to create a script with enums I could use in CS in Unity. (I’m not sure this last part makes sense - but essentially a way to have access to the different values direclty in Unity)

1 Like

Hi,

Thank you for sharing your solution.

In case this is usefull to someone is tha far far future here is my script:
(you would then need export it to a file or something like that)
Disclaimer: probably not the best way to do it but it works for me at least:

    public void PrintParametersCustomClass()
    {
        string parameterDeclaration = "";
        string enumDeclaration = "";
        string fullText = "";
        FMOD.Studio.EventInstance eInstance = FMODUnity.RuntimeManager.CreateInstance(Util_allParam); //Util_allParam contains all parameters of my Fmod Project
        FMOD.Studio.EventDescription eDescription;
        eInstance.getDescription(out eDescription);
        eDescription.getParameterDescriptionCount(out int count);


        for (int i = 0; i <= count; i++)
        {
            FMOD.Studio.PARAMETER_DESCRIPTION pDescription;
            eDescription.getParameterDescriptionByIndex(i, out pDescription);

            string name = pDescription.name;
            if (pDescription.guid.Data1 == 0 && pDescription.guid.Data2 == 0 && pDescription.guid.Data3 == 0 && pDescription.guid.Data4 == 0)
                break;
            int guidData1 = pDescription.guid.Data1;
            int guidData2 = pDescription.guid.Data2;
            int guidData3 = pDescription.guid.Data3;
            int guidData4 = pDescription.guid.Data4;
            uint idData1 = pDescription.id.data1;
            uint idData2 = pDescription.id.data2;
            float min = pDescription.minimum;
            float max = pDescription.maximum;
            string namePrefix = "Switch_";
            if (pDescription.flags.HasFlag(PARAMETER_FLAGS.GLOBAL))
                namePrefix = "State_";

            if (!pDescription.flags.HasFlag(PARAMETER_FLAGS.LABELED))
                namePrefix = namePrefix + "rtpc_";
            //UnityEngine.Debug.Log($"public static CustomParamRef {name} = new CustomParamRef({name}, new FMOD.GUID {hiphen} Data1 = {guidData1}, " +
            //    $"Data2 = {guidData2}, Data3 = {guidData3}, Data4 = {guidData4} {hiphen}, new FMOD.Studio.PARAMETER_ID {hiphen} data1 = {idData1}, dat2 = {idData2} {hiphen}); \n\n");
            parameterDeclaration = $" {parameterDeclaration} public static CustomParamRef {namePrefix}{name} = new CustomParamRef( {quote}{name} {quote}, new FMOD.GUID {hiphenIn} Data1 = {guidData1}, " +
                $"Data2 = {guidData2}, Data3 = {guidData3}, Data4 = {guidData4} {hiphenOut}, new FMOD.Studio.PARAMETER_ID {hiphenIn} data1 = {idData1}, data2 = {idData2} {hiphenOut}, {min}, {max}); \n";
            float enumValuesTotal = pDescription.maximum;
            

            //FMODUnity.RuntimeManager.StudioSystem.getParameterLabelByID(pDescription.id, 0, out string labels);

            string eventToTest = name;
            if (pDescription.flags.HasFlag(PARAMETER_FLAGS.LABELED))
            {
                enumDeclaration = $"{enumDeclaration} \n public enum FmodEnum_{name}\n {hiphenIn} \n";
                for (int y = 0; y <= (int)enumValuesTotal; y++)
                {
                    eDescription.getParameterLabelByName(eventToTest, y, out string labels);
                    if (labels == "in")
                    {
                        labels = "value_" + labels;
                    }
                    else if (labels == "out")
                        labels = "value_" + labels;

                    enumDeclaration = $"{enumDeclaration} \n {labels} = {y}";
                    if (y != (int)enumValuesTotal)
                    {
                        enumDeclaration = $"{enumDeclaration},";
                    }

                }
                enumDeclaration = $"{enumDeclaration} \n {hiphenOut} \n";
            }
            else if (pDescription.flags.HasFlag(PARAMETER_FLAGS.DISCRETE))
            {
            }            

        }

And this generates:
-Enums for all my parameters
-A declaration for all enums using the following class (which contains, param ID, min and max value and GUID)

    public class CustomParamRef
    {
        public string ParameterName { get => parameterName; }
        public FMOD.Studio.PARAMETER_ID ParamId { get => paramId; }
        public FMOD.GUID ParameterGUID { get => parameterGUID; }
        public float MaxValue { get => maximumValue; }
        //public FMOD.Studio.PARAMETER_ID ParameterID;

        private string parameterName;
        private FMOD.GUID parameterGUID;
        private float maximumValue;
        private float minimumValue;
        private FMOD.Studio.PARAMETER_ID paramId;




        public CustomParamRef(string parameterName, FMOD.GUID parameterGUID)
        {
            this.parameterName = parameterName;
            this.parameterGUID = parameterGUID;
        }

        public CustomParamRef(string parameterName, FMOD.GUID parameterGUID, FMOD.Studio.PARAMETER_ID parameterId, float min, float max)
        {
            this.parameterName = parameterName;
            this.parameterGUID = parameterGUID;
            this.paramId = parameterId;
            //this.ParameterID = parameterId;
            maximumValue = max;
            minimumValue = min;
        }

        public float ReturnCorrectValue(float value)
        {
            if (value < minimumValue)
                return minimumValue;
            else if (value > maximumValue)
                return maximumValue;

            return value;
        }
    }

I basically too the idea of the export GUID header available in Fmod and use it for Parameters.
Alrighty good luck to you all hope this is of help for a few people

1 Like