Skip to content

When editing a model that's inside a prefab, the tool adds new brushes to the open scene instead of the prefab #321

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

Open
robclouth opened this issue Apr 11, 2021 · 7 comments
Labels

Comments

@robclouth
Copy link

When editing a model that's inside a prefab, the tool adds new brushes to the open scene instead of the prefab. It seems to "remember" to add to the prefab if you edit a brush then go back to generate, but then it will forget it again and you have to do the edit trick again. Any ideas?

@alexjhetherington
Copy link

alexjhetherington commented Apr 22, 2022

Unable to reproduce in 2019 LTS, 2021 LTS.

@robclouth please could you provide the version you are on + video or project with replication.

Otherwise I recommend this issue is closed.

@Mark-LaCroix
Copy link

I'm having the same issue. Here's a video of it "in action" :

2022-07-08.05-02-49.mp4

I'm using Unity 2021.3.3 and Realtime CSG 1.57.2 via Package Manager git URL.

@robclouth
Copy link
Author

That's exactly it

@Mark-LaCroix
Copy link

Mark-LaCroix commented Jul 8, 2022

I've traced the problem to Generator.Base.GenerateBrushObjects() where lastUsedModelTransform (which gets its value from SelectionUtility.LastUsedModel) is somehow null when you're editing a prefab (or really, when a Model object is part of a prefab, as this issue also occurs outside of prefab editing mode). Thus, a new "Model" GameObject is created for the brush to go into.

I'm not yet sure how SelectionUtility.LastUsedModel is normally set, but I'll keep looking.

@Mark-LaCroix
Copy link

Mark-LaCroix commented Jul 8, 2022

Once I comment out this block inside of SelectionUtility.LastUsedModel.set...

// don't want new stuff to be added to a prefab instance
if (CSGPrefabUtility.IsPrefabAssetOrInstance(model.gameObject))
{
	continue;
}

...adding brushes now work as expected in prefab isolation mode, and also works just fine in scene mode, as long as there isn't another (non-prefab) Model object, in which case it seems to default to that with no problem.

So, fixed? But... the comment in this code block implies that there's some reason we actually wouldn't want to do this. I can't find any downsides, but I've only been testing it for a few minutes. 😂

I can do a PR for this, assuming it doesn't brake something else that I'm ignorant to. Let me know.

@nukeandbeans
Copy link
Collaborator

Once I comment out this block inside of SelectionUtility.LastUsedModel.set...

So, fixed? But... the comment in this code block implies that there's some reason we actually wouldn't want to do this. I can't find any downsides, but I've only been testing it for a few minutes. 😂

I can do a PR for this, assuming it doesn't brake something else that I'm ignorant to. Let me know.

Out of curiosity, how is it working now? Any side effects?

You're more than welcome to submit a PR to this branch of my own fork, so it can be included in #349

@silentorb
Copy link

silentorb commented Feb 17, 2023

Commenting out either or both of the CSGPrefabUtility.IsPrefabAssetOrInstance checks isn't fixing the bug for me in 2022.1.10.

As a workaround, if I first add an empty CSG Model to the prefab and then start generating brushes, the brushes are created within the prefab instead of the scene.

In case the root of the issue does involve CSGPrefabUtility.IsPrefabAssetOrInstance, just to clear up some confusion: there are two uses of it in SelectionUtility. @Mark-LaCroix mentions set but pasted code for the get.

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

No branches or pull requests

5 participants