-
Notifications
You must be signed in to change notification settings - Fork 19
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
Editor contents not updated after material change #33
Comments
Ok, I see. ShapeMaterial is an asset and you're making changes to an instance when the editor is playing - if I understand you correctly. To trigger whatever happens under the surface of the editor, you have to call Let me know if this works! |
Oh! Thanks. This is something I should have thought about, sorry about that. I need a Unity object to call that, but material is agx.Material. In my case, I sent the game object containing this material, but it doesn't update. If I have the agxCollide.Geometry and the agx.Material of that geometry which is what the contact gives me, What should I use instead?. I also have the GameObject that contains this geometry. |
What are you changing in agx.Material? AGXUnity.ShapeMaterial hasn't got much other than what can be used for wires/cables and functionality to pair them in contact materials. I'm awaiting reasons to implement all properties 😉 What I can say now is that if you change something in a ShapeMaterial instance, the changes propagates to the Inspector and the asset is saved. It's not defined to make changes to a native instance (geometry.getMaterial() in your contact listener) when the parameter is exposed in the AGXUnity API. We're not propagating the values back and the values can be changed when, for example, the Inspector GUI is updated. If you have access to the GameObject you can match the geometry and find the ShapeMaterial: var geometry1 = // a geometry in the geometry contact
var shapes = go.GetComponentsInChildren<AGXUnity.Collide.Shape>();
foreach ( var shape in shapes ) {
if ( shape.NativeGeometry == geometry1 && shape.Material != null )
shape.Material.Density = 500.0f;
} Let me know if there's something missing in the ShapeMaterial class. |
I'm just changing the material of the geometry: And I don't see any change in the inspector. I'm just swapping the material after touching a particular sensor I want. It's a temporal swap but I need to see which is the material after swapping it, making the GUI update. It's weird I don't see any update after a while, even after opening the inspector and closing it. Thanks! |
One more comment. I checked that the update on the GUI is called, I was wrong. UnityEngine.Object valInField = wrapper.Get<UnityEngine.Object>(); But the material is the old one when this is run. |
In the custom editor file : BaseEditor, the Update() or even OnInspectorGUI() stops being called after a while. It is called every time I switch from one object to another that has an AGXUnity script at the beginning of the play mode, but after a while, it stops being called.
I don't know exactly how this works, but the problem we are having is that we are changing the material through the code, but those materials are not shown in the inspector. The old material is shown, making it hard to debug. We are using log messages intensively but due to the impact it has on the simulation time, I think there should be an update to the contents of the editor and I don't really understand why it is not updated when selecting an object. The thing is, it is not showing the current data of the object!
Thanks
The text was updated successfully, but these errors were encountered: