umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
726 stars 167 forks source link

IndexOutOfRangeException when modifying Texture Channels in UMA Material #444

Closed jurjjc closed 3 weeks ago

jurjjc commented 3 weeks ago

Describe the bug When decreasing the "Texture Channels" by 1 and then increasing it by 1 in UMA Material, an IndexOutOfRangeException occurs.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Select a UMA material.
  2. In the Inspector, locate the "Texture Channels" section.
  3. Decrease the "Texture Channels" value by 1.
  4. Increase the "Texture Channels" value by 1.
  5. Observe the Console for the error.

Expected behavior Modifying the "Texture Channels" value should not cause any errors.

Screenshots

Additional context

Jaimi commented 3 weeks ago

I'm not able to duplicate this. Can you post the error and the call stack?

jurjjc commented 3 weeks ago

IndexOutOfRangeException: Index was outside the bounds of the array. UMA.Editors.UMAMaterialInspector.IsChannelValid (System.Int32 channel) (at Assets/UMA/Core/Editor/Scripts/UMAMaterialInspector.cs:224) UMA.Editors.UMAMaterialInspector.DrawChannelList (UnityEditor.SerializedProperty list, UMA.UMAMaterial+MaterialType materialType) (at Assets/UMA/Core/Editor/Scripts/UMAMaterialInspector.cs:261) UMA.Editors.UMAMaterialInspector.OnInspectorGUI () (at Assets/UMA/Core/Editor/Scripts/UMAMaterialInspector.cs:158) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.b__0 () (at <3d611f181d2047d0a4666e5262482490>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Jaimi commented 3 weeks ago

This appears to be a case where the object has not yet been updated by the SerializedProperty, and the channel was expanded before the object was updated. I forced the SerializedObject to ApplyModifiedProperties before drawing the channel list, and then checked the array bounds before accessing the channels. Checked into Feature-13 branch, will be in next RC or Release.

Jaimi commented 3 weeks ago

Feature-13