edit: update to reflect changes made after comments
So I'm trying to build a mesh with code and generate triangles. I've successfully made tris manually, but I'm hoping to utilize this Triangulator script to generate tris for more complex concave/convex shapes.
http://www.unifycommunity.com/wiki/index.php?title=Triangulator Here's the triangulator code in C# -- I'm very unfamiliar with C# so this is pretty confusing to me.
Here's a thread that has helped me so far http://forum.unity3d.com/threads/27346-JavaScript.Array-gt-C-.List-and-constructor?highlight=constructor+triangulator
So I use that code:
var triangulator : Triangulator = GetComponent("Triangulator");
temp = new Triangulator(newVertices2D.ToBuiltin(Vector2));
temp.Triangulate();
But that doesn't seem to do much. I assume the .cs script ran through Triangulate with my Vector2 array, but how do I retrieve the results in this .js script?
Any help is greatly appreciated :)
The Triangulator class in http://www.unifycommunity.com/wiki/index.php?title=Triangulator doesn't extend MonoBehaviour. Does yours differs from it?
– anon44852076I forgot I did modify line 4 to "public class Triangulator : MonoBehaviour" because it was giving me an error -- should I remove that and find a solution to my original error?
– anon88966785Yes, you can't do that -- as the error says, you can't instantiate MonoBehavior classes. They are instantiated by Unity itself.
– anon44852076So now I get the warning "The class defined in the script is not derived from MonoBehaviour or ScriptableObject!" in monobehavior.cpp and still no tris. I'm thinking I'm still failing to actually receive the tris back in the js file..
– anon88966785Hmmm, I can't help much. But you should update the question with the new info and perhaps a more detailed stack trace information.
– anon44852076