• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by crowbar1 · Jan 07 at 12:44 PM · gameobjectaiscene viewdisable object

Show disabled object in scene view

I want to disable game objects, which I will enable later in the game during gameplay. When I disabled objects, they are completely invisible the scene view, which makes it hard to work this way. I would like to disabled game objects, but still see them in the scene view, so I can easily know where they are and make modifications.

For example I place enemies, which will be activated when the player enters a trigger. I want to test the level, stop play mode and quickly adjust enemy positions without having to select the objects from the hierarchy, I just want to click on the enemies in the scene view as if they were enabled.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Hatsuko · Jan 15 at 01:02 AM

I don't know a good way. I have two ideas.

  1. Have your enemy GameObjects enabled in Edit Mode. If you want to hide them at first in the gameplay, hide them by script. For example you may have a GameManager script that hides all the enemies on Start or after the level is loaded.

  2. Some editor scripting might help. I tried to write one.

Create a script called LetMeSeeYouGuys with the following content.

 using UnityEngine;
 
 [ExecuteInEditMode]
 public class LetMeSeeYouGuys : MonoBehaviour
 {
     public GameObject[] guys;
 
     public Vector2 buttonSize = new Vector2(100, 25);
     public Vector2 buttonOffset = new Vector2(0, 40);
     public Color buttonGUIColor = new Color(1, 1, 1, 0.8f);
 
     void Awake()
     {
 #if !UNITY_EDITOR
         Destroy(gameObject);
 #endif
     }
 }

Create another script called LetMeSeeYouGuysEditor with the following content. Put it in the same folder as LetMeSeeYouGuys.

 #if UNITY_EDITOR
 using UnityEditor;
 using UnityEngine;
 
 [CustomEditor(typeof(LetMeSeeYouGuys))]
 public class LetMeSeeYouGuysEditor : Editor
 {
     new private LetMeSeeYouGuys target;
 
     void OnEnable()
     {
         target = (LetMeSeeYouGuys)base.target;
     }
 
     void OnSceneGUI()
     {
         if (target.guys == null || target.guys.Length == 0)
             return;
         Camera sceneCam = SceneView.currentDrawingSceneView.camera;
         Handles.BeginGUI();
         Color colorBackup = GUI.color;
         GUI.color = target.buttonGUIColor;
         foreach (GameObject guy in target.guys)
         {
             Vector3 screenPos = sceneCam.WorldToScreenPoint(guy.transform.position);
             Vector2 guiPos = new Vector2(screenPos.x, sceneCam.pixelHeight - screenPos.y);
             Rect buttonRect = new Rect(guiPos - target.buttonSize / 2, target.buttonSize);
             buttonRect.x += target.buttonOffset.x;
             buttonRect.y -= target.buttonOffset.y;
 
             if (GUI.Button(buttonRect, guy.name))
             {
                 // Debug.Log("Clicked!");
                 Selection.activeObject = guy;
             }
         }
         GUI.color = colorBackup;
         Handles.EndGUI();
     }
 
 
     // [DrawGizmo(GizmoType.Selected | GizmoType.NonSelected)]
     // static void DrawGizmoForMyScript(LetMeSeeYouGuys target, GizmoType gizmoType)
     // {
     //     // Cannot detect mouse click here...
     // }
 }
 #endif
 
 // Reference:
 // https://forum.unity.com/threads/button-in-scene-view.259913/
 // https://answers.unity.com/questions/19321/onscenegui-called-without-any-object-selected.html

In your scene

  • Create a GameObject and attach the script LetMeSeeYouGuys.

  • Drag your disabled enemies into the Guys list.

  • Turn on Gizmos in the Scene view. Now you should see some Gizmo buttons in the Scene view. Click a button to select the enemy GameObject.

alt text

Currently the Gizmo buttons only show when the LetMeSeeYouGuys object is selected. Not very handy and I don't know how to solve it. There is a workaround. You can add another Inspector tab.

alt text

Now you have another Inspector tab. Select the LetMeSeeYouGuys GameObject and then lock the tab. You can shrink it very small and keep working on the project like usual.


snipaste-2023-01-15-08-25-37.png (196.2 kB)
img2.png (151.3 kB)
Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

290 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Quick question. How do i get an object to come down once all AIs are destroyes and then when i come near it it loads a level 1 Answer

Problem with AI tracking object 0 Answers

Ai trigger 0 Answers

How to assign a transform object to Prefab ? 3 Answers

How can I hide/expose a gameobject based on its distance from the player/camera? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges