• 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
0
Question by gameCoder95 · Sep 05, 2018 at 11:20 AM · spritesceneinspectorflag

Sprite changes that only apply in scene view

I'm making a brick breaker game with a twist, and one of the features that I'm implementing requires me to add a public flag (i.e. a bool) to the brick's script, and then to set that flag on a desired number of bricks. However, since they all look the same, the only way I can tell if said flag is set on a brick or not is to check them manually in the inspector.

What I would like is a way to add a visual change to the brick's sprite/object in the scene when that flag is set, such as a highlight or a border glow, that is only applied to object in the scene view. When the game is actually being played, that change should go away.

Is there any way to achieve this effect?

Comment
Add comment · Show 1
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
avatar image FernandoHC · Sep 05, 2018 at 11:32 AM 0
Share

You can change the object icon, since you only want to see it on the Scene. Found this thread here: https://answers.unity.com/questions/213140/programmatically-assign-an-editor-icon-to-a-game-o.html

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by misher · Sep 05, 2018 at 12:24 PM

Let's say you have:

 using UnityEngine;
 
 public class TestScript : MonoBehaviour {
     public bool myBool;
 }

You can create custom editor for say, parent of all briks, to display in scene view some gizmos:

 using UnityEngine;
 #if UNITY_EDITOR
 using UnityEditor;
 #endif
 
 public class TestScriptParent : MonoBehaviour {
     public TestScript[] testScripts;
     public TestScript[] TestScripts
     {
         get
         {
             return GetComponentsInChildren<TestScript>();
         }
     }
 }
 
 #if UNITY_EDITOR
 [CustomEditor(typeof(TestScriptParent))]
 public class TestScriptParentEditor : Editor
 {
     float circleSize = 10f;
     void OnSceneGUI()
     {
         TestScriptParent t = target as TestScriptParent;
         foreach (var s in t.TestScripts)
         {
             if (s.myBool) Handles.DrawSolidDisc(s.transform.position, Vector3.forward, circleSize);
         }
     }
 }
 #endif


You still need to select parent object in order to run its custom inspector and draw gizmos. You also can create custom editor window, and when you open it, your custom editor script for it can find all objects of certain type in the scene and draw gizmos in the same way in them.

Comment
Add comment · Show 3 · 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
avatar image FernandoHC · Sep 05, 2018 at 12:55 PM 0
Share

Not OP, but that's a pretty good starting template, will probably use in the future, thanks!

avatar image gameCoder95 · Sep 08, 2018 at 02:46 PM 0
Share

Thank you so much, this looks legit! I will try it out and will let you know the result or if I need more help.

avatar image gameCoder95 · Jun 30, 2019 at 03:26 PM 0
Share

It's been a while, but I finally tried your code sample, and it was a really good starting point, so thank you so much for your help! The effect was exactly what I was looking for, I will build on top of it to suit my particular needs.

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

137 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

Related Questions

Reload a scene without closing the inspector and hierarchy 0 Answers

How to efficiently populate scene with GameObjects 1 Answer

2D scene level design Help 2 Answers

Adding HingeJoints to Script fields in Inspector 0 Answers

Game window keeps de attaching 0 Answers


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