Search Unity

Toggle wireframe on selected objects

Discussion in 'Editor & General Support' started by Odini, Mar 18, 2010.

  1. Odini

    Odini

    Joined:
    Jan 3, 2010
    Posts:
    18
    Maybe this is quite obvious, but I couldn't find an option to turn wireframe off on objects that are selected - where do I do this?

    Currently, I cannot see what I am doing (especially when tweaking shaders/material parameters) due to the fact that the mesh is fairly dense and the wireframe is simply obscuring the view.

    Any idea?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There isn't an option to turn off the wireframe for an object while it is selected.
     
  3. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    this would be very handy... as mention by the OP, working on shaders when you have a solid wireframe overlayed is very frustrating at times, and no you can't unselect it, you often want to move/rotate the object...

    perhaps provide some options here?

    transparent overlay color when selected
    bounding volume only
    a transparency option on the wireframe
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Wireframe rendering does not support transparency at all (its a hardware feature), so at least that option is "directly out"
     
  5. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    it is possible :)
    I've used it on plenty of editor tools at the directX level - you just enable alphablending when you submit the drawprimitive containing the wire

    ...eitherway, some options as to how the selected obejcts are displayed would be handy!
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    problem is that unity is an opengl - dx thing not a dx thing ;)
    but yeah you are right one could change the color of the vertices

    but it would also become more costly so cases where you "flooded the view" with triangles will not needfully become any better, just slower.


    what I think would be a good solution would be hotkey that allows you to disable the selection overlay completely till you hit it again so you can select and see all fine and when you need to see the actual model its a hit - check - hit again
     
  7. Odini

    Odini

    Joined:
    Jan 3, 2010
    Posts:
    18
    yeah a hotkey to show/hide the wireframe while working on a selected object would be nice.

    Other solutions:
    - Object outline (not sure if this would be possible tho' ;))
    - Show wireframe of the bounding volume instead



    Another thing that would be good. Render wireframe as quads/tris (not just tris).
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    the model is triangulated (as in all realtime 3D engines, as they all work with triangles on the meshes only)
     
  9. tomvds

    tomvds

    Joined:
    Oct 10, 2008
    Posts:
    1,028
    Not perfect, but certainly a workaround:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. [ExecuteInEditMode]
    5. public class ObjectHandle : MonoBehaviour
    6. {
    7.     public Transform    target;
    8.     void Update ()
    9.     {
    10.         if (target != null)
    11.         {
    12.             if (renderer == null)
    13.             {
    14.                 gameObject.AddComponent<MeshRenderer>();
    15.                 List<Material> list = new List<Material>();
    16.                 Renderer[] rens = target.GetComponentsInChildren<Renderer>();
    17.                 foreach (Renderer r in rens)
    18.                     foreach (Material m in r.sharedMaterials)
    19.                         if (!list.Contains(m))
    20.                             list.Add(m);
    21.                 renderer.sharedMaterials = list.ToArray();
    22.             }
    23.             target.position = transform.position;
    24.             target.rotation = transform.rotation;  
    25.         }
    26.     }
    27. }
    Place this script on an empty GameObject and link the object you're testing the shader on in the "target" variable. You can then rotate and move the object without seeing the wireframe, by rotating/moving the helper GameObject with the script instead.

    You could even add a renderer to the helper GameObject and link in all the sharedMaterials from the target object. That way you could even edit shader settings from the helper object.

    EDIT: I went around and added the material edit support. It's actually quite handy, as it can now also be used to edit all the materials in a deep selection of objects from one single node (and without wireframes, ofcourse :p).
     
  10. Odini

    Odini

    Joined:
    Jan 3, 2010
    Posts:
    18
    Awesome, thanks dude! :D
     
  11. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    3 years later and still no way to disable wireframe on selected object.... sigh
     
  12. Jiven

    Jiven

    Joined:
    Jul 10, 2012
    Posts:
    1
    Not sure when this was added but as of 4.2.0f4 you can turn the alpha all the way down on your wireframe display in Preferences.

    Edit > Preferences > Colors > Wireframe Active >

    $hide_wireframe.png

    Move the (A)lpha slider all the way to the left.

    You'll notice my S***ty helmet is selected and the rotate gizmo is active.
     
  13. testure

    testure

    Joined:
    Jul 3, 2011
    Posts:
    81
    einWikinger and Alekxss like this.
  14. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    Unity 5.4 "Edit > Preferences > Colors > Wireframe Active >"
    does not seem to be working.
     
    Rachan likes this.
  15. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    424
    Yes, I'm also had the same problem. like...
    Screenshot (279).png

    Is there any way to turn off this wireframes?
     
  16. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    I took the Editor script that @testure linked to and modified it so that it will enable or disable the wireframes on the renderers of all children of the selected object. I found this makes it much more useful, at least for me. Also changed the keyboard shortcut for Show Wireframe to Ctrl+w, as the example script had it set to Ctrl+s, which is already used (save scene).

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. namespace YourGame
    5. {  
    6.     public class ToggleWireframe : EditorWindow
    7.     {
    8.         [MenuItem("GameObject/Show Wireframe %w")]
    9.         static void ShowWireframe()
    10.         {
    11.             foreach (GameObject s in Selection.gameObjects)
    12.             {
    13.                 var renderers = s.GetComponentsInChildren<Renderer>();
    14.                 if (renderers == null) { return; }
    15.  
    16.                 foreach (var r in renderers)
    17.                 {                  
    18.                     EditorUtility.SetSelectedWireframeHidden(r, false);
    19.                 }              
    20.             }
    21.         }
    22.  
    23.         [MenuItem("GameObject/Show Wireframe %w", true)]
    24.         static bool ShowWireframeValidate()
    25.         {
    26.             return Selection.activeGameObject != null;
    27.         }
    28.  
    29.         [MenuItem("GameObject/Hide WireFrame %h")]
    30.         static void HideWireframe()
    31.         {
    32.             foreach (GameObject s in Selection.gameObjects)
    33.             {
    34.                 var renderers = s.GetComponentsInChildren<Renderer>();
    35.                 if (renderers == null) { return; }
    36.                
    37.                 foreach (var r in renderers)
    38.                 {
    39.                     EditorUtility.SetSelectedWireframeHidden(r, true);
    40.                 }                          
    41.             }
    42.         }
    43.  
    44.  
    45.         [MenuItem("GameObject/Hide WireFrame %h", true)]
    46.         static bool HideWireframeValidate()
    47.         {
    48.             return Selection.activeGameObject != null;
    49.         }
    50.     }
    51. }
     
    Chris_Payne_QS, Akshara and Dan_lala like this.
  17. Dan_lala

    Dan_lala

    Joined:
    May 14, 2015
    Posts:
    42
    Thank you! It is working great. To make sure everyone gets it, here are the fail-safe instructions: put above script named toggleWireframe.cs in an editor folder, use Ctrl+h to hide wireframe of selected mesh, Crtl+w to unhide.
     
    TeagansDad likes this.
  18. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    THANKS -- You've helped me out today :)

    However, The wireframe, after I make it hidden, doesn't disappear until I select the object again. Any idea how to force the scene view to update the change?
     
    TeagansDad likes this.
  19. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @sfbaystudios - sorry, I can't help you there as it disappears immediately for me. :)

    I'm not super knowledgeable about editor scripting just yet, so I'm not sure how to do that.

    I do find that it reappears after running the game though.
     
  20. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Interesting. My best amateurish guess is that the scene view doesn't register any changes, so it doesn't update. Only updates when a change occurs, probably. Who knows!

    (It's an update for the Blend Shapes script -- the Devils character has 175 blend shapes, so I'm updating the script to make things more readable, to turn off the wireframes, and to have preset files that you can export and import)
     
    TeagansDad likes this.