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 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; for (int i = 0; i < pb.faces.Length; i++) { if (pb.faces[i].material == mat) { addToSelection = true; pb.AddToFaceSelection(i); } } if (addToSelection) { editor.AddToSelection(pb.gameObject); } } editor.UpdateSelection(); }