Jump to content
Sign in to follow this  
joduffy

Runtime Editing - Playmaker

Recommended Posts

Hi Guys,

 

I am trying to do editing of a mesh at runtime. Currently I have the face part working but I am trying to do vert, edge and then uv stuff.

 

I am running into some problems with 24 vertices showing up for a standard procbuilder cube when i expected it to be 8?
 
I think this might be doing a loop for the number of vertices per face. As a cube has 6 faces and 4 vertices for face. Thats 6 x 4 = 24.
 
I am just trying to highlight each of the verts with a cube at the moment so I could then move the mini cube and have the vert update and follow it. But is there any built in highlight or gizmo stuff I could use?
 
I also wanted to ask if this would would for building walls in an RTS.
 
I am currently digging through the dll file but its hard to find information on this stuff.
 
Thanks for your help guys,
Jonathan

Share this post


Link to post
Share on other sites
I am running into some problems with 24 vertices showing up for a standard procbuilder cube when i expected it to be 8?
 
 
24 is correct.  Each of the 6 faces requires 4 of it's own normals in order to have hard edges.  So out of the 6 faces, each face is composed of 4 vertices and 6 triangles.
 
I am just trying to highlight each of the verts with a cube at the moment so I could then move the mini cube and have the vert update and follow it. But is there any built in highlight or gizmo stuff I could use?
 
 
Check out the pb_Editor_Graphics class.  You'll need to install the Source version of ProBuilder, and the class uses the Editor API, but the principles of how things are rendered should translate to runtime without issue.
 
I also wanted to ask if this would would for building walls in an RTS.
 
 
Sure - you could make that happen.
 
I am currently digging through the dll file but its hard to find information on this stuff.
 
Again, I'd highly recommend installing the Source version so that you don't have to go through a decompiler.

Share this post


Link to post
Share on other sites

Thanks Karl,

 

You have been awesome help on this forum. Surprised by how fast I get answers.

 

I installed the update from the source code but got this error:

 

 

Assets/ProCore/ProBuilder/Classes/ClassesCore/Type/EdgeConnection.cs(45,64): error CS0121: The call is ambiguous between the following methods or properties: `ProBuilder2.Common.pbUtil.ToFormattedString<ProBuilder2.Common.pb_Edge>(this System.Collections.Generic.List<ProBuilder2.Common.pb_Edge>, string)' and `ProBuilder2.Common.pbUtil.ToFormattedString<ProBuilder2.Common.pb_Edge>(this System.Collections.Generic.List<ProBuilder2.Common.pb_Edge>, string)'

Share this post


Link to post
Share on other sites

Karl,

 

I updated to the lastest probuilder and now the scene I had working is now broken and even the sample runtime scene doesnt want to work.

 

I get this error.

 

 

ProBuilder Object -424272 contains null geometry.  Self destruct in 5...4...3...

UnityEngine.Debug:LogError(Object)
pb_Object:Verify() (at Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Object.cs:1329)
pb_Object:Awake() (at Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Object.cs:43)
UnityEngine.GameObject:AddComponent()
pb_Object:CreateInstanceWithPoints(Vector3[]) (at Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Object.cs:133)
ProBuilder2.Common.ProBuilder:CreateObjectWithPoints(Vector3[]) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/ProBuilder.cs:124)
pb_Shape_Generator:CubeGenerator(Vector3) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_Shape_Generator.cs:99)
ProBuilder2.Common.ProBuilder:CreatePrimitive(Shape) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/ProBuilder.cs:64)
RuntimeEdit:SpawnCube() (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:90)
RuntimeEdit:Awake() (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:66)

 

 

NullReferenceException: Object reference not set to an instance of an object

pb_Object.CreateInstanceWithPoints (UnityEngine.Vector3[] vertices) (at Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Object.cs:134)
ProBuilder2.Common.ProBuilder.CreateObjectWithPoints (UnityEngine.Vector3[] vertices) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/ProBuilder.cs:124)
pb_Shape_Generator.CubeGenerator (Vector3 size) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_Shape_Generator.cs:99)
ProBuilder2.Common.ProBuilder.CreatePrimitive (Shape shape) (at Assets/ProCore/ProBuilder/Classes/ClassesEditing/ProBuilder.cs:64)
RuntimeEdit.SpawnCube () (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:90)
RuntimeEdit.Awake () (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:66)

Share this post


Link to post
Share on other sites

