You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Assets/SpritesAndBones/Scripts/Utils/AnimationToPNG.cs
+79-46
Original file line number
Diff line number
Diff line change
@@ -28,19 +28,41 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
28
THE SOFTWARE.
29
29
*/
30
30
31
-
// AnimationToPNG is based on Twinfox and bitbutter's Render Particle to Animated Texture Scripts, this script will render out an animation that is played when "Play" is pressed in the editor.
32
-
33
-
/* Basically this is a script you can attach to any gameobject in the scene, but you have to reference a Black Camera and White Camera both of which should be set to orthographic, but this script should have it covered. There is a prefab called AnimationToPNG which should include everything needed to run the script.
34
-
35
-
If you have Unity Pro, you can use Render Texture, which can accurately render the transparent background for your animations easily in full resolution of the camera. Just check the box for the variable "useRenderTexture" to use RenderTextures instead. If you are using Unity Free, then leave this unchecked and you will have a split area using half of the screen width to render the animations.
36
-
37
-
You can change the "animationName" to a string of your choice for a prefix for the output file names, if it is left empty then no filename will be added.
38
-
39
-
The destination folder is relative to the Project Folder root, so you can change the string to a folder name of your choice and it will be created. If it already exists, it will simply create a new folder with a number incremented as to how many of those named folders exist.
40
-
41
-
Choose how many frames per second the animation will run by changing the "frameRate" variable, and how many frames of the animation you wish to capture by changing the "framesToCapture" variable.
42
-
43
-
Once "Play" is pressed in the Unity Editor, it should output all the animation frames to PNGs output in the folder you have chosen, and will stop capturing after the number of frames you wish to capture is completed. */
31
+
// AnimationToPNG is based on Twinfox and bitbutter's Render Particle to Animated Texture Scripts,
32
+
// this script will render out an animation that is played when "Play" is pressed in the editor.
33
+
34
+
/*
35
+
Basically this is a script you can attach to any gameobject in the
36
+
scene, but you have to reference a Black Camera and White Camera both of
37
+
which should be set to orthographic, but this script should have it
38
+
covered. There is a prefab called AnimationToPNG which should include
39
+
everything needed to run the script.
40
+
41
+
If you have Unity Pro, you can use Render Texture, which can accurately
42
+
render the transparent background for your animations easily in full
43
+
resolution of the camera. Just check the box for the variable
44
+
"useRenderTexture" to use RenderTextures instead. If you are using Unity
45
+
Free, then leave this unchecked and you will have a split area using
46
+
half of the screen width to render the animations.
47
+
48
+
You can change the "animationName" to a string of your choice for a
49
+
prefix for the output file names, if it is left empty then no filename
50
+
will be added.
51
+
52
+
The destination folder is relative to the Project Folder root, so you
53
+
can change the string to a folder name of your choice and it will be
54
+
created. If it already exists, it will simply create a new folder with a
55
+
number incremented as to how many of those named folders exist.
56
+
57
+
Choose how many frames per second the animation will run by changing the
58
+
"frameRate" variable, and how many frames of the animation you wish to
59
+
capture by changing the "framesToCapture" variable.
60
+
61
+
Once "Play" is pressed in the Unity Editor, it should output all the
62
+
animation frames to PNGs output in the folder you have chosen, and will
63
+
stop capturing after the number of frames you wish to capture is
64
+
completed.
65
+
*/
44
66
45
67
publicclassAnimationToPNG:MonoBehaviour{
46
68
@@ -57,16 +79,16 @@ public class AnimationToPNG : MonoBehaviour {
57
79
publicintframesToCapture=25;
58
80
59
81
// White Camera
60
-
publicCamerawhiteCam;
82
+
privateCamerawhiteCam;
61
83
62
84
// Black Camera
63
-
publicCamerablackCam;
85
+
privateCamerablackCam;
64
86
65
87
// Pixels to World Unit size
66
88
publicfloatpixelsToWorldUnit=74.48275862068966f;
67
89
68
90
// If you have Unity Pro you can use a RenderTexture which will render the full camera width, otherwise it will only render half
69
-
publicbooluseRenderTexture=false;
91
+
privatebooluseRenderTexture=false;
70
92
71
93
privateintvideoframe=0;// how many frames we've rendered
72
94
@@ -90,45 +112,41 @@ public class AnimationToPNG : MonoBehaviour {
90
112
91
113
privateRenderTexturewhiteCamRenderTexture;// white camera render texure
92
114
93
-
// Get the texture from the screen, render all or only half of the camera
94
-
publicTexture2DGetTex2D(boolrenderAll){
95
-
// Create a texture the size of the screen, RGB24 format
0 commit comments