• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.PolygonCollider2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PolygonCollider2D类属于UnityEngine命名空间,在下文中一共展示了PolygonCollider2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Awake

        // Use this for initialization
        void Awake()
        {
            spriteRend = GetComponent<SpriteRenderer> ();
            collider = GetComponent<PolygonCollider2D> ();

            //DestroyPlanetChunk ();
        }
开发者ID:dialcforchris,项目名称:InterstellarmadillosGame,代码行数:8,代码来源:GravityBody.cs


示例2: Start

	// Use this for initialization
	void Start () {
		area = this.gameObject.GetComponent<PolygonCollider2D> (); 
		/*Vector3[] passIn = new Vector3[points.Length]; 
		for (int i = 0; i < points.Length; i++)
			passIn [i] = points [i].transform.position; 
		SetCollider (passIn); */
	}
开发者ID:RIT-SMCS,项目名称:Gerrymander,代码行数:8,代码来源:DistrictCollider.cs


示例3: Start

 void Start()
 {
     base.Start();
     anim = GetComponent<Animator>();
     rigid = GetComponent<Rigidbody2D>();
     collider = GetComponent<PolygonCollider2D>();
 }
开发者ID:stronklabs,项目名称:fastfast,代码行数:7,代码来源:Player.cs


示例4: AssignValues

		override public void AssignValues (List<ActionParameter> parameters)
		{
			SceneSettings sceneSettings = GameObject.FindWithTag (Tags.gameEngine).GetComponent <SceneSettings>();

			if (sceneSetting == SceneSetting.DefaultNavMesh)
			{
				if (sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles)
				{
					hole = AssignFile <PolygonCollider2D> (parameters, parameterID, constantID, hole);
				}
				else
				{
					newNavMesh = AssignFile <NavigationMesh> (parameters, parameterID, constantID, newNavMesh);
				}
			}
			else if (sceneSetting == SceneSetting.DefaultPlayerStart)
			{
				playerStart = AssignFile <PlayerStart> (parameters, parameterID, constantID, playerStart);
			}
			else if (sceneSetting == SceneSetting.SortingMap)
			{
				sortingMap = AssignFile <SortingMap> (parameters, parameterID, constantID, sortingMap);
			}
			else if (sceneSetting == SceneSetting.OnLoadCutscene || sceneSetting == SceneSetting.OnStartCutscene)
			{
				cutscene = AssignFile <Cutscene> (parameters, parameterID, constantID, cutscene);
			}
		}
开发者ID:amutnick,项目名称:CrackTheCode_Repo,代码行数:28,代码来源:ActionNavMesh.cs


示例5: AssignValues

 public override void AssignValues(List<ActionParameter> parameters)
 {
     if (sceneSetting == SceneSetting.DefaultNavMesh)
     {
         if (KickStarter.sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles)
         {
             hole = AssignFile <PolygonCollider2D> (parameters, parameterID, constantID, hole);
             replaceHole = AssignFile <PolygonCollider2D> (parameters, replaceParameterID, replaceConstantID, replaceHole);
         }
         else
         {
             newNavMesh = AssignFile <NavigationMesh> (parameters, parameterID, constantID, newNavMesh);
         }
     }
     else if (sceneSetting == SceneSetting.DefaultPlayerStart)
     {
         playerStart = AssignFile <PlayerStart> (parameters, parameterID, constantID, playerStart);
     }
     else if (sceneSetting == SceneSetting.SortingMap)
     {
         sortingMap = AssignFile <SortingMap> (parameters, parameterID, constantID, sortingMap);
     }
     else if (sceneSetting == SceneSetting.SortingMap)
     {
         tintMap = AssignFile <TintMap> (parameters, parameterID, constantID, tintMap);
     }
     else if (sceneSetting == SceneSetting.OnLoadCutscene || sceneSetting == SceneSetting.OnStartCutscene)
     {
         cutscene = AssignFile <Cutscene> (parameters, parameterID, constantID, cutscene);
     }
 }
