diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a15e0253..5382f0ab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,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..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; @@ -146,8 +148,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 +164,13 @@ 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) < k_MinHeight) + m_Size.y = 1f; + } + UpdateShape(); m_UnmodifiedMeshVersion = mesh.versionIndex;