示例#1
0
        void DrawTexture(ImageData srcImage, Rect srcRect, Rect targetRect, DaggerfallUnityItem item = null)
        {
            // Calculate image position relative to origin
            int posX = (int)targetRect.xMin - paperDollOrigin.X;
            int posY = (int)targetRect.yMin - paperDollOrigin.Y;

            // Scale to paper doll render texture
            float scaleX = target.width / (float)paperDollWidth;
            float scaleY = target.height / (float)paperDollHeight;

            // Get target rect
            Rect screenRect = new Rect(
                posX * scaleX,
                posY * scaleY,
                targetRect.width * scaleX,
                targetRect.height * scaleY);

            // Allow for some adjustment so artist can finetune how their new item images should be positioned.
            TextureReplacement.OverridePaperdollItemRect(item, srcImage, scale, ref screenRect);

            // Draw with custom shader for paper doll item masking
            if (item != null)
            {
                paperDollMaterial.SetTexture("_MaskTex", srcImage.maskTexture);
                Graphics.DrawTexture(screenRect, srcImage.texture, srcRect, 0, 0, 0, 0, paperDollMaterial);
            }
            else
            {
                Graphics.DrawTexture(screenRect, srcImage.texture, srcRect, 0, 0, 0, 0);
            }

            // Store layout element for mouse picking
            if (item != null)
            {
                ItemElement element = new ItemElement();
                element.item    = item;
                element.rect    = screenRect;
                element.texture = srcImage.texture;
                itemLayout.Add(element);
            }
        }