开发者ID:mcbodge,项目名称:eidolon,代码行数:31,代码来源:ActionNavMesh.cs


示例6: Awake

	// Use this for initialization
	void Awake () {
        ignoreCollisionList = new List<Collider2D>();

        rigid = GetComponent<Rigidbody2D>();

        ball = this.gameObject.AddComponent<PolygonCollider2D>();
        ball.sharedMaterial = ballPhysicsMat;

        rend = GetComponent<LineRenderer>();

        Vector2[] points = new Vector2[2 * (numSides + 1)];
        rend.SetVertexCount(numSides + 1);

        float visualRadius = (outerRadius + innerRadius) / 2;
        rend.SetWidth(outerRadius - innerRadius, outerRadius - innerRadius);

        // inner points
        for (int i = 0; i <= numSides; i++)
        {
            float angle = TwoPI * i / numSides;
            Vector2 direction = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
            points[i] = innerRadius * direction;
            rend.SetPosition(i, visualRadius * direction);

        }

        // outer points
        for (int i = numSides + 1; i < points.Length; i++)
        {
            float angle = TwoPI * i / numSides;
            points[i] = new Vector2(outerRadius * Mathf.Cos(angle), outerRadius * Mathf.Sin(angle));
        }

        ball.points = points;
	}
开发者ID:AlbearKamoo,项目名称:Witches-vs-Aliens-2015-2016,代码行数:36,代码来源:HampsterBall.cs


示例7: OnDrawGizmos

    //---------------------------------------------------------------------------------------------

    protected virtual void OnDrawGizmos()
    {
        Follow();

        if (!m_pCollider)
            m_pCollider = GetComponent<PolygonCollider2D>();

        Vector2[] points = m_pCollider.points;
        Vector2 p2D = transform.position;

        if (points == null) return;

        Vector3 pointCurrent, pointNext;
        Vector3 angles = transform.rotation.eulerAngles;

        for (var i = 0; i < points.Length - 1; i++)
        {
            pointCurrent = KDTools.Adjust(points[i], p2D, angles, transform.localScale);
            pointNext = KDTools.Adjust(points[i + 1], p2D, angles, transform.localScale);
            Gizmos.DrawLine(pointCurrent, pointNext);
        }

        pointCurrent = KDTools.Adjust
                       (
                            points[points.Length - 1], 
                            p2D, 
                            angles,
                            transform.localScale
                        );

        pointNext = KDTools.Adjust(points[0], p2D, angles, transform.localScale);

        Gizmos.DrawLine(pointCurrent, pointNext);
    }
开发者ID:aaronroles,项目名称:LITZombies,代码行数:36,代码来源:KD2DArea.cs


示例8: DrawAsteroid

    public void DrawAsteroid()
    {
        var drawObject = GetComponent<LineRendererDrawer>();
        polyCollider = GetComponent<PolygonCollider2D>();
        var linePoints = circleSegments + 1;
        var polyPoints = new Vector2[linePoints];
        var drawPoints = new List<Vector2>();
        float part = 360f / circleSegments;
        int i = 0;
        while (i < linePoints)
        {
            float duh = part * i * (2 * Mathf.PI / 360) * -1 + Mathf.PI / 2;
            Vector3 pos = new Vector3((Mathf.Cos(duh) * radius), (Mathf.Sin(duh) * radius), 0);

            if (i != 0 && i != (linePoints - 1))
            {
                pos = new Vector3(pos.x + Random.Range(-radius / 4, radius / 4), pos.y + Random.Range(-radius / 4, radius / 4), 0);
            }

            drawPoints.Add(pos);
            polyPoints[i] = new Vector2(pos.x, pos.y);
            i++;
        }
        drawObject.SetPoints(drawPoints);
        polyCollider.points = polyPoints;
    }
开发者ID:torston,项目名称:Asteroids,代码行数:26,代码来源:Asteroid.cs


