Jump to content
Spikeh

Suggestion: Add a "solo" button to progroups

Recommended Posts

This actually may belong in probuilder itself, but it would be really handy to be able to "solo" an object, much like you can "solo" a track in music or film editing software - when enabled, it would hide everything in the scene except the selected object.

 

Would be extremely handy when editing complex meshes with lots of other objects around them.

Share this post


Link to post
Share on other sites

I just want to make sure I understand what you mean. This would be like the current "Isolate" function for a group but instead of hiding all other groups it hides all other objects in the scene?

The only issue I think could come up is that such a function would potentially be manipulating objects that aren't being referenced by ProGroups. So flags may be altered where the user doesn't want them to be.

Share this post


Link to post
Share on other sites

Yes - essentially, everything in the scene except the currently selected objects would be hidden. This isn't really related to the groups you've created; it's more to make editing an individual object that's surrounded with more complex objects, easier.

Share this post


Link to post
Share on other sites

Yep, this existed in the REALLLLY old version of ProGroups. I would love to have it myself, maybe it can be looked into. Would really be a separate thing though- more of a standalone editor enhancement. 

 

In 3DS Max, you can hit "Alt-Q" to isolate the selection. I use it...every 30 seconds or so, ha. Keeps the view clean and unobstructed for brains like mine that are easily distracted :)

Share this post


Link to post
Share on other sites

Yep, this existed in the REALLLLY old version of ProGroups. I would love to have it myself, maybe it can be looked into. Would really be a separate thing though- more of a standalone editor enhancement. 

 

In 3DS Max, you can hit "Alt-Q" to isolate the selection. I use it...every 30 seconds or so, ha. Keeps the view clean and unobstructed for brains like mine that are easily distracted :)

 

Tbh, I can't see it being hard. I'm going to have a go myself at some point - would be extremely handy for me at the moment.

Share this post


Link to post
Share on other sites

Here's a script to add 2 menu items to the editor (just put it in your Editor directory), and shortcut keys to do what you want:

 

SHIFT+H: Hide Unselected objects

CTRL+SHIFT+H: Unhide all

using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

public class RadiangamesMenus : ScriptableObject
{
    [MenuItem("Custom/Visibility/Unhide All %#h")]
    static void UnhideAll()
    {
        UnhideAllObjects();
    }

    [MenuItem("Custom/Visibility/Hide Unselected #h")]
    static void HideUnselected()
    {
        HideUnselectedObjects();
    }

    public static void UnhideAllObjects()
    {
        object[] obj = GameObject.FindObjectsOfType(typeof(GameObject));
        foreach (object o in obj) {
            GameObject go = (GameObject)o;
            if (go != null) {
                ToggleHidden(go, false, true);
            }
        }
    }

    public static void HideUnselectedObjects()
    {
        InvertSelection();

        foreach (object o in Selection.objects) {
            GameObject go = (GameObject)o;
            if (go != null) {
                ToggleHidden(go, true);
            }
        }

        InvertSelection();
    }

    public static void ToggleHidden(GameObject go, bool should_hide = false, bool should_unhide = false)
    {
        Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
        foreach (Renderer r in renderers) {
            if (should_hide) {
                r.enabled = false;
            } else if (should_unhide) {
                r.enabled = true;
            } else {
                r.enabled = !r.enabled;
            }
        }
    }

    public static void InvertSelection()
    {
        List<GameObject> oldSelection = new List<GameObject>();
        List<GameObject> newSelection = new List<GameObject>();

        foreach (GameObject obj in Selection.GetFiltered(typeof(GameObject), SelectionMode.ExcludePrefab))
            oldSelection.Add(obj);

        foreach (GameObject obj in FindObjectsOfType(typeof(GameObject))) {
            if (!oldSelection.Contains(obj))
                newSelection.Add(obj);
        }

        Selection.objects = newSelection.ToArray();
    }
}

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×