Watermark · yBW7X5V1A
function main()
    --Get the canvas object
    local canvas = CS.UnityEngine.GameObject.Find("/Canvas");
    --Create a new watermark object
    local watermark = CS.UnityEngine.GameObject("Watermark");
    --Add a image component to the watermark
    local watermark_img = watermark:AddComponent(typeof(CS.UnityEngine.UI.Image));
    --Create a new texture from png
    local tex = CS.UnityEngine.Texture2D(1920, 1080);
    local tex_bytes = CS.System.IO.File.ReadAllBytes("D:\\watermark.png");
    CS.UnityEngine.ImageConversion.LoadImage(tex, tex_bytes);
    --Set watermark's texture from a file
    watermark_img.sprite = CS.UnityEngine.Sprite.Create(tex, CS.UnityEngine.Rect(0, 0, 1920, 1080), CS.UnityEngine.Vector2(0.5, 0.5));
    --Set the parent of the watermark to the canvas
    watermark.transform:SetParent(canvas.transform);
    watermark.transform.localScale = CS.UnityEngine.Vector3(15.3601, 8.72, 90)
end
  • 5

    6/19/2022, 9:57:51 PM