Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Take screenshot and apply it as a texture

Discussion in 'Scripting' started by QuackedUp, Jun 18, 2021.

  1. QuackedUp

    QuackedUp

    Joined:
    May 3, 2021
    Posts:
    10
    Hello, i have a problem where i take a screeshot inside a folder and would like to use it as a texture in a canvas, picture, but i have no idea how. Heres how i take the screenshot.
    Code (CSharp):
    1.         ScreenCapture.CaptureScreenshot(Application.dataPath + "/screenshots/" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".png");
    2.         UnityEditor.AssetDatabase.Refresh();
    and would also like to delete these screenshots after pressing a button. Thanks in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    Do you mean at editor time or at runtime? Line 2 will not work anywhere except inside the Unity editor.
     
    jtok4j likes this.
  3. QuackedUp

    QuackedUp

    Joined:
    May 3, 2021
    Posts:
    10
    In runtime. When the game starts i want to take a screenshot and use it as a texture. But when i start it again and take a screenahot, i want to use that screenshot.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
  5. QuackedUp

    QuackedUp

    Joined:
    May 3, 2021
    Posts:
    10
    Didnt knew about this, thanks
     
    Kurt-Dekker likes this.