private string GetKeyName()
        {
            Vector2Int imageSliceCoord = LDtkToolOriginCoordConverter.ImageSliceCoord(_srcPos, _srcTex.height, _pixelsPerUnit);
            string     key             = LDtkKeyFormatUtil.TilesetKeyFormat(_srcTex, imageSliceCoord);

            return(key);
        }
示例#2
0
        public Sprite CreateSpriteSliceForPosition(Vector2Int ldtkPos)
        {
            Vector2Int realPos = LDtkToolOriginCoordConverter.ImageSliceCoord(ldtkPos, _texture.height, _gridSize);

            Rect srcRect = new Rect(realPos, Vector2.one * _gridSize);

            Vector2 pivot = Vector2.one * 0.5f;

            if (!IsLegalSpriteSlice(_texture, srcRect))
            {
                Debug.LogError($"Illegal sprite slice: {srcRect}, Is the pixels per unit value set too big?");
                return(null);
            }

            Sprite sprite = Sprite.Create(_texture, srcRect, pivot, _gridSize);

            return(sprite);
        }