public static Texture2D ImportFromZip(this ZipArchive package, string name, ImageNames type)
        {
            ImageNames.Result result = type.FindInPackage(name, package);

            if (result == null)
            {
                return(null);
            }

            string originalName = result.entry.Name;
            string extension    = originalName.Substring(originalName.LastIndexOf("."));

            Texture2D texture = new Texture2D(2, 2);

            if (type == ImageNames.Albedo)
            {
                texture.alphaIsTransparency = true;
            }
            texture.LoadImage(result.entry.Open().ReadFully());
            if (result.shouldInvert)
            {
                texture = texture.Inverted();
            }
            texture.Apply();

            return(texture.ToAsset($"Textures/{name}/{name}_{type.canonicalName}{extension}", type.importType));
        }
예제 #2
0
        /// <summary>
        /// sets up the draw rectangle for the images specified.
        /// </summary>
        /// <param name="imageID">Index of the texture to set up.</param>
        private void CreateDrawSpace(ImageNames imageID)
        {
            switch (imageID)
            {
            case ImageNames.TitleBar:
            {
                Texture2D titleTexture = (Texture2D)GetTexture(images[(int)imageID]);
                imageDrawSpaces[(int)imageID] = new Rectangle(0, 0, (int)sizePixel.Width, titleTexture.Height);
                break;
            }

            case ImageNames.Background:
            {
                imageDrawSpaces[(int)imageID] = new Rectangle(0, 0, (int)sizePixel.Width, (int)sizePixel.Height);
                break;
            }

            case ImageNames.Bottom:
            {
                Texture2D bottomTexture = (Texture2D)GetTexture(images[(int)imageID]);
                imageDrawSpaces[(int)imageID] = new Rectangle(0, (int)sizePixel.Height - bottomTexture.Height,
                                                              (int)sizePixel.Width, bottomTexture.Height);
                break;
            }

            case ImageNames.Left:
            {
                Texture2D leftTexture = (Texture2D)GetTexture(images[(int)imageID]);
                imageDrawSpaces[(int)imageID] = new Rectangle(0, 0, leftTexture.Width, (int)sizePixel.Height);
                break;
            }

            case ImageNames.Right:
            {
                Texture2D rightTextutre = (Texture2D)GetTexture(images[(int)imageID]);
                imageDrawSpaces[(int)imageID] = new Rectangle((int)sizePixel.Width - rightTextutre.Width,
                                                              0, rightTextutre.Width, (int)sizePixel.Height);
                break;
            }
            }
        }