Ejemplo n.º 1
0
    private IEnumerator UploadPhoto(winPhotoGallery gallery, Texture2D texture)
    {
        // Encode texture into PNG
        var bytes = texture.EncodeToPNG();

        // Create a Web Form
        var form = new WWWForm();

        var sessionId = Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor ? "7946428e3ffe6c62549ab6642a42d6be" : this.sessionId;

        Debug.Log("Upload capture with session: " + sessionId);

        form.AddField("session_id", sessionId);
        form.AddBinaryData("picture", bytes, "screenshot.png", "image/png");

        WWW www = new WWW(PopBloopSettings.PhotoUploadUrl, form);
        yield return www;

        if (www.error != null)
        {
            Debug.LogError(www.error);
        }
        else
        {
            if (www.text.Contains("ERROR"))
            {
                Debug.LogWarning("Capture failed!");
            }
            else
            {
                string url = PopBloopSettings.PhotoUploadShareAlbumToFacebookUrl;
                url = url.Replace("www.", "");

                Debug.Log(string.Format("Share with Facebook: {0}", url));

                www = new WWW(url);

                yield return www;

                if (www.error != null)
                {
                    Debug.LogError("Share Upload photo facebook failed: " + www.error);
                }
                else
                {
                    Debug.Log("Uploaded photo shared to facebook with message: " + www.text);
                }

                /*// Now we get our latest uploaded filename
                Debug.Log("Get Uploaded capture filename on Server: " + PopBloopSettings.PhotoUploadLatestFilenameUrl);

                www = new WWW(PopBloopSettings.PhotoUploadLatestFilenameUrl);

                yield return www;

                if (www.error != null)
                {
                    Debug.LogError(www.error);
                }
                else
                {
                    string latestFilenameOnServer = www.text;

                    if (latestFilenameOnServer.Trim() != null)
                    {
                    }
                }*/
            }
        }

        gallery.FinishUpload();
        /*
        // Encode texture into PNG
        var bytes = texture.EncodeToPNG();

        // Create a Web Form
        var form = new WWWForm();

        var session = Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor ? "7946428e3ffe6c62549ab6642a42d6be" : this.sessionId;

        Debug.Log("Upload capture with session: " + session);

        form.AddField("session_id", session);
        form.AddBinaryData("picture", bytes, "screenshot.png", "image/png");

        WWW www = new WWW(PopBloopSettings.PhotoUploadUrl, form);
        yield return www;

        if (www.error != null)
        {
            Debug.LogError(www.error);
        }
        else
        {
            if (www.text.Contains("ERROR"))
            {
                Debug.LogWarning("Capture failed!");
            }
            else
            {
                Debug.Log("Captured");
            }
        }

        gallery.FinishUpload();*/
    }
Ejemplo n.º 2
0
    public static winPhotoGallery CreatePhotoGallery(string title, Texture2D texture)
    {
        winPhotoGallery gallery = null;
        if (Windows.ContainsKey(title))
        {
            gallery = (winPhotoGallery)Windows[title];
            gallery.Initialize(texture);
            gallery.Show();
        }
        else
        {
            gallery = new winPhotoGallery(title, title, texture);

            Windows.Add(title, gallery);
        }

        return gallery;
    }
Ejemplo n.º 3
0
 void OnGuiUploadPhoto(winPhotoGallery gallery, Texture2D texture)
 {
     StartCoroutine(UploadPhoto(gallery, texture));
 }