赞
踩
1.首先创建一个UI摄像机,并调整好Layer层,遮罩层之类的,拼拼界面。
2.制作成预制体。(代码中的路径可能需要改)加载的地方改下Resource.Load();
3.先点字一个GUIBUtton,再点第二个才会好使。
下面给出代码自己看看吧,嘿嘿:
- using UnityEngine;
- using System.Collections;
- using System.IO;
-
- public class GameUISharePopUp : MonoBehaviour
- {
-
- private string imagePath = "";
- void OnGUI()
- {
- if (GUI.Button(new Rect(10, 10, 200, 20), "first capture"))
- {
-
- StartCoroutine(GenerateShareScreenshot());
- }
- if (GUI.Button(new Rect(10, 30, 200, 20),"cut"))
- {
- string fileName = Application.persistentDataPath+"wwb";
- Texture2D shareBgImg = LoadImageFromBytes(File.ReadAllBytes(fileName));
- if (shareBgImg == null)
- {
- Debug.LogErrorFormat("Can not load Screenshot Image {0}.", fileName);
- return;
- }
- StartCoroutine(GenerateShareImage("www", "hahaha", shareBgImg));
- }
- }
- private IEnumerator GenerateShareScreenshot()
- {
- string fileName = Application.persistentDataPath + "wwb";
- Debug.Log("fileName= "+fileName);
- if (File.Exists(fileName))
- File.Delete(fileName);
- yield
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。