1
\$\begingroup\$

I have implemented Scene loading in my game and have three scenes: Persistent, Main Menu and Game

By default, the player is loaded into the Persistent scene, which immediately loads the Main Menu, and when the player clicks on Play, Main Menu is unloaded and Game is loaded.

Now, the two active scenes are Persistent and Game.

However, I have a script with OnDrawGizmos on a GameObject in the Game scene. It seems that by default gizmos only begin to be drawn when I click on that GameObject, sort of activating it, and everything works fine. This used to just work before because Game was my only scene and Unity automatically selected that first GameObject. Now, with multiple scenes, no GameObject is selected by default and my gizmos won't draw until I manually click on it.

How can I solve this?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ OnDrawGizmos and OnDrawGizmosSelected handle unselected/selected game objects. I'd suspect in your case it's not so much about selecting the object as selecting something in the scene. Unity might disable gizmos from scenes other than the one containing your last selection, either to reduce scene view clutter or improve performance in multi-scene editing. \$\endgroup\$ – DMGregory Mar 23 at 14:32
0
\$\begingroup\$

I think you're looking for this

Selection.activeGameObject = {Whatever object you want selected}

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.