app名称本地化自适应;分享图片接入
This commit is contained in:
1 parent
cbd1ce3313
commit
625e2b7934
66 files changed
+7772
-342
No files matched your search
@@ -880,8 +880,11 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
}
|
||||
|
||||
protected void CaptureCamera(Camera camera, Rect rect,string fileName)
|
||||
public byte[] CaptureCamera()
|
||||
{
|
||||
return CaptureCameraReturnByte(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f));
|
||||
}
|
||||
private byte[] CaptureCameraReturnByte(Camera camera, Rect rect)
|
||||
{
|
||||
// 创建一个RenderTexture对象
|
||||
RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);
|
||||
@@ -905,8 +908,11 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
RenderTexture.active = null; // JC: added to avoid errors
|
||||
GameObject.Destroy(rt);
|
||||
// 最后将这些纹理数据,成一个图片文件
|
||||
byte[] bytes = screenShot.EncodeToJPG();
|
||||
|
||||
return screenShot.EncodeToJPG();
|
||||
}
|
||||
protected void CaptureCamera(Camera camera, Rect rect,string fileName)
|
||||
{
|
||||
byte[] bytes = CaptureCameraReturnByte(camera, rect);
|
||||
//var path = Helper.GetDataDir("MapWorkoutRecords/images");
|
||||
//string filename = path + "/" + Guid.NewGuid().ToString() + ".png";
|
||||
System.IO.File.WriteAllBytes(fileName, bytes);
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
#region 功能按钮
|
||||
GameObject goResultBtn;
|
||||
GameObject cancelBtn;
|
||||
GameObject shareWxBtn;
|
||||
#endregion
|
||||
|
||||
CyclingController cyclingController;
|
||||
@@ -67,6 +68,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
#endregion
|
||||
goResultBtn = transform.Find("ConFirmButton").gameObject;
|
||||
cancelBtn = transform.Find("CloseButton").gameObject;
|
||||
shareWxBtn = transform.Find("ToolBarPanel/WeChatButton").gameObject;
|
||||
|
||||
}
|
||||
|
||||
public void InjectController(CyclingController controller)
|
||||
@@ -74,7 +77,15 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
cyclingController = controller;
|
||||
cyclingController.AddEvent(goResultBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, GoResult);
|
||||
cyclingController.AddEvent(cancelBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Cancel);
|
||||
cyclingController.AddEvent(shareWxBtn, EventTriggerType.PointerClick, shareToWx);
|
||||
}
|
||||
|
||||
private void shareToWx(BaseEventData b)
|
||||
{
|
||||
var bs = cyclingController.CaptureCamera();
|
||||
WeChatController.Instance.ShareImageToWX(0, bs);
|
||||
}
|
||||
|
||||
private void GoResult(BaseEventData baseEventData)
|
||||
{
|
||||
if (App.MainSceneParam.ContainsKey("Name"))
|
||||
|
||||
Reference in new issue
Block a user