Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PolyShape Undo Errors #264

Merged
merged 3 commits into from
Feb 28, 2020
Merged

Fix PolyShape Undo Errors #264

merged 3 commits into from
Feb 28, 2020

Conversation

karl-
Copy link
Contributor

@karl- karl- commented Feb 28, 2020

@karl- karl- added the backport label Feb 28, 2020
@karl- karl- changed the base branch from master to v4.2/master February 28, 2020 14:29
@@ -309,11 +309,14 @@ internal static void InitObject(ProBuilderMesh pb)
switch (s_ColliderType.value)
{
case ColliderType.BoxCollider:
pb.gameObject.AddComponent<BoxCollider>();
if(!pb.gameObject.TryGetComponent<BoxCollider>(out _))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use getComponent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TryGetComponent doesn't allocate if there is no component matching the requested type. It's a minor perf. optimization.

@karl- karl- merged commit 1d0d3a8 into v4.2/master Feb 28, 2020
@karl- karl- deleted the v4.2/st/fix-poly-shape-undo branch March 1, 2020 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants