A few Unity versions ago it was possible to drag a GameObject from a different scene into an Object fields on my component. The reference would not serialize of course, but I could still use the Unity Drag and Drop behaviour and then serialize manually through my custom inspector.
Sometime along the road, Unity disabled the feature to drag references from one scene to another to prevent corrupted scene files, but now my tool doesn’t work anymore, because I can’t drag Objects into the field.
Is there any simple way to replicate the previous behaviour? I’d love to just drag any GameObject from any scene and determine, if it needs to be serialized in my custom way, if it’s from another scene.
I noticed that it is possible if you use Odin inspector, but I guess it is not on purpose that it is possible.
Yes, I saw the feature in different asset store products as well, so I looked more into it.
After some more research I found the answer: Unity actually added the functionality back in, I just didn’t notice it: https://docs.unity3d.com/ScriptReference/SceneManagement.EditorSceneManager-preventCrossSceneReferences.html
In my custom inspector I can set the flag to allow cross scene references without them throwing warnings. Then I can serialize the data to my own reference system and voila.
1 Like
Hello, I’m looking to do something similar to this, was wondering if there’s any docs\tutorials\examples that you know of I can take a look at please? Thanks