示例9: Awake

    void Awake()
    {
        lightMesh = new Mesh();
        lightMesh.name = string.Format("Light Mesh ({0})", name);
        lightMesh.MarkDynamic();

        meshFilter = GetComponent<MeshFilter>();
        meshFilter.mesh = lightMesh;

        meshRenderer = GetComponent<MeshRenderer>();
        meshRenderer.sharedMaterial = lightMaterial;

        var container = transform.Find("LightMesh");
        if (!container)
        {
            container = new GameObject("LightMesh").transform;
            container.SetParent(transform, true);
            container.localPosition = Vector3.zero;
            container.gameObject.layer = gameObject.layer;
        }

        lightMeshCollider = container.GetComponent<PolygonCollider2D>();
        if (lightMeshCollider == null)
        {
            lightMeshCollider = container.gameObject.AddComponent<PolygonCollider2D>();
        }

        lightMeshCollider.isTrigger = true;

        vertices = new List<Vertex>();

        UpdateLightFX();
    }
开发者ID:igm-capstone,项目名称:proto-03-lights,代码行数:33,代码来源:Light2D.cs


示例10: Start

 void Start()
 {
     hitbox = gameObject.AddComponent<PolygonCollider2D>();
     hitbox.isTrigger = true;
     AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Skills/Slash/slash_" + Random.Range(0,3).ToString()), gameObject.transform.position);
     StartCoroutine("playAnimation", attackSpeed);
 }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:7,代码来源:SlashLogic.cs


示例11: Awake

	// ============= GENERATION ==============
	private void Awake() {
		allPoints = new List<Point>();
		edgePoints = new List<Point>();
		finishingPoints = new List<Point>();
		polygonCollider = GetComponent<PolygonCollider2D>();
		mesh = GetComponent<TriangulatedMesh>();
	}
开发者ID:wtrebella,项目名称:Grappler,代码行数:8,代码来源:MountainChunk.cs


示例12: RebuildAllColliders

    public override void RebuildAllColliders()
    {
        UpdateCollidable();

        DestroyCollider();

        var alphaTex = destructibleSprite.AlphaTex;

        if (alphaTex != null)
        {
            var spriteRenderer = D2D_Helper.GetOrAddComponent<SpriteRenderer>(child);
            var sprite         = Sprite.Create(alphaTex, new Rect(0, 0, alphaTex.width, alphaTex.height), Vector2.zero, 1.0f, 0, SpriteMeshType.FullRect);

            spriteRenderer.sprite = sprite;

            collider = child.AddComponent<PolygonCollider2D>();

            // Disable the collider if it couldn't form any triangles
            collider.enabled = IsDefaultPolygonCollider2D(collider) == false;

            D2D_Helper.Destroy(sprite);
            D2D_Helper.Destroy(spriteRenderer);

            UpdateColliderSettings();
        }
    }
开发者ID:rickbatka,项目名称:birds,代码行数:26,代码来源:D2D_AutoSpriteCollider.cs


示例13: Start

    // Use this for initialization
    void Start()
    {

        audio = gameObject.GetComponent<AudioSource>();
        rb = GetComponent<Rigidbody2D>();
        collision = GetComponent<PolygonCollider2D>();
    }
开发者ID:dustmant27,项目名称:UnitySpaceShooter,代码行数:8,代码来源:EnemyMoveDown.cs


示例14: MakeBounds

 private void MakeBounds(PolygonCollider2D source)
 {
     if (source.renderer == null)
     {
     Vector2[] points = source.points;
     float maxX = float.NegativeInfinity;
     float maxY = float.NegativeInfinity;
     foreach (Vector2 point in points)
     {
         if (point.x > maxX)
         {
             maxX = point.x;
         }
         if (point.y > maxY)
         {
             maxY = point.y;
         }
     }
     Vector2 maxSize = new Vector2(maxX, maxY);
     Vector2 pos = source.transform.position;
     Vector2 polySize = maxSize - pos;
     MakeBounds(source.gameObject, polySize, Vector2.zero);
     }
     else
     {
     MakeBounds(source.renderer);
     }
 }
开发者ID:Jay2645,项目名称:UnityHelperFunctions,代码行数:28,代码来源:Bounds2D.cs