Is there an online thing like oxygen for ProBuilder and the other ProCore packages?

 

Not an updated one - I'll try to get that compiled soon.

 

 

I updated to the lastest probuilder and now the scene I had working is now broken and even the sample runtime scene doesnt want to work.

 

 

 
Are there any persistent errors in the Console?

Share this post


Link to post
Share on other sites

Thanks Karl,

 

No. There isnt any other errors. I even created a new project and imported in Probuilder and still the same error. I contacted a dev who has your asset and he got the same error.

 

Does it work fine from your end?

 

I am testing it now with other plugins and it is just when it gets to the editing that it throws an error. It seems to be the verify method:

 

 

public bool Verify()

#endif
{
if(msh == null)
{
// attempt reconstruction...
if( !ReconstructMesh() )
{
// reconstruct failed.  this shouldn't happen, but sometimes it does?
Debug.LogError("ProBuilder Object " + id + " contains null geometry.  Self destruct in 5...4...3...");
DestroyImmediate(this.gameObject);
}
 
return false;
}

 

 

Here is a screenshot of VS complaining about pb_UV_Editor 

 

https://app.box.com/s/r6fu8vebxdbi1wc0640b

 

 

The name 'pb' does not exist in the current context

 

This seems to be on line 1785

 

 

 

GUI.Label( new Rect(p.x, p.y, 120, 20), pb.uv[index].ToString() );

 
 

Here is screenshots of the error in unity:

 

https://app.box.com/s/vvrtqy8rklrzikhgubx5

 

https://app.box.com/s/ocxn1jix3ucdd9ei2ih0

Share this post


Link to post
Share on other sites

Oh interesting - so it looks like you've the Source version installed, and a global "DEBUG" defined somewhere?  If you remove that define, does that fix things

 

 

Edit - sorry, that define isn't the problem with the Runtime example.  That's expected actually.  Check the Readme that is inside that API example folder, it explains that you need to re-connect some components to get it working.

Share this post


Link to post
Share on other sites

Hi Karl,

 

The pb_cube isnt missing any scripts or reference though.

 

 

# ProBuilder Instantiate Example Scene

 
Due to the UnityPackage build process, the prefab used in this
scene loses it's script references.  To fix this, drag the 
pb_Object script (found in ProBuilder->Classes->ProBuilderCore)
onto the first missing script well, and pb_Entity onto the
second missing script well.
 
So I have no missing reference errors in the inspector panel.

 

I also did a search for global Debug and couldnt find anything.

 

Edit -

Looks like its pointing to two lines in the pb_Object

 

Line 1329

 

Debug.LogError("ProBuilder Object " + id + " contains null geometry.  Self destruct in 5...4...3...");

 
 

Line 134

 

pb_obj.SetName("Object");

 
 

And when I build in VS I get error for pb_UV_Editor

Line 1785

 

GUI.Label( new Rect(p.x, p.y, 120, 20), pb.uv[index].ToString() );

 
 
I don't know if this helps at all.

Share this post


Link to post
Share on other sites

Hi,

 

I tried building a windows app with probuilder and I got the following error:

 

 

Assets/ProCore/Shared/pb_Profiler/Tests/TestProfiler.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

 
Its coming from the TestProfiler.cs file

Share this post


Link to post
Share on other sites

Just delete TestProfiler.cs.  As the name implies, it's simply a unit test for the pb_Profiler editor.

 

Edit - Which actually shouldn't be included in distribution packs... I've modified the Source release to exclude this file in the future.  Thanks for bringing it to my attention.

Share this post


Link to post
Share on other sites

Thanks Karl,

 

That removed the build error. But I am still having trouble with runtime editing and that sample scene.

 

Can you verify that it works from your end for:

 

ProBuilder2-v2900

 

Sorry to be a pain. I am just trying to finish off the code needed for my masters thesis.

Share this post


Link to post
Share on other sites

@joduffy - I was able to reproduce the runtime editing error and have it fixed for the 2.3.2 update.  I'm just running through tests today and should have it on the Asset Store in a day or two.

Share this post


Link to post
Share on other sites

The latest update has removed the error and the run time example works really well.

 

I am currently able to move faces in and out. But I just wanted  to ask if there was a way to stop faces becoming inverted as you extrude / subtract them backwards.

 

I am guessing you find the back faces maybe and then test to see the current face your moving doesnt go beyond the back face position?

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  

×