- Home /
Guidance needed to use Handles.DrawAAPolyLine in JS
Hi guys, I'm trying to use this function to draw a line on the screen:
Handles.DrawAAPolyLine
I pass in a Vector3[] array but i got a compile error:
BCE0017: The best overload for the method 'UnityEditor.Handles.DrawAAPolyLine(*UnityEngine.Vector3[])' is not compatible with the argument list '(UnityEngine.Vector3[])'.
what does this mean? Thanks .
Could you please post a bit more information? I made a quick repro and I couldn't get this error. I'd like to see your call to DrawAAPolyLine and the definition of the object passed in.
Actually, what happens is that I get the error in JS but not in C#. It is probably due to the params type.
Answer by Statement · Jan 10, 2011 at 11:39 AM
The error says that the function has a parameter type of *Vector3[] (pointer to vector3 array). You are passing in a Vector3[] (vector3 array - not a pointer to one). In C#, the signature reads as params Vector3[], which means that you can pass several Vector3s separated by comma, or send a vector3 array. I think this is a design bug in Unity.
It seems that the function expects a pointer to an array of Vector3. I am not well versed in JS to know how to obtain a pointer, or if it is even possible to obtain the pointer of an array. Until someone else post a definite answer how to solve this in JS I can present you a workaround with C# code, proxying the call without the params version. Your JS code can then call this instead of Handles.
Put this in Standard Assets folder to ensure it compiles before your script.
using UnityEngine; using UnityEditor;
/// <summary> /// Handles eXtension. /// Provides support to DrawAAPolyLine functions for JS. /// </summary> public static class HandlesX { public static void DrawAAPolyLine(Vector3[] points) { Handles.DrawAAPolyLine(points); } public static void DrawAAPolyLine(float width, Vector3[] points) { Handles.DrawAAPolyLine(width, points); } public static void DrawAAPolyLine(Texture2D lineTex, Vector3[] points) { Handles.DrawAAPolyLine(lineTex, points); } public static void DrawAAPolyLine(Texture2D lineTex, float width, Vector3[] points) { Handles.DrawAAPolyLine(lineTex, width, points); } }
Then you can use HandlesX.DrawAAPolyLine in a similar fashion, from your JS code.
Answer by Eddie 2 · Jan 12, 2011 at 06:53 AM
The error is gone after I passed in the elements of the vector3 array instead of the whole array:
Handles.DrawAAPolyLine(vecArray[0], vecArray[1], vecArray[2]);
I get the error if I pass in vecArray:
Handles.DrawAAPolyLine(vecArray);
this is the function declaration:
static function DrawAAPolyLine (params points : Vector3[]) : void
Your answer
Follow this Question
Related Questions
Can't call Handles.DrawPolyLine() from Boo 1 Answer
My Vector3 changes all values to 0 1 Answer
Help to figure a logic to achieve a movement. 2 Answers
Character Jumping 2 Answers
change angle of vector3 0 Answers