示例15: Reset

    void Reset()
    {

        gameObject.name = "@PolyNav2D";
        masterCollider = GetComponent<PolygonCollider2D>();
        masterCollider.isTrigger = true;
    }
开发者ID:SamuelKnox,项目名称:Project-Heist,代码行数:7,代码来源:PolyNav2D.cs


示例16: Awake

	// Use this for initialization
    protected override void Awake()
    {
        base.Awake();
		vfx = GetComponent<ParticleSystem>();
		coll = GetComponent<PolygonCollider2D>();
		effector = GetComponent<PointEffector2D>();
	}
开发者ID:AlbearKamoo,项目名称:Witches-vs-Aliens-2015-2016,代码行数:8,代码来源:PushAbilityCone.cs


示例17: Start

 void Start()
 {
     // Create a polygon collider
     localCollider = gameObject.AddComponent<PolygonCollider2D>();
     localCollider.isTrigger = true; // Set as a trigger so it doesn't collide with our environment
     localCollider.pathCount = 0; // Clear auto-generated polygons
 }
开发者ID:DemoProductions,项目名称:fighter,代码行数:7,代码来源:ColliderManager.cs


示例18: Start

	// Use this for initialization
	void Start () {
        this.currentState = "Square"; // Game starts with Square
        this.animator = this.GetComponent<Animator>();
        this.currentDirection = 1; // 1 for RIGHT / -1 for LEFT

        this.world = GameObject.Find("World");
        this.isStucked = false;
        this.isControllerLocked = false;

        //Initialize the sounds
        /*this.fitTargetSound = this.audioPrefab.transform.GetChild(0).GetComponent<AudioSource>();
        this.dieSound = this.audioPrefab.transform.GetChild(1).GetComponent<AudioSource>();
        this.landscapeSound = this.audioPrefab.transform.GetChild(2).GetComponent<AudioSource>();
        this.changeSound = this.audioPrefab.transform.GetChild(3).GetComponent<AudioSource>();
        this.bounceSound = this.audioPrefab.transform.GetChild(4).GetComponent<AudioSource>();
        */
        //Grab the colliders
        this.SquareCollider = this.GetComponent<BoxCollider2D>();
        this.CircleCollider = this.GetComponent<CircleCollider2D>();
        this.TriangleCollider = this.GetComponent<PolygonCollider2D>();

        //Grab the Rigidbody
        this.rigidBody = this.GetComponent<Rigidbody2D>();
        this.setRigidbody();
	}
开发者ID:erdiizgi,项目名称:SwappieNew,代码行数:26,代码来源:PlayerController.cs


示例19: Awake

    void Awake()
    {
        rigidbody = GetComponent<Rigidbody2D>();
        body = GetComponent<PolygonCollider2D>();
        feet = GetComponent<CircleCollider2D>();
        health = GetComponent<Health>();
        standing = body.points;
        crouched = new Vector2[standing.Length];
        grounded = false;
        onWall = false;
        upSlope = false;
        downSlope = false;

        int min = 0;
        for (int i = 0; i < standing.Length; i++)
        {
            if (standing[i].y < standing[min].y)
                min = i;
        }
        for (int i = 0; i < standing.Length; i++)
        {
            float newY = (standing[i].y - standing[min].y) * 0.5f + standing[min].y;
            crouched[i] = new Vector2(standing[i].x, newY);
        }
    }
开发者ID:pueblak,项目名称:ProjectDarkZone,代码行数:25,代码来源:PlayerController.cs


示例20: Start

 void Start()
 {
     Debug.Log("Started");
     gameObject.AddComponent<LineRenderer>();
     classpc = gameObject.AddComponent<PolygonCollider2D>();
     classpc.SetPath(0, new Vector2[] { });
     //classpc.SetPath(1, new Vector2[] { });
 }
开发者ID:Ghust1995,项目名称:inkrunner,代码行数:8,代码来源:TouchTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.ProceduralMaterial类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Plane类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap