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

Dropping a material in a rigid body is not set in all shapes #32

Open
lidiamartinez opened this issue Dec 5, 2018 · 3 comments
Open

Comments

@lidiamartinez
Copy link

I found out this failed in a rigid body made out of several materials and I wanted to override all of them with the one I dropped in the box.

Sometimes works, sometimes not. I'm not really sure how to reproduce this.

@nmalg
Copy link
Member

nmalg commented Dec 5, 2018

I've heard you had this issue and I think the conclusion was a Unity bug. Could also be that the Inspector GUI isn't properly flagged dirty, so if you deselect and select the body/shape again the shapes appears to have same material.

From Editor/AGXUnityEditor/Tools/RigidBodyTool.cs this method is invoked when the material is dropped:

    private void AssignShapeMaterialToAllShapes( ShapeMaterial shapeMaterial )
    {
      Shape[] shapes = RigidBody.GetComponentsInChildren<Shape>();
      foreach ( var shape in shapes )
        shape.Material = shapeMaterial;

      RigidBody.UpdateMassProperties();
    }

As long as GetComponentsInChildren<Shape>() is returning all the shapes (expected), the materials should be updated.

@lidiamartinez
Copy link
Author

I didn't check that, maybe I need to force that update. I'll see if that works. Thanks!

@lidiamartinez
Copy link
Author

Seems like it works. Thanks!

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

No branches or pull requests

2 participants