From 00cd3d3cf7b4aa12693c90e8bbd188ab2b1c8d3e Mon Sep 17 00:00:00 2001 From: Thomas Lopez Date: Tue, 26 May 2026 16:28:07 -0400 Subject: [PATCH 1/2] Use a default height of 1 when switching from a 2d shape to a 3d one --- CHANGELOG.md | 1 + Runtime/Shapes/ProBuilderShape.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6e1fa2f..8dd2d823d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed +- [UUM-133529] Fixed an issue where ProBuilder GameObjects could not change back to 3D shapes after being changed to Plane or Sprite. - [UUM-133861] Fixed "Look rotation viewing vector is zero" log being spammed when holding shift while using a create tool such as Create Sprite. - [UUM-133859] Fixed an issue in URP projects where the Editor would recompile scripts when after a rectangle selection in ProBuilder. - [UUM-133530] Fixed the `Set Double Sided` custom action in the Editor Sample, which was previously remaining disabled. diff --git a/Runtime/Shapes/ProBuilderShape.cs b/Runtime/Shapes/ProBuilderShape.cs index ed410fedf..470d5be91 100644 --- a/Runtime/Shapes/ProBuilderShape.cs +++ b/Runtime/Shapes/ProBuilderShape.cs @@ -146,8 +146,12 @@ void Rebuild() internal void SetShape(Shape shape) { + bool wasFlat = m_Shape is Plane || m_Shape is Sprite; + bool isFlat = shape is Plane || shape is Sprite; + m_Shape = shape; - if(m_Shape is Plane || m_Shape is Sprite) + + if(isFlat) { Bounds bounds = new Bounds(m_LocalCenter, size); var newCenter = bounds.center; @@ -158,6 +162,15 @@ internal void SetShape(Shape shape) size = newSize; m_Size.y = 0; } + else if(wasFlat && !isFlat) + { + // Transitioning FROM a 2D shape TO a 3D shape - restore Y dimension + if(Mathf.Abs(m_Size.y) < Mathf.Epsilon) + { + m_Size.y = 1f; + } + } + UpdateShape(); m_UnmodifiedMeshVersion = mesh.versionIndex; From d67cdfe9b4459a9e8fb364060841787b9ec1bc95 Mon Sep 17 00:00:00 2001 From: Thomas Lopez Date: Thu, 28 May 2026 10:28:06 -0400 Subject: [PATCH 2/2] replaced Mathf.Epsilon by 0.0001f Unity typically uses tolerances like 0.0001f for geometric comparisons (e.g., in collision detection, mesh validation) --- Runtime/Shapes/ProBuilderShape.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Runtime/Shapes/ProBuilderShape.cs b/Runtime/Shapes/ProBuilderShape.cs index 470d5be91..8855407de 100644 --- a/Runtime/Shapes/ProBuilderShape.cs +++ b/Runtime/Shapes/ProBuilderShape.cs @@ -10,6 +10,8 @@ sealed class ProBuilderShape : MonoBehaviour const string k_HelpUrl = "https://docs.unity3d.com/Packages/com.unity.probuilder@latest"; const string k_IconPath = "Packages/com.unity.probuilder/Editor Default Resources/Icons/EditableMesh/EditableMesh.png"; + const float k_MinHeight = 0.0001f; + [SerializeReference] Shape m_Shape = new Cube(); @@ -58,7 +60,7 @@ public Bounds editionBounds { m_EditionBounds.center = m_LocalCenter; m_EditionBounds.size = m_Size; - if(Mathf.Abs(m_Size.y) < Mathf.Epsilon) + if(Mathf.Abs(m_Size.y) < k_MinHeight) m_EditionBounds.size = new Vector3(m_Size.x, 0f, m_Size.z); return m_EditionBounds; @@ -165,10 +167,8 @@ internal void SetShape(Shape shape) else if(wasFlat && !isFlat) { // Transitioning FROM a 2D shape TO a 3D shape - restore Y dimension - if(Mathf.Abs(m_Size.y) < Mathf.Epsilon) - { + if(Mathf.Abs(m_Size.y) < k_MinHeight) m_Size.y = 1f; - } } UpdateShape();