static public int CreatePrimitive(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.CreatePrimitive(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); self.CreatePrimitive(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); UnityEngine.Vector2 a3; checkType(l, 4, out a3); self.CreatePrimitive(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int CreatePrimitive(IntPtr l) { try{ if (matchType(l, 2, typeof(int), typeof(UnityEngine.Vector2), typeof(UnityEngine.Vector2))) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); UnityEngine.Vector2 a3; checkType(l, 4, out a3); self.CreatePrimitive(a1, a2, a3); return(0); } else if (matchType(l, 2, typeof(int), typeof(UnityEngine.Vector2))) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); self.CreatePrimitive(a1, a2); return(0); } else if (matchType(l, 2, typeof(int))) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.CreatePrimitive(a1); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int QPYX_CreatePrimitive_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 2) { UnityEngine.PolygonCollider2D QPYX_obj_YXQP = (UnityEngine.PolygonCollider2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.PolygonCollider2D)); int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); QPYX_obj_YXQP.CreatePrimitive(QPYX_arg0_YXQP); return(0); } else if (QPYX_count_YXQP == 3) { UnityEngine.PolygonCollider2D QPYX_obj_YXQP = (UnityEngine.PolygonCollider2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.PolygonCollider2D)); int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); UnityEngine.Vector2 QPYX_arg1_YXQP = ToLua.ToVector2(L_YXQP, 3); QPYX_obj_YXQP.CreatePrimitive(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else if (QPYX_count_YXQP == 4) { UnityEngine.PolygonCollider2D QPYX_obj_YXQP = (UnityEngine.PolygonCollider2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.PolygonCollider2D)); int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); UnityEngine.Vector2 QPYX_arg1_YXQP = ToLua.ToVector2(L_YXQP, 3); UnityEngine.Vector2 QPYX_arg2_YXQP = ToLua.ToVector2(L_YXQP, 4); QPYX_obj_YXQP.CreatePrimitive(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.PolygonCollider2D.CreatePrimitive")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static public int CreatePrimitive(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.CreatePrimitive(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); self.CreatePrimitive(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector2 a2; checkType(l, 3, out a2); UnityEngine.Vector2 a3; checkType(l, 4, out a3); self.CreatePrimitive(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function CreatePrimitive to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public void StopDraw() { StartDraw = false; previousObj = null; startPoint = null; if(linePoints.Count<2){ linePoints.Clear(); return;} #region getting circle shape Hashtable table = new Hashtable(); foreach (Vector3 item in linePoints) { float radius = (float) System.Math.Round( Vector2.Distance( item, compute2DPolygonCentroid(linePoints.ToArray(), linePoints.Count)), 2); if(!table.ContainsKey( radius)) table.Add(radius, 0); table[radius] = (int) table[radius] + 1; } GameObject parentObj = new GameObject("lineObject"); parentObj.transform.parent = transform; foreach (DictionaryEntry item in table) { if((int)item.Value >= 10 && table.Count > 6) { CreateCircle(compute2DPolygonCentroid(linePoints.ToArray(), linePoints.Count), ""+item.Key, parentObj); linePoints.Clear(); return; } } #endregion int ii = 0; GameObject gm = null; GameObject polyObj = new GameObject("polyObj"); polyObj.transform.parent = parentObj.transform; PlaneFromPoly scr = polyObj.AddComponent<PlaneFromPoly>(); foreach (Vector3 item in linePoints) { //create points gm = Instantiate(point, item, transform.rotation) as GameObject; if(startPoint == null) startPoint = gm; gm.transform.parent = polyObj.transform; gm.GetComponent<LineObject>().firstObject = item; gm.GetComponent<LineObject>().nextObject = gm; if(previousObj != null){ gm.GetComponent<LineObject>().nextObject = previousObj; } previousObj = gm; ii++; } scr.mat = mat; scr.poly = linePoints.ToArray(); scr.keyPoints = linePoints; int scoreMinus = -80; if(Vector3.Distance( startPos, Input.mousePosition) < 10f){ // if shape is rounded scoreMinus = -50; scr.BuildMesh(linePoints); gm.GetComponent<LineObject>().nextObject = startPoint; polyCollider = polyObj.AddComponent<PolygonCollider2D>(); polyCollider.sharedMaterial = bounce; polyCollider.CreatePrimitive(linePoints.Count); polyCollider.SetPath(0, linePoints.ToArray() ); } else{ edgeCollider = polyObj.AddComponent<EdgeCollider2D>(); edgeCollider.sharedMaterial = bounce; // polyCollider = polyObj.AddComponent<PolygonCollider2D>(); // polyCollider.sharedMaterial = bounce; // polyCollider.CreatePrimitive( linePoints.Count * 2 ); Vector2[] listV2 = new Vector2[linePoints.Count*2]; for (int i = 0; i < linePoints.Count; i++) { listV2[i] = linePoints[i]; } int j =0; for (int i = linePoints.Count - 1; i >= 0; i--) { listV2[j+linePoints.Count] = linePoints[i]+Vector2.up*0.05f; j++; } edgeCollider.points = linePoints.ToArray(); //listV2; // polyCollider.SetPath(0, listV2); } previousObj = null; startPoint = null; Rigidbody2D r = polyObj.AddComponent<Rigidbody2D>(); r.mass = 0.2f * linePoints.Count; // r.collisionDetectionMode = CollisionDetectionMode2D.Continuous; linePoints.Clear(); }