public static pb_Lightmap_Editor Init(pb_Editor _editor)
	{
		pb_Lightmap_Editor win = EditorWindow.GetWindow<pb_Lightmap_Editor>(true, "UV2 Param Gen. Settings", true);
		win.Show();
		win.editor = _editor;
		win.OnSelectionUpdate(win.editor.selection);

		return win;
	}
Ejemplo 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.entity.entityType != EntityType.Detail && pb.entity.entityType != 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 SelectedFaces
                    pb.AddToFaceSelection(q);
                }
            }

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

        editor.UpdateSelection();
    }
Ejemplo n.º 3
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;

            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();
    }
Ejemplo n.º 5
0
 public void OnEnable()
 {
     editorRef = pb_Editor.instance;
 }
Ejemplo n.º 6
0
    public static void SetFaceColors(Color col)
    {
        pb_Object[] selection = pbUtil.GetComponents <pb_Object>(Selection.transforms);

        pbUndo.RecordObjects(selection, "Apply Vertex Colors");

        pb_Editor editor = pb_Editor.instance;

        if (editor && editor.editLevel == EditLevel.Geometry)
        {
            switch (editor.selectionMode)
            {
            case SelectMode.Face:
            case SelectMode.Vertex:
                foreach (pb_Object pb in selection)
                {
                    Color[] colors = pb.colors;

                    foreach (int i in pb.SelectedTriangles)
                    {
                        colors[i] = col;
                    }

                    pb.SetColors(colors);
                }
                break;

            case SelectMode.Edge:
                foreach (pb_Object pb in selection)
                {
                    Color[] colors = pb.colors;

                    foreach (int i in pb.sharedIndices.AllIndicesWithValues(pb.SelectedTriangles))
                    {
                        colors[i] = col;
                    }

                    pb.SetColors(colors);
                }
                break;
            }
        }
        else
        {
            foreach (pb_Object pb in selection)
            {
                foreach (pb_Face face in pb.faces)
                {
                    pb.SetFaceColor(face, col);
                }
            }
        }

        foreach (pb_Object pb in selection)
        {
            pb.ToMesh();
            pb.Refresh();
            pb.Optimize();
        }

        pb_Editor_Utility.ShowNotification("Set Vertex Colors\n" + pb_ColorUtil.GetColorName(col));
    }
Ejemplo n.º 7
0
    public static bool MenuVerifyDeleteEdge()
    {
        pb_Editor editor = pb_Editor.instance;

        return(editor && editor.editLevel == EditLevel.Geometry && editor.selectedFaceCount > 0);
    }
Ejemplo n.º 8
0
 public void OnEnable()
 {
     editorRef = pb_Editor.instance;
 }
Ejemplo n.º 9
0
		public static bool MenuVerifySmartConnect()
		{
			pb_Editor editor = pb_Editor.instance;
			return editor != null && editor.selectedVertexCount > 3;
		}
Ejemplo n.º 10
0
		public static bool MenuVerifySplitOperationObject()
		{
			pb_Editor editor = pb_Editor.instance;
			return editor && editor.selection.Length > 0;
		}
Ejemplo n.º 11
0
		public static bool MenuVerifySplitOperationEdge()
		{
			pb_Editor editor = pb_Editor.instance;
			return editor && editor.editLevel == EditLevel.Geometry && editor.selectionMode == SelectMode.Edge && editor.selectedEdgeCount > 0;
		}
Ejemplo n.º 12
0
        public static bool MenuVerifySplitOperationVertex()
        {
            pb_Editor editor = pb_Editor.instance;

            return(editor && editor.editLevel == EditLevel.Geometry && editor.selectionMode == SelectMode.Vertex && editor.selectedVertexCount > 0);
        }
Ejemplo n.º 13
0
        public static bool MenuVerifySmartConnect()
        {
            pb_Editor editor = pb_Editor.instance;

            return(editor != null);
        }
Ejemplo n.º 14
0
 public static void OpenEditorWindow()
 {
     pb_Editor pb_Editor = pb_Editor.MenuOpenWindow();
 }