상속: MonoBehaviour
예제 #1
0
    public void Init(FContainer container, uint color, bool shouldUpdateColliders)
    {
        _container = container;

        _container.AddChild(_drawHolder = new FContainer());

        _color = RXUtils.GetColorFromHex(color);

        this.shouldUpdateColliders = shouldUpdateColliders;

        Collider[] colliders = gameObject.GetComponents <Collider>();

        int colliderCount = colliders.Length;

        for (int c = 0; c < colliderCount; c++)
        {
            Collider collider = colliders[c];

            FNode newNode = null;

            if (collider is BoxCollider)
            {
                FSprite sprite = new FSprite("Debug/Square");
                sprite.color = _color;

                newNode = sprite;
            }
            else if (collider is SphereCollider)
            {
                FSprite sprite = new FSprite("Debug/Circle");
                sprite.color = _color;

                newNode = sprite;
            }

            if (newNode != null)
            {
                _drawHolder.AddChild(newNode);
                _nodes.Add(newNode);
            }
        }

        FPPolygonalCollider mesh2D = gameObject.GetComponent <FPPolygonalCollider>();

        if (mesh2D != null)
        {
            FPDebugPolygonColliderView debugView = new FPDebugPolygonColliderView("Debug/Triangle", mesh2D);
            debugView.color = _color;

            _drawHolder.AddChild(debugView);
            _nodes.Add(debugView);
        }

        Update();
        if (!shouldUpdateColliders)
        {
            UpdateColliders();                                //always update the colliders the first time
        }
    }
    public FPPolygonalCollider AddPolygonalCollider(Vector2[] vertices, bool withDebugView = false)
    {
        FPPolygonalCollider fp = gameObject.AddComponent <FPPolygonalCollider>();

        fp.Init(new FPPolygonalData(vertices, false));

        if (withDebugView)
        {
            FPDebugRenderer.Create(gameObject, Futile.stage, 0x00FF00, false);
        }

        return(fp);
    }
    public FPDebugPolygonColliderView(string elementName, FPPolygonalCollider mesh2D)
    {
        _mesh2D = mesh2D;

        List<int[]> trianglePolygons = _mesh2D.polygonalData.trianglePolygons;

        int polyCount = trianglePolygons.Count;

        _triangleCount = 0;

        for(int p = 0; p<polyCount; p++)
        {
            _triangleCount += trianglePolygons[p].Length / 3;
        }

        Init(FFacetType.Triangle, Futile.atlasManager.GetElementWithName(elementName),_triangleCount);

        _isAlphaDirty = true;

        UpdateLocalVertices();
    }
예제 #4
0
	public FPDebugPolygonColliderView (string elementName, FPPolygonalCollider mesh2D)
	{
		_mesh2D = mesh2D;
		
		List<int[]> trianglePolygons = _mesh2D.polygonalData.trianglePolygons;
		
		int polyCount = trianglePolygons.Count;
		
		_triangleCount = 0;
		
		for(int p = 0; p<polyCount; p++)
		{
			_triangleCount += trianglePolygons[p].Length / 3;	
		}
		
		Init(FFacetType.Triangle, Futile.atlasManager.GetElementWithName(elementName),_triangleCount);
		
		_isAlphaDirty = true;
		
		UpdateLocalVertices();
	}