T
T
tessariman2016-06-14 15:28:48
MySQL
tessariman, 2016-06-14 15:28:48

How to implement shooting from the object's camera with subsequent saving of these pictures in a separate folder?

It is necessary to implement an imitation of the flight of a UAV surveying the area

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aleksey Ratnikov, 2015-10-27
@mahoho

Make two requests in a transaction, this will be the most reliable.

D
Daniil Basmanov, 2016-06-14
@tessariman

This is done via RenderTexture , Camera.targetTexture and Texture2D.EncodeToJPG or Texture2D.EncodeToPNG :

// Создаём временную рендер-текстуру
var renderTexture = RenderTexture.GetTemporary(Screen.width, Screen.height);

// Рендерим в неё картинку с камеры
camera.targetTexture = renderTexture;
camera.Render();

var active = RenderTexture.active;
RenderTexture.active = renderTexture;
{
    // Превращаем рендер-текстуру в Texture2D
    var texture = new Texture2D(renderTexture.width, renderTexture.height);
    texture.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0);
    texture.Apply();
}
RenderTexture.active = active;
RenderTexture.ReleaseTemporary(renderTexture);

// Превращаем текстуру в файл с помощью Texture2D.EncodeToJPG или Texture2D.EncodeToPNG
// Сохраняем на диск

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question