Unity_Vuforia_AR_实现手机端屏幕截图功能(不带UI界面)

关键代码如下:

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;

public class ScreenShot : MonoBehaviour {

    public Camera ARCamera;

	// Use this for initialization
	void Start () {
        ARCamera = GameObject.Find("ARCamera").GetComponent<Camera>();

    }
	
	// Update is called once per frame
	void Update () {
		
	}

    //单机截屏
    public void OnScreenShotClick() {
        //获取当前时间
       System.DateTime now = System.DateTime.Now;
       string nowTime = now.ToString();
       nowTime = nowTime.Trim();
       nowTime = nowTime.Replace("/","-");
        //创建并获取 截图的图片名称
       string fileName = "ARScreenShot" + nowTime + ".png";
        //如果运行的设备是Android 就截图
        if (Application.platform == RuntimePlatform.Android)
        {
            //包含UI的截图

            创建2D图片
            参数一 图片宽度
            参数二 图片高度
            参数三 图片格式
            参数四 是否映射
            //Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
            读取图片
            参数一 要读取的视图的矩形区域。从当前渲染目标读取像素。
            参数二 从哪里开始读取
            参数三 从哪里结束
            //texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
            调用Apply截屏 成功
            //textu
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值