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

Scene file changes in version 3 #24

Open
russellquinn opened this issue Jan 28, 2022 · 8 comments
Open

Scene file changes in version 3 #24

russellquinn opened this issue Jan 28, 2022 · 8 comments

Comments

@russellquinn
Copy link
Contributor

Since version 3 implemented dynamic Material creation, we've fixed the problem of floating-point values in Material asset files changing and making for confusing source-control commits.

But, now I'm seeing lots of spurious changes in my Scene files. Material components being added and/or deleted from GameObjects. This makes it very hard to check any intended changes in scene files while committing to source control.

Is this an expected result of the new system, or is it because I switched from version 2 to 3 on an existing project, and Unity is only updating GameObjects to the new dynamic-Material system when I touch them during editing?

@kirevdokimov
Copy link
Owner

The expected behaviour is that when we change components, it changes in scene file, but not when we change material manually. Unfortunately I am not into Unity anymore and, if you have some issues and able to fix it with PR, I will be really appreciate!

@russellquinn
Copy link
Contributor Author

Sorry, to clarify, I haven't changed any settings into the Components, I'm just seeing the same ever-changing values that were happening in the Material files, now happening in my Scene file. I was wondering if that was expected, or if the changing-numbers problem still exists, but was just moved somewhere else. (I can try and look into it.)

@antonsmetanin
Copy link
Collaborator

@russellquinn I can't seem to reproduce it. Does this happen every time you save the scene? When you look at the diff, does it show any changed objects other than the material?

@russellquinn
Copy link
Contributor Author

It happens every time I make a change to something (so the scene is dirty) and then save. For example, change the name of a single, unrelated GameObject in the scene and save.

From looking at the code, I think the problem is that it creates a dynamic material and sets the Image's Material property to be this material. This causes the Material to be saved to the Scene file. But, it recreates this Material every single time Unity is run.

@russellquinn
Copy link
Contributor Author

I spent some time refactoring and trying to get more-stable changes. You can see my progress here: russellquinn@3c508c9

But, I ran into a problem with being unable to update the dynamic material if "Is Maskable" is set on the image. I switched back to version 3.0.1 and I think it suffers from the same problem — the new system breaks if maskable is set. Or, at least, the dynamic updating breaks.

@antonsmetanin
Copy link
Collaborator

This update seems to have caused more problems than it was supposed to solve. Anyway, I've been able to reproduce the material being recreated by closing the scene, then opening it again and saving it.

I didn't test it but your refactoring should help here. Also, I think maybe we don't need to store the material in our script at all, since the Image holds a reference to it, so theMaterial property can be just a getter.

I wonder why masks were affected though.

@russellquinn
Copy link
Contributor Author

Masks change the material used by the Image to a stencil material

@russellquinn
Copy link
Contributor Author

A summary of the problems:

v2 v3
WidthHeightRadius updates in Material files, without user changes, causing problems with source control WidthHeightRadius updates in Scene files, without user changes, causing problems with source control
Requires new Material assets to be created Materials inside Scene files update, without user changes, causing problems with source control
isMaskable broken?

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

3 participants