arimger / Unity-Editor-Toolbox

Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.
MIT License
1.7k stars 125 forks source link

[Feature Request] NotPrefabObjectOnly #111

Closed blawnode closed 2 months ago

blawnode commented 4 months ago

Could be plentily useful, when you want to target something loaded in the scene. Then one could Destroy it or SetActive it with less trouble about if it's a prefab or not.

arimger commented 4 months ago

Hi, if I understand correctly - there is already a SceneObjectOnly attribute that allows only Scene objects to be assigned (otherwise there is a warning). I'm open to potential improvements.

blawnode commented 3 months ago

Nah, not what I mean. [SceneObjectOnly] is for a specific asset type, selected from the Assets window, right?

The potential [NotPrefabObjectOnly] would not be for assets, but rather game objects located in a scene's hierarchy, and selected from the Hierarchy window.

arimger commented 3 months ago

Ok, got it. I think I can implement something similar.

blawnode commented 3 months ago

Hey, I appreciate it! Thank you so much! And thank you for adding stuff even after so much time..!

arimger commented 3 months ago

Hello, I added NotPrefabObjectOnly attribute. Drawer checks if an object is a prefab, if so then input will be ignored. Additionally, I added the AllowInstancedPrefabs property, if true then instanced prefabs from the Scene will be accepted. Is this the behaviour you expected?

blawnode commented 3 months ago

Good thinking with the AllowInstancedPrefabs property! I think this is exactly what I hoped for! I'm sure this will be useful, and not only for me. I've tested the feature, and it seems to work fine.

If I may suggest, maybe adding it to PrefabObjectOnly could be handy.

But that idea aside, I believe that this feature is pretty much done. Think this issue should be closed?

arimger commented 3 months ago

There is already PrefabObjectOnlyAttribute, which allows only connected prefab objects. Yes, if you feel that everything is ok then close the issue, please.

blawnode commented 2 months ago

Ah yeah, I know there is a PrefabObjectOnlyAttribute. I meant that giving PrefabObjectOnlyAttribute the AllowInstancedPrefabs property is a neat idea. For now I'll close, the idea is probably irrelevant for this specific issue, as you've solved it.

arimger commented 2 months ago

Ach, sorry, probably I was reading too fast :D I will consider adding it there, thanks.