当前位置: 首页>>代码示例>>C#>>正文


C# PolygonCollider2D.GetTotalPointCount方法代码示例

本文整理汇总了C#中UnityEngine.PolygonCollider2D.GetTotalPointCount方法的典型用法代码示例。如果您正苦于以下问题:C# PolygonCollider2D.GetTotalPointCount方法的具体用法?C# PolygonCollider2D.GetTotalPointCount怎么用?C# PolygonCollider2D.GetTotalPointCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.PolygonCollider2D的用法示例。


在下文中一共展示了PolygonCollider2D.GetTotalPointCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CasterCollider

	internal CasterCollider(PolygonCollider2D coll){
		collider = coll;
		transform = coll.transform;
		TotalPointsCount = coll.GetTotalPointCount();
		points = new Vector2[TotalPointsCount];
		points = coll.points;
		type = CasterType.PolygonCollider2d;
	}
开发者ID:CarsonRoscoe,项目名称:DefendAman,代码行数:8,代码来源:CasterCollider.cs

示例2: Start

    void Start()
    {
        switch (gameObject.GetComponent<PlayerController> ().playerType) {

        case 0:
            pc2 = squareCollider;
            break;

        case 1:
            //pc2 = circleCollider;
            gameObject.GetComponent<MeshRenderer>().enabled = false;
            break;

        case 2:
            pc2 = triangleCollider;
            break;

        case 3:
            pc2 = trapezoidCollider;
            break;

        case 4:
            pc2 = rectangleCollider;
            break;

        case 5:
            pc2 = starCollider;
            break;
        }

        // don't act if type is circle
        if (gameObject.GetComponent<PlayerController> ().playerType != 1){
        //Render thing
        int pointCount = 0;
        pointCount = pc2.GetTotalPointCount();
        MeshFilter mf = GetComponent<MeshFilter>();
        Mesh mesh = new Mesh();
        Vector2[] points = pc2.points;
        Vector3[] vertices = new Vector3[pointCount];
        for(int j=0; j<pointCount; j++){
            Vector2 actual = points[j];
            vertices[j] = new Vector3(actual.x, actual.y, 0);
        }
        Triangulator tr = new Triangulator(points);
        int [] triangles = tr.Triangulate();
        mesh.vertices = vertices;
        mesh.triangles = triangles;
        mf.mesh = mesh;
        //Render thing
        }
    }
开发者ID:ChubbRck,项目名称:SFB,代码行数:51,代码来源:ColliderToMesh.cs

示例3: Start

 void Start()
 {
     pc2 = gameObject.GetComponent<PolygonCollider2D>();
     int pointCount = 0;
     pointCount = pc2.GetTotalPointCount();
     MeshFilter mf = GetComponent<MeshFilter>();
     Mesh mesh = new Mesh();
     Vector2[] points = pc2.points;
     Vector3[] vertices = new Vector3[pointCount];
     for(int j=0; j<pointCount; j++){
         Vector2 actual = points[j];
         vertices[j] = new Vector3(actual.x, actual.y, 0);
     }
     Triangulator tr = new Triangulator(points);
     int [] triangles = tr.Triangulate();
     mesh.vertices = vertices;
     mesh.triangles = triangles;
     mf.mesh = mesh;
     //Render thing
 }
开发者ID:ChubbRck,项目名称:SFB,代码行数:20,代码来源:SimpleColliderToMesh.cs

示例4: IsDefaultPolygonCollider2D

	// The default collider is a pentagon, but its position and size changes based on the sprite
	private static bool IsDefaultPolygonCollider2D(PolygonCollider2D polygonCollider2D)
	{
		if (polygonCollider2D == null) return false;
		
		if (polygonCollider2D.GetTotalPointCount() != 5) return false;
		
		var points  = polygonCollider2D.points;
		var spacing = Vector2.Distance(points[0], points[4]);
		
		// Same spacing?
		for (var i = 0; i < 4; i++)
		{
			var spacing2 = Vector2.Distance(points[i], points[i + 1]);
			
			if (Mathf.Approximately(spacing, spacing2) == false)
			{
				return false;
			}
		}
		
		var midpoint = (points[0] + points[1] + points[2] + points[3] + points[4]) * 0.2f;
		var radius   = Vector2.Distance(points[0], midpoint);
		
		// Same radius?
		for (var i = 1; i < 5; i++)
		{
			var radius2 = Vector2.Distance(points[i], midpoint);
			
			if (Mathf.Approximately(radius, radius2) == false)
			{
				return false;
			}
		}
		
		// Must be a pentagon then!
		return true;
	}
开发者ID:KariVillagran,项目名称:Dracomonium_demo,代码行数:38,代码来源:D2D_AutoPolygonCollider.cs

示例5: GetPolygonCollider2DPoints

 private Vector2[] GetPolygonCollider2DPoints(PolygonCollider2D col)
 {
     int size = col.GetTotalPointCount();
     Vector2[] points = new Vector2[size];
     Vector2[] local_points = col.points;
     for (int i = 0; i < size; i++)
     {
         points[i] = col.transform.TransformPoint(local_points[i]);
     }
     if (!colList.Contains(col))
     {
         colList.Add(col);
         CircleCollider2D circle;
         GameObject empty = new GameObject();
         empty.transform.parent = col.transform;
         empty.layer = LayerMask.NameToLayer("LumColl");
         for (int i = 0; i < points.Length; i++)
         {
             circle = empty.AddComponent<CircleCollider2D>();
             circle.radius = 0.005f;
             circle.offset = empty.transform.InverseTransformPoint(points[i]);
         }
     }
     return points;
 }
开发者ID:Nicolas-Constanty,项目名称:TestUnity,代码行数:25,代码来源:NewLight.cs


注:本文中的UnityEngine.PolygonCollider2D.GetTotalPointCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。