/// <summary> /// 把图片拍摄到内存中 /// </summary> /// <param name="callback">回调函数</param> public override void PhotographMemory(SCameraPhotographMemoryCallBack callback) { if (m_flashType == SCameraFlashType.OPEN) { m_cameraDeviceBehaviour.Device.SetFlashTorchMode(true); } SCameraManager.instance.StartCoroutine(PhotographMemory2(callback)); }
private IEnumerator PhotographMemory2(SCameraPhotographMemoryCallBack callback) { if (m_flashType == SCameraFlashType.OPEN) { yield return(new WaitForSeconds(0.5f)); } // 先创建一个的空纹理,大小可根据实现需要来设置 Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); // 读取屏幕像素信息并存储为纹理数据, texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); texture.Apply(); callback(true, texture); yield return(new WaitForSeconds(0.5f)); m_cameraDeviceBehaviour.Device.SetFlashTorchMode(false); }
/// <summary> /// 把图片拍摄到内存中 /// </summary> /// <param name="callback">回调函数</param> public abstract void PhotographMemory(SCameraPhotographMemoryCallBack callback);