Jump to content
Sign in to follow this  
karl

ProBuilder-izer

Recommended Posts

This board could use a little love! So here's an Action that will turn any old mesh into a shiny new ProBuilder object. Currently it nukes all normal and uv information, so you'll still need to use Quick Edit for your day to day mesh modifications.

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

public class ProBuilderizeMesh : Editor
{
[MenuItem("Window/ProBuilder/Actions/ProBuilderize Selection")]
public static void init()
{
	foreach(Transform t in Selection.transforms)
	{
		if(t.GetComponent())
		{
			pb_Object pb = ProBuilderize(t);
			if(pb.GetComponent())	
				DestroyImmediate(pb.GetComponent());
		}
	}
}

public static pb_Object ProBuilderize(Transform t)
{
	Mesh m = t.GetComponent().sharedMesh;

	pb_Face[] faces = new pb_Face[m.triangles.Length/3];
	int f = 0;
	for(int n = 0; n 		{
		for(int i = 0; i 			{
			faces[f] = new pb_Face(
				new int[3] {
					m.triangles[i+0],
					m.triangles[i+1],
					m.triangles[i+2]
					},
				t.GetComponent().sharedMaterials[n],
				new pb_UV()												// meh.
			);
			f++;
		}
	}

	t.gameObject.SetActive(false);
	pb_Object pb = ProBuilder.CreateObjectWithVerticesFaces(m.vertices, faces);
	pb.SetName("FrankenMesh");
	pb_Editor_Utility.SetEntityType(ProBuilder.EntityType.Detail, pb.gameObject);

	GameObject go = pb.gameObject;

	go.transform.position = t.position;
	go.transform.localRotation = t.localRotation;
	go.transform.localScale = t.localScale;
	pb.FreezeScaleTransform();
	return pb;
}
}

Share this post


Link to post
Share on other sites

BTW this only works if you copy it into assets/6by7/ProBuilder/Editor and go

Window/6by7/actions/probuilderize.

Anyway I made a sphere and ran it, there were no verts to edit after pressing Gkey, what exactly is

the effect here?

Share this post


Link to post
Share on other sites

Is ProBuilderizer fully implemented yet?

I have a blender made oval shaped ring (effectively a single oval shaped wall.

I can import into Unity (free) ok and it textures ok but once I probuilderize the object (selected in scene window) it looks like the uv faces are rotated at random. It is impossible to get a smooth flowing texture (even up to the seams).

I have also tried as a .fbx file but the results are identical.

To be honest the more complicated assets will be imported as is later on - but I was just trying to add a nice curved wall section while prototyping.

Share this post


Link to post
Share on other sites

This exposes a current limitation of ProBuilder; namely the inability to UV multiple faces simultaneously. I've been working on a way to do so, but I'm not sure when that will make it to the trunk. Long story short, this script isn't full featured, but it's not to blame in this case.

Share this post


Link to post
Share on other sites

I can't imagine how complex the script to import/recreate complex meshes must be - at least I know its not me for now :)

It isn't a major issue as I seem to have no trouble replacing the now perfectly sized placeholders in my map (thanks to ProGrids/ProBuilder).

Thanks again for such a quick response.

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
Sign in to follow this  

×