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 for Edit PolyShape tool reverting previously merged polyshapes #583

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

modrimkus-unity
Copy link
Contributor

Purpose of this PR

PR fixes issue where merging two or more polyshape objects would not remove the PolyShape component resulting in issue down the line when Edit PolyShape tool would be activated.

Links

Jira: https://jira.unity3d.com/browse/PBLD-205

Comments to Reviewers

[List known issues, planned work, provide any extra context for your code.]

Comment on lines 66 to 69
// Remove PolyShape component if one is present post-merge
var polyShapeComp = mesh.gameObject.GetComponent<PolyShape>();
if (polyShapeComp != null )
UndoUtility.DestroyImmediate(polyShapeComp);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should also remove ProBuilderShape Components when merging 2 PB objects (2 PBShapes or one PBShape + PolyShape) because it does not make sense either to have access to the shape parameters anymore in that case, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lopezt-unity Good point! Added this in d00e0b4. Test also updated.

Copy link

@katherinesheridan1 katherinesheridan1 left a comment

Choose a reason for hiding this comment

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

Works great on my end !!

Copy link
Collaborator

@lopezt-unity lopezt-unity left a comment

Choose a reason for hiding this comment

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

LGTM,
Adding some comments to make tests improvements but nothing blocking here :D

m_mesh1 = ShapeFactory.Instantiate<Cube>();
m_mesh2 = ShapeFactory.Instantiate<Cone>();
m_mesh3 = ShapeFactory.Instantiate<Cylinder>();
m_mesh1.gameObject.AddComponent<BoxCollider>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this :)

Comment on lines +35 to +36
[TestCase(typeof(PolyShape))]
[TestCase(typeof(ProBuilderShape))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe try to change this for something like:

    [TestCase(typeof(PolyShape),typeof(PolyShape))]
    [TestCase(typeof(ProBuilderShape),typeof(ProBuilderShape))]
    [TestCase(typeof(ProBuilderShape),typeof(PolyShape))]

ActiveEditorTracker.sharedTracker.ForceRebuild();

var mergeObjectsAction = new MergeObjects();
var newMeshes = mergeObjectsAction.DoMergeObjectsAction();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just add an assert on newMeshes.Count == 1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants