Search Unity

Change color of an object in editor (scene view) based on a property of a script component

Discussion in 'Immediate Mode GUI (IMGUI)' started by cvbattum, Mar 4, 2019.

  1. cvbattum

    cvbattum

    Joined:
    Apr 20, 2018
    Posts:
    12
    I have a dozen of the same objects in my game for which I set the color manually on each one. Now instead of copying the material a dozen times and ending up with a lot of clutter in my assets, I decided to make the color of this object an adjustable property in the inspector. In the Start() function I then copy the original material, set it's color to the one I set in the inspector and all works great. The only problem is that I can't quickly see what color all of my objects are while I'm editing my scene. To make my life easier while I'm building the level, I'd really like to see this.

    The most beautiful solution would be to perform the steps I now do at the start of the game in the scene editor as well. Is this in any way possible? If so, how and where can I find resources on how to do it? If not, a simple outline with the color I set in the inspector would work great as well. I know for a fact this last thing is possible, yet I don't know what terms to Google to find resources on how to do it. Any push in the right direction is greatly appreciated!
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,317
    You can use a MaterialPropertyBlock that you update the values for OnValidate.
     
    the-Lander likes this.