Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SocialSharing : MonoBehaviour
- {
- Texture2D screenshot;
- public Canvas canvas;
- public ScreensManager nav;
- string status = "Я играю в викторину \"Саша Спилберг\".\nПомогите ответить на вопрос!";
- string statusEN = "I am playing the \"New District\" game.\nPlease help me to answer this question!";
- public IEnumerator TakeScreenshot()
- {
- yield return new WaitForEndOfFrame();
- int width = Screen.width;
- int height = Screen.height;
- canvas.renderMode = RenderMode.ScreenSpaceCamera;
- RenderTexture rt = new RenderTexture(width, height, 24);
- Camera.main.targetTexture = rt;
- screenshot = new Texture2D(width, height, TextureFormat.RGB24, false);
- Camera.main.Render();
- RenderTexture.active = rt;
- screenshot.ReadPixels(new Rect(0, 0, width, height), 0, 0);
- screenshot.Apply();
- Camera.main.targetTexture = null;
- RenderTexture.active = null;
- Destroy(rt);
- canvas.renderMode = RenderMode.ScreenSpaceOverlay;
- }
- void ShowQuestionPage()
- {
- //спрячем 2 страницы, закрывающие страницу вопросов
- nav.askFriendsPage.SetActive(false);
- nav.hintPage.SetActive(false);
- }
- public void InstagramShare()
- {
- ShowQuestionPage();
- StartCoroutine(TakeScreenshot());
- UM_ShareUtility.InstagramShare(status, screenshot);
- Debug.Log("Отправка в Instagram");
- }
- public void FacebookShare()
- {
- ShowQuestionPage();
- StartCoroutine(TakeScreenshot());
- UM_ShareUtility.FacebookShare(status, screenshot);
- Debug.Log("Отправка в Facebook");
- //Debug.Log("Share to Facebook");
- }
- public void TwitterShare()
- {
- ShowQuestionPage();
- StartCoroutine(TakeScreenshot());
- UM_ShareUtility.TwitterShare(status, screenshot);
- Debug.Log("Отправка в Twitter");
- }
- public void ShareMedia()
- {
- ShowQuestionPage();
- StartCoroutine(TakeScreenshot());
- UM_ShareUtility.ShareMedia("Sasha Spilberg Celebrity Quiz", status, screenshot);
- Debug.Log("Поделиться");
- }
- public void VKShare()
- {
- //нужен плагин
- Debug.LogError("Не реализована шарилка для VK", transform);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement