コード例 #1
0
    private void GetIntersection()
    {
        Vector2[] subjectPoints = PolygonTools.FixTransformBias(toCheck.polygon.points, toCheck.polygon.transform);
        Vector2[] cutPoints     = PolygonTools.FixTransformBias(checker.polygon.points, checker.polygon.transform);

        _polyIntersections = PolygonTools.Clip(subjectPoints, cutPoints, ClipType.Intersection);

        for (int i = 0; i < _polyIntersections.Count; i++)
        {
            if (_currentIntersections.Count - 1 < i)
            {
                _currentIntersections.Add(Instantiate(intersectionTemplate));
            }

            _currentIntersections[i].polygon.points = _polyIntersections[i];
            _currentIntersections[i].gameObject.SetActive(true);
        }

        for (int i = _polyIntersections.Count; i < _currentIntersections.Count; i++)
        {
            _currentIntersections[i].gameObject.SetActive(false);
        }
    }