Hi,
I’m writing a c# Editor Plugin.
So I try to explain my problem as easy as possible. Lets take a simple example.
What i basically want to do is taking Screenshots from the GameWindow in the Editor.
Here is a simple pseudocode example having the Camera which is taking the screenshots looking at an Object The Color of the Object gets changed. In the beginning the Object is grey
void example(){
Application.CaptureScreenshot(“Screenshot1.png”);
Object material changed to red…
Application.CaptureScreenshot(“Screenshot2.png”);
Object material changed to green…
Application.CaptureScreenshot(“Screenshot3.png”);
Object material is chanched to blue…
Application.CaptureScreenshot(“Screenshot4.png”);
}
In the end im getting 4 Screenshots with Object color Grey.
I thought the code gets executed line by line.
Do you execute this within the same frame in the original code?
I’m asking, because this sample would execute within the same frame.
Note that the method does not immediately take the screenshot. The arguments you pass will be remembered and the screenshot will be written once updates and rendering has finished, at the end of the frame.
I’m not even sure why you get 4 screenshots anyway, as this should only produce one screenshot with the name “Screenshot4.png”. All others would basically be exact copies, due to the conditions mentioned above and therefore are superfluous overhead, which the engine eliminates itself by only saving the latest screenshot requested.
If you need to see the changes, you’ll have to delay the screenshots by at least one frame. This could be done with a coroutine.
No thats not a bug no matter if i m changing color or rotation or transforming or doing anything else all screenshots im getting are showing the object in the state like it was befor executing the code.
I’m executing this as a Menu Item in Unity Editor.
So there is no Frame Update or something like this.
I think I get your point is there any way around it.
public class TestDB_acces : MonoBehaviour {
[MenuItem(“Add-On/TakeScreenshot#&d”)]