Search Issue Tracker

Fixed in 2022.1.0b4

Votes

1

Found in

2022.1

2022.1.0b4

Issue ID

1396818

Regression

No

DivideByZeroException in UniityEditor.TerrainInspector.GetAspectRect after selecting Terrain with enabled Paint texture panel

Terrain

-

Steps to repro:
1. Pull the repository linked in the comments and switch to revision 8b2d1b1dd2b0cbbf2fd11c4bf008bfae4607aef2;
2. Open the project and scene "SK_TestScene";
3. In the Hierarchy select TerrainBase gameobject;
4. In the Inspector select Paint Texture tab;
5. In the Hierarchy select TerrainPark gameobject.

Actual result:
Error:
DivideByZeroException: Attempted to divide by zero.
UnityEditor.TerrainInspector.GetAspectRect (System.Int32 elementCount, System.Int32 approxSize, System.Int32 extraLineHeight, System.Int32& itemsPerRow) (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainInspector.AspectSelectionGridImageAndText (System.Int32 selected, System.Int32 itemCount, UnityEngine.GUI+CustomSelectionGridItemGUI itemGUI, System.Int32 approxSize, UnityEngine.GUIContent emptyString, System.Boolean& doubleClick) (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainInspector.AspectSelectionGridImageAndText (System.Int32 selected, UnityEngine.GUIContent[] textures, System.Int32 approxSize, UnityEngine.GUIContent emptyString, System.Boolean& doubleClick) (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainLayerUtility.ShowTerrainLayersSelectionHelper (UnityEngine.Terrain terrain, System.Int32 activeTerrainLayer) (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainTools.PaintTextureTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainInspector.ShowPaint () (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.TerrainInspector.OnInspectorGUI () (at <5d684a862a4a439185f337d8fab2f3d2>:0)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass62_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <a41af8713c314ad8b19c9e0c8298b3b8>:0)
UnityEditor.InspectorWindow:RedrawFromNative()

is shown. See attached video.

Expected result:
No error is shown after selecting Terrain gameobject.

Notes:
- Reproducible in Version 2022.1.0b4;
- Reproducible on Windows;
- Also reproducible with Paint Trees tab selected in the Terrain Inspector.

Comments (3)

  1. 89b37054dfd1cadbd17b6a4188b42ea4?d=mm

    Ryan-Hayle

    Mar 11, 2022 10:42

    Will this issue be backported?

  2. 89b37054dfd1cadbd17b6a4188b42ea4?d=mm

    Ryan-Hayle

    Mar 11, 2022 10:40

    I have the same issue (or very similar) in Unity 2021.2.8 HDRP and I do not use terrain details.

    DivideByZeroException: Attempted to divide by zero.
    UnityEditor.TerrainInspector.GetAspectRect (System.Int32 elementCount, System.Int32 approxSize, System.Int32 extraLineHeight, System.Int32& itemsPerRow) (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainInspector.AspectSelectionGridImageAndText (System.Int32 selected, System.Int32 itemCount, UnityEngine.GUI+CustomSelectionGridItemGUI itemGUI, System.Int32 approxSize, UnityEngine.GUIContent emptyString, System.Boolean& doubleClick) (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainInspector.AspectSelectionGridImageAndText (System.Int32 selected, UnityEngine.GUIContent[] textures, System.Int32 approxSize, UnityEngine.GUIContent emptyString, System.Boolean& doubleClick) (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainLayerUtility.ShowTerrainLayersSelectionHelper (UnityEngine.Terrain terrain, System.Int32 activeTerrainLayer) (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainTools.PaintTextureTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainInspector.ShowPaint () (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.TerrainInspector.OnInspectorGUI () (at <13c5ad68fffb46969f1ca1df233d1e4d>:0)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <6e80f6af65b64894a5fb8578a935bf61>:0)
    UnityEditor.UIElements.Tooltip:SetTooltip(Single, Single)

  3. 23a866368e38d8b385d42991611c8efb?d=mm

    Fernando-Ferreira

    Mar 04, 2022 16:13

    after debuging for a while, I noticed maybe the grass system is causing it

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.