예제 #1
0
    private bool WriteDataToJPG(Texture2D texture, SScreenShotImgInfo imgInfo, string filePath)
    {
        if (filePath == "")
        {
            return(false);
        }

        //类型byte数组
        byte[] typeBytes = ImageExtensions.StructToBytes(imgInfo);

        //压缩Jpg文件Byte数组
        byte[] imgBytes = texture.EncodeToJPG();

        ImageExtensions.AppendDataToJPG(filePath, imgBytes, typeBytes);

        return(true);
    }
예제 #2
0
    /// <summary>
    /// 截取屏幕图像
    /// </summary>
    /// <param name="_type">截图类型</param>
    public void CaptureScreenImage(SScreenShotImgInfo imgInfo)
    {
        if (!bCaptureFinish)
        {
            return;
        }

        if (!Directory.Exists(LogicDataCenter.screenCaptureDataManager.ImgFolderFullPath))
        {
            return;
        }

        StopAllCoroutines();

        if (imgInfo.screenShotType == EMScreenShotType.EMSS_RemoveUI)
        {
            USpeedUI.UISystem.Instance.GetCamera().gameObject.SetActive(false);
        }

        StartCoroutine(CaptureScreenImg(imgInfo));
    }
예제 #3
0
    IEnumerator CaptureScreenImg(SScreenShotImgInfo imgInfo)
    {
        bCaptureFinish = false;

        yield return(new WaitForEndOfFrame());

        Texture2D screenShot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);

        screenShot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        screenShot.Apply();

        if (imgInfo.screenShotType == EMScreenShotType.EMSS_RemoveUI)
        {
            USpeedUI.UISystem.Instance.GetCamera().gameObject.SetActive(true);
        }

        string filePath = GetFilePath();

        WriteDataToJPG(screenShot, imgInfo, filePath);
        warImgCount++;
        ResNode.DestroyRes(ref screenShot);
        bCaptureFinish = true;
    }