umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
739 stars 168 forks source link

Index is outside the bounds of the array exception on try to get all DNA Ranges to all aviable DNA's #404

Closed Assambra closed 1 year ago

Assambra commented 1 year ago

Describe the bug I want to set the slider range automatically for each DNA it also seems to work only some DNA ranges I get an index which is outside the bounds of the array exception, which means that the user interface is not built any further. I have installed various checks but always the same result. It seems that for the values ​​eyeRotation, eyeSize, breastSize, eyeSpacing there is no DNA Range in the DNA Range asset.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior: I use following code i hope it is understandable:

public void InitializeSlider(string sliderName, string dnaName, float currentValue, int index, DynamicCharacterAvatar avatar, UMADnaBase owner)
    {
        textSliderName.text = sliderName;
        slider.value = currentValue;
        this.index = index;
        this.avatar = avatar;
        this.owner = owner;

        dNARangeAsset = GetRangeAsset(dnaName);

        if(dNARangeAsset.ContainsDNARange(index, dnaName))
        {
            slider.minValue = dNARangeAsset.means[index] - dNARangeAsset.spreads[index];
            slider.maxValue = dNARangeAsset.means[index] + dNARangeAsset.spreads[index];
        }

        isInitialized = true;
    }

    private DNARangeAsset GetRangeAsset(string dnaName)
    {
        DNARangeAsset[] dnaRangeAssets = avatar.activeRace.data.dnaRanges;
        foreach (DNARangeAsset d in dnaRangeAssets)
        {
            if (d.ContainsDNARange(index, dnaName))
            {
                return d;
            }
        }
        return null;
    }

Expected behavior Some working solution to securly exclude this DNA Range in some way. Or an option to add this into the DNA Ranges

Screenshots

Additional context

Assambra commented 1 year ago

It was a settings problem with eyeSymetry i removed it from DNA Names because i didnt set it in DNAConverterController.