Got annoyed by not being able to turn off wireframe drawing of selected game objects. Totally kills rendering performance.
So I wrote this C# editor script which applies the current wireframe state via SetSelectedWireframeHidden to all current and future game objects in the scene:
Did you really have to go put the whole “under MIT Licence” mumbo jumbo while sharing 3 or 4 lines of code for which the documentation of this method provides example code to do the exact same thing except for it not been a toggle action?
Yes, I like to add a license to my source code to avoid any confusion regarding its use. By default, if one doesn’t add a license the code is not for public use, distribution, etc unless the author gives his/her permission to each individual. Some people tend to stay away from such code because they have the legal perspective in mind.
As for the manual’s example code: it did not work for me (probably because it doesn’t act on child objects) and was written in JS. So I rewrote it in C# because I’m more familiar with it. Then I wanted it to act globally for all objects in the scene, including new ones. My problem is with object collections where the root object draws all its children as wireframe, which made the editor nearly unusable.
When I saw something like that wasn’t readily available I published it as a unity package. I needed this, I’m sure others will find use for it too.
many of us all share snippets of code be it JS , C# or Shaderlab on these forums and unity answers using code tags or a .unity package. You post it and people - use it , talk about it, review it , dispute it, laugh at it, give thanks whatever - with no confusion
I mean if you wrote some 20000 line framework that took a few months and release it for free ,then sure put some licence on it so people can say: " hey, that guy x did this , he is awesome!" but for a small snippet of logic…? just share it like everyone else does without all the bureaucratic nonsense.
here is a day in the life of just one page one answers.unity , just have a look people talking about problems with code , posting suggestions , posting whole solutions , doing revisions … and no licence mumbo jumbo talk is seen anywhere …
I suppose the Unity Answers site has a similar policy than stackoverflow.com (same software btw). The thing is, if the site’s user agreement includes such a clause then all the code posted on the site may be under a permissive license or even public domain automatically. That is one reason why stackoverflow is so popular even among developers working for larger companies.
I come from a background where the legal perspective is important even for small snippets of code. So I add the license, no harm done.
THANK YOU, SteffenJ! I’ve been using Unity since 2.5, and the wireframe is a problem that has nagged me, on and off, for a very long time.
I’ve been able to ignore it, enough that I haven’t bothered putting together a toggle on my own (I always assumed there was already a hot key that I wasn’t aware of, lol). With my latest project, though, the wireframe has been a particular hassle – perhaps in part bcz I’m using a lot of off-the-shelf objects for this one, which often have a ton more edges than my own do! Because I can’t actually see the textured surface behind all the wires, I haven’t been able to judge when an object is penetrating the terrain or another object (I don’t remember having that problem before).
At any rate, I’m using v 5.4.4 (Unity Pro), and the script updated just fine, and it’s working precisely as advertised.
I also wanted to let you know that I appreciate the heavily commented code. The CC/MIT license stuff is a non-issue for me, btw; I’m accustomed to the header/disclaimer/usage-rights from web development and other Unity resources, so I had no problem skimming past the “header” section.
Regardless, I just wanted to say thanks for posting this little snippet.