Application.CaptureScreenshot doesn't work for Tizen

hi, my names Nando… i have question about Application.CaptureScreenshot… is that works for Tizen?
because i have made a script like in this : [TIZEN] Application.CaptureScreenshot doesnt work - Questions & Answers - Unity Discussions

but it just work for windows or in unity editor… and doesnt work for Tizen. may all of you have solved this problem before? thanks

I’m looking this issue.

The captured screenshot is stored under Application.temporaryCachePath in Tizen.
You can copy it to the other path where you want.
This is a sample code to save the captured file under ‘Downloads’ folder.
(You should enable MediaStorage in PlayerSettings->Capabilities to copy a file to Downloads folder.)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;

public class ScreenCapture : MonoBehaviour {

    public void CaptureIt()
    {
        Application.CaptureScreenshot("MyCapture.png");
        System.IO.File.Copy(Path.Combine(Application.temporaryCachePath, "MyCapture.png"), "/opt/usr/media/Downloads/MyTest.png", true);
    }
}
1 Like

btw, actually i can

wow thankyou so much… :smile:

hi after i try thats code, actually thats work for capture the game, but the result capture is just go to “/opt/usr/media/Downloads/MyTest.png” but i cant see the image on gallery… and after i restart my phone the capture image is available on gallery… but if i open my game and doing screencapture again the last capture is doesnt see on gallery and i must restart my phone to do that… have you try? thankyou…

Thanks everyone!

@nandonandito

Please use Tizen Plugin for updating contents.

bool
tizenupdatecontent(const char *img_path)
{
    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", img_path);
    int ret = media_content_connect();
    if (ret != MEDIA_CONTENT_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "media_content_connect() error %p", ret);
    }

    ret = media_content_scan_file(img_path);
    if (ret != MEDIA_CONTENT_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "media_content_scan_file() error %p", ret);
    }

    ret = media_content_disconnect();
    if (ret != MEDIA_CONTENT_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "media_content_disconnect() error %p", ret);
    }

    return true;
}
public class NewBehaviourScript : MonoBehaviour {
#if !UNITY_EDITOR && UNITY_TIZEN
    [DllImport ("updatecontent")]
    private static extern bool tizenupdatecontent(string img_path);
#endif

    // Use this for initialization
    void Start () {
 
    }
 
    // Update is called once per frame
    void Update () {


        if (Input.GetKey(KeyCode.Menu))
        {
            Application.CaptureScreenshot("MyCapture.png");
#if !UNITY_EDITOR && UNITY_TIZEN
            System.IO.File.Copy(Path.Combine(Application.temporaryCachePath, "MyCapture.png"), "/opt/usr/media/DCIM/MyTest.png", true);
            tizenupdatecontent("/opt/usr/media/DCIM/MyTest.png");
#endif
        }
}
}

please find the file on /Debug/libupdatecontent.so.

3080136–231910–updatecontent.zip (19 KB)

1 Like

@sukwon-suh where can i get updatecontent dll files? after extract your updatecontent.zip and i just see on the folder src updatecontent.c

i try to copied updatecontent.c to assets/Plugins/Tizen/libs its still doesnt work. or i must go to Tizen Studio to open that? and build .so plugin?

i see the manuel at : https://docs.unity3d.com/Manual/PluginsForTizen.html
but i don’t really know how to do that at tizen ide/studio

@nandonandito
I updated updatecontent.zip.
please find the file on /Debug/libupdatecontent.so.

@sukwon-suh i use this to call but still get error if i try to build the project “The type or namespace name `DllImport’ could not be found. Are you missing an assembly reference?”

public class NewBehaviourScript : MonoBehaviour {
#if !UNITY_EDITOR && UNITY_TIZEN
    [DllImport ("updatecontent")]
    private static extern bool tizenupdatecontent(string img_path);
#endif
    // Use this for initialization
    void Start () {
    }
    // Update is called once per frame
    void Update () {
        if (Input.GetKey(KeyCode.Menu))
        {
            Application.CaptureScreenshot("MyCapture.png");
#if !UNITY_EDITOR && UNITY_TIZEN
            System.IO.File.Copy(Path.Combine(Application.temporaryCachePath, "MyCapture.png"), "/opt/usr/media/DCIM/MyTest.png", true);
            tizenupdatecontent("/opt/usr/media/DCIM/MyTest.png");
#endif
        }
}
}

@nandonandito
Did you test it on real device?

yes @sukwon-suh , i try to build and run but error “The type or namespace name `DllImport’ could not be found. Are you missing an assembly reference?”

where the place you copied the libupdatecontent.so ? is on just at “assets” or “assets/plugins/tizen/libs” ? and is you are using [DllImport (“updatecontent”)] or [DllImport (“libupdatecontent”)] ?


this is the screenshot of the error i get @sukwon-suh

I used assets folder.

\

and use like this.
[DllImport (“updatecontent”)]

please find attached cs file.

3080542–231915–NewBehaviourScript.cs (849 Bytes)

1 Like

Would you please check UNITY version?
I tested it on Unity 5.6.1f1. (this is the latest)

thankyou so much @sukwon-suh the plugin is work without error, but the screenshot is still doesn’t available if we need to see on gallery… the screenshot is available on “/opt/usr/media/DCIM” folder but at gallery it doesn’t… i use Tizen Z1 and Z2 to test this. the screenshot will available on gallery if i restart my phone…

@sukwon-suh i use Unity 5.6.0p1, is i must update my unity?

@nandonandito
oops… you didn’t use name space on the c# script.
please add this.
using System.Runtime.InteropServices;

ya… i forgot the namespace, but after i use the namespace and test it again, it still doesn’t see the screenshot on gallery, but this just work if i find at folder… i will make the video how its looks like

@sukwon-suh this the video, that i hope can more easier to explain, btw sorry about my english is not really good :slight_smile: