Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 15 additions & 2 deletions Runtime/Shapes/ProBuilderShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
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();

Expand Down Expand Up @@ -58,7 +60,7 @@
{
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)

Check warning on line 63 in Runtime/Shapes/ProBuilderShape.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Runtime/Shapes/ProBuilderShape.cs#L63

Added line #L63 was not covered by tests
m_EditionBounds.size = new Vector3(m_Size.x, 0f, m_Size.z);

return m_EditionBounds;
Expand Down Expand Up @@ -146,8 +148,12 @@

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;
Expand All @@ -158,6 +164,13 @@
size = newSize;
m_Size.y = 0;
}
else if(wasFlat && !isFlat)
{

Check warning on line 168 in Runtime/Shapes/ProBuilderShape.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Runtime/Shapes/ProBuilderShape.cs#L168

Added line #L168 was not covered by tests
// Transitioning FROM a 2D shape TO a 3D shape - restore Y dimension
if(Mathf.Abs(m_Size.y) < k_MinHeight)
m_Size.y = 1f;
}

Check warning on line 173 in Runtime/Shapes/ProBuilderShape.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Runtime/Shapes/ProBuilderShape.cs#L170-L173

Added lines #L170 - L173 were not covered by tests
UpdateShape();

m_UnmodifiedMeshVersion = mesh.versionIndex;
Expand Down