Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
4
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System;

public class SendData : MonoBehaviour
{
    public GameObject panel;
    public void PostData()
    {

        
        contact.email = GameObject.FindWithTag("inputMail").GetComponent<InputField>().text;
        contact.attributes = new Attributes(); // JE SAIS PAS SI BESOIN
        contact.attributes.nom = GameObject.FindWithTag("inputName").GetComponent<InputField>().text;

            StartCoroutine(onResponse(request));

        panel = GameObject.FindWithTag("panelTag");
        panel.gameObject.SetActive(false);

        IEnumerator naze = TakeScreenAndShare();
    }

    private IEnumerator TakeScreenAndShare()
    {
        yield return new WaitForEndOfFrame();

        Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        ss.Apply();

        string filePath = System.IO.Path.Combine(Application.temporaryCachePath, "cerealis.png");
        System.IO.File.WriteAllBytes(filePath, ss.EncodeToPNG());

        Destroy(ss);

        new NativeShare().AddFile(filePath)
                .SetSubject("").SetText("").SetUrl("")
                .SetCallback((res, target) => Debug.Log($"result {res}, target app: {target}"))
                .Share();
    }

}

[Serializable]
internal class Contact
{
    public string email;
    public Attributes attributes;
    //public bool Update;
}

[Serializable]
internal class Attributes
{
    public string nom;
}