1
사진을 찍어 기념비 같은 다른 배경으로 배치하는 프로그램을 만들려고합니다. 지금까지, 나는 항상 모든 검은 끝 때문에 스크린 샷 또는 사진을 찍을 수 없다, 내가화음으로 사진 찍기 C#
webcamTexture = new WebCamTexture();
rawImage.texture = webcamTexture;
rawImage.material.mainTexture = webcamTexture;
webcamTexture.Play();
Texture2D PhotoTaken = new Texture2D (webcamTexture.width, webcamTexture.height);
PhotoTaken.SetPixels (webcamTexture.GetPixels());
PhotoTaken.Apply();
그러나이 코드로 프로젝트를 시작할 때 카메라를 회전 할 수 있었다. 다른 코드를 시도했지만 아무 것도 작동하지 않습니다. 누군가 제발 도와 줄 수 있니? 일부 시도 후 감사
편집
, 이것은 내가 가지고있는 코드 :
WebCamTexture webcamTexture;
public RawImage rawImage;
void Start() {
webcamTexture = new WebCamTexture();
rawImage.texture = webcamTexture;
rawImage.material.mainTexture = webcamTexture;
webcamTexture.Play();
RenderTexture texture= new RenderTexture(webcamTexture.width, webcamTexture.height,0);
Graphics.Blit(webcamTexture, texture);
Button btn = yourButton.GetComponent<Button>();
btn.onClick.AddListener(OnClick);
}
public IEnumerator Coroutine(){
yield return new WaitForEndOfFrame();
}
public void OnClick() {
var width = 767;
var height = 575;
Texture2D texture = new Texture2D(width, height);
texture.ReadPixels(new Rect(0, 0, width, height), 0, 0);
texture.Apply();
// Encode texture into PNG
var bytes = texture.EncodeToPNG();
//Destroy(texture);
File.WriteAllBytes (Application.dataPath + "/../SavedScreen.png", bytes);
}
및
이 다음 코드로 스크린 샷을 촬영하지만, 모든 일의 사진을 소요, 그리고 화면 조금. 당신은Unity
Application.CaptureScreenshot("Screenshot.png");
EDIT 1
이 같은 화면을 캡처 할 수
내가 전체 화면의 스크린 샷에 표시하지 않으려면? 한 부분 만 – Dmgm
정말 바보 같아서 미안하지만, 정말이에요. 그러나 그것은 효과가 없습니다. Rect 부분에 오류가 있으며 많은 os가 시도한 후에 무엇을해야할지 모르겠습니다. – Dmgm
시도한 코드로 질문을 업데이트 할 수 있습니까? – Hristo