public void ReplaceSelectedMaterials(Material mat, Material replacement)
    {
        pb_Editor editor = pb_Editor.instance;

        pb_Object[] pbs = FindObjectsOfType(typeof(pb_Object)) as pb_Object[];
        // Cycle through every ProBuilder Object
        foreach (pb_Object pb in pbs)
        {
            bool addToSelection = false;

            foreach (pb_Face f in pb.faces)
            {
                if (f.material == mat)
                {
                    addToSelection = true;

                    f.SetMaterial(rmat);

                    editor.AddToFaceSelection(pb, f);
                }
            }

            pb.Refresh();

            if (addToSelection)
            {
                editor.AddToSelection(pb.gameObject);
            }
        }

        SceneView.RepaintAll();
    }
Esempio n. 2
0
    public static void SelectHiddenFaces(pb_Editor editor, float collision_distance)
    {
        // Open the pb_Editor window if it isn't already open.
        // pb_Editor editor = pb_Editor.instance;

        // Clear out all selected
        editor.ClearSelection();

        // If we're in Mode based editing, make sure that we're also in geo mode.
        editor.SetEditLevel(EditLevel.Geometry);

        // aaand also set to face seelction mode
        editor.SetSelectionMode(SelectMode.Face);

        // Find all ProBuilder objects in the scene.
        pb_Object[] pbs = (pb_Object[])Object.FindObjectsOfType(typeof(pb_Object));

        // Cycle through every quad
        foreach (pb_Object pb in pbs)
        {
            // Ignore if it isn't a detail or occluder
            if (pb.entityType != ProBuilder.EntityType.Detail && pb.entityType != ProBuilder.EntityType.Occluder)
            {
                continue;
            }

            bool addToSelection = false;

            foreach (pb_Face q in pb.faces)
            {
                if (HiddenFace(pb, q, collision_distance))
                {
                    // If a hidden face is found, set material to NoDraw
                    // pb.SetQuadMaterial(q, nodrawMat);

                    // Mark this object to be added to selection
                    addToSelection = true;

                    // Add hit face to selected_faces
                    editor.AddToFaceSelection(pb, q);
                }
            }

            if (addToSelection)
            {
                editor.AddToSelection(pb.gameObject);
            }
        }
        editor.UpdateSelection();

        // if(editor.selection.Length > 0) {
        editor.SetSelectionMaterial(true);
        // }
    }
    public void SelectFacesWithMatchingMaterial(Material mat)
    {
        pb_Editor editor = pb_Editor.instance;

        // Clear out all selected
        editor.ClearSelection();

        // If we're in Mode based editing, make sure that we're also in geo mode.
        editor.SetEditLevel(EditLevel.Geometry);

        // aaand also set to face seelction mode
        editor.SetSelectionMode(SelectMode.Face);

        pb_Object[] pbs = FindObjectsOfType(typeof(pb_Object)) as pb_Object[];

        // Cycle through every ProBuilder Object
        foreach (pb_Object pb in pbs)
        {
            bool addToSelection = false;

            foreach (pb_Face f in pb.faces)
            {
                if (f.material == mat)
                {
                    addToSelection = true;
                    editor.AddToFaceSelection(pb, f);
                }
            }

            if (addToSelection)
            {
                editor.AddToSelection(pb.gameObject);
            }
        }

        editor.UpdateSelection();
    }
Esempio n. 4
0
    public static void SelectHiddenFaces(pb_Editor editor, float collision_distance)
    {
        // Open the pb_Editor window if it isn't already open.
        // pb_Editor editor = pb_Editor.editorInstance;

        // Clear out all selected
        editor.ClearSelection();

        // If we're in Mode based editing, make sure that we're also in geo mode.
        editor.SetEditLevel(pb_Editor.EditLevel.Geometry);

        // aaand also set to face seelction mode
        editor.SetSelectionMode(ProBuilder.SelectMode.Face);

        // Find all ProBuilder objects in the scene.
        pb_Object[] pbs = (pb_Object[])Object.FindObjectsOfType(typeof(pb_Object));

        // Cycle through every quad
        foreach(pb_Object pb in pbs)
        {
            // Ignore if it isn't a detail or occluder
            if(pb.entityType != ProBuilder.EntityType.Detail && pb.entityType != ProBuilder.EntityType.Occluder)
                continue;

            bool addToSelection = false;

            foreach(pb_Face q in pb.faces)
            {
                if(HiddenFace(pb, q, collision_distance))
                {
                    // If a hidden face is found, set material to NoDraw
                    // pb.SetQuadMaterial(q, nodrawMat);

                    // Mark this object to be added to selection
                    addToSelection = true;

                    // Add hit face to selected_faces
                    editor.AddToFaceSelection(pb, q);
                }

            }

            if(addToSelection)
                editor.AddToSelection(pb.gameObject);
        }
        editor.UpdateSelection();

        // if(editor.selection.Length > 0) {
            editor.SetSelectionMaterial(true);
        // }
    }