Пример #1
0
        public void Awake()
        {
            int       w  = texture.width;
            int       h  = texture.height;
            BitMatrix bm = new BitMatrix(w, h);

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    bm.Set(x, y, (texture.GetPixel(x, y).a >= 0.5f));
                }
            }
            this.polygons        = Polygonizer.Polygonize(bm);
            this.polygonCollider = GetComponent <PolygonCollider2D>();

            foreach (List <IntPoint> li in this.polygons)
            {
                for (int i = 0; i < li.Count; i++)
                {
                    li[i] = new IntPoint(li[i].X * MAP_SCALE_INV, li[i].Y * MAP_SCALE_INV);
                }
            }

            dirty = true;
        }