Uploaded December 2022 | Updated November 2026, 1 hour ago
Often when building a project you'll need to do some sort of repetitive task as part of the work. This can be things like data entry, running a script or other jobs. We can use software to automate some of this work to help save ourselves time and remove the potential slowness of doing things manually. Additionally, this kind of automation can ensure that jobs complete with consistent results with less opportunity for human error. Today we're going to dive into an implementation of a quick tool to help us convert SVG's (which Unity can't natively render) into PNG's automatically so we can take advantage of SVG based icon packs or designs and the scalability of SVG's while still being able to view and use the art inside of Unity.
In order to do this we're going to create a Unity [`MenuItem`](docs.unity3d.com/ScriptReference/MenuItem.html) that launches the Inkscape CLI to automatically render images from SVG files in our directory.
The code for this task looks like this:
```csharp
// Search the projects Assets directory and all children directories
var searchDirectory = Path.Combine(Environment.CurrentDirectory, "Assets");
Debug.Log($"Searching for SVGs in {searchDirectory}");
var svgFiles = Directory.EnumerateFiles(searchDirectory, "*.svg", SearchOption.AllDirectories);
foreach (var svgFile in svgFiles)
{
// Generate a new path with a PNG extension instead of the original SVG extension - reusing other parts of the path
var pngFile = Path.ChangeExtension(svgFile, "png");
Debug.Log($"Converting {svgFile} to {pngFile}");
Process process = Process.Start("inkscape",
$"-o {pngFile} -w 32 -h 32 {svgFile}"); //32 is the size in pixels of the width and height of the generated image
process.WaitForExit();
}
Debug.Log("jobs done");
```
You can get a copy of Inkscape here: inkscape.org
The Inkscape Wiki has more information about how you can get started using the Inkscape CLI: wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
The icons I'm using are from the Material Design Icons set, you can browse the complete set of icons here: materialdesignicons.com
Join the World of Zero Discord Server: discord.gg/hU5Kq2u
Often when building a project you'll need to do some sort of repetitive task as part of the work. This can be things like data entry, running a script or other jobs. We can use software to automate some of this work to help save ourselves time and remove the potential slowness of doing things manually. Additionally, this kind of automation can ensure that jobs complete with consistent results with less opportunity for human error. Today we're going to dive into an implementation of a quick tool to help us convert SVG's (which Unity can't natively render) into PNG's automatically so we can take advantage of SVG based icon packs or designs and the scalability of SVG's while still being able to view and use the art inside of Unity.
In order to do this we're going to create a Unity [`MenuItem`](docs.unity3d.com/ScriptReference/MenuItem.html) that launches the Inkscape CLI to automatically render images from SVG files in our directory.
The code for this task looks like this:
```csharp
// Search the projects Assets directory and all children directories
var searchDirectory = Path.Combine(Environment.CurrentDirectory, "Assets");
Debug.Log($"Searching for SVGs in {searchDirectory}");
var svgFiles = Directory.EnumerateFiles(searchDirectory, "*.svg", SearchOption.AllDirectories);
foreach (var svgFile in svgFiles)
{
// Generate a new path with a PNG extension instead of the original SVG extension - reusing other parts of the path
var pngFile = Path.ChangeExtension(svgFile, "png");
Debug.Log($"Converting {svgFile} to {pngFile}");
Process process = Process.Start("inkscape",
$"-o {pngFile} -w 32 -h 32 {svgFile}"); //32 is the size in pixels of the width and height of the generated image
process.WaitForExit();
}
Debug.Log("jobs done");
```
You can get a copy of Inkscape here: inkscape.org
The Inkscape Wiki has more information about how you can get started using the Inkscape CLI: wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
The icons I'm using are from the Material Design Icons set, you can browse the complete set of icons here: materialdesignicons.com
Join the World of Zero Discord Server: discord.gg/hU5Kq2u

 from an earlier video on the channel.
When this grid snapping is applied against a mesh there are a few additional decisions we need to make. This includes what coordinate space we want to perform the operation in. Coordinate spaces describe an object relative to that space. For example an object space representation is an identical representation for each version of that object whereas a world space version of the same object would describe the unique position, rotation and scale of that object in the world. Which coordinate space we decide to create our grid in will effect the final result: if we snap vertices in object space then even as that object is rotated or moved through the world the rounded vertices will not change. However if we perform the grid snapping in world space the final results will change as the object is moved and rotated through the world. Depending on the effect we want to achieve different coordinate spaces may be more appropriate. For our testing purposes though well just use object space since this is the most straightforward to implement.
The vertex shader code that snaps to a grid looks like this (this is the surface shader implementation):
```shader
void vert(inout appdata_full v) {
v.vertex /= _GridSize;
v.vertex = round(v.vertex);
v.vertex *= _GridSize;
}
```
Note: the syntax is slightly different between the Surface Shader and Vertex Shader implementations however the principals are the same. Both implementations are demonstrated in the video.
You can view the entire playlist of implementing this effect here: https://www.youtube.com/playlist?list=PLEwYhelKHmiixWR3Tn5dYt1iUlSCL6OFq
***
More Visual Effects weve built on World of Zero: https://www.youtube.com/playlist?list=PLEwYhelKHmig6ttzH0nRL3OOQsGLtVrtX
Unitys Surface Shader examples: https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
If youre interested in learning more about coordinate spaces (object space/world space/etc) this article goes into a bit more depth and also describes the relationships between the different coordinate spaces: http://davidlively.com/programming/graphics/coordinate-spaces/
The Bomber Bug asset is located here: https://assetstore.unity.com/packages/p/bomber-bug-pack-pbr-63127
Come chat in the World of Zero Discord Server: https://discord.gg/hU5Kq2u What Happens When You Snap Vertices To A Grid?](https://i.ytimg.com/vi/e8NItqF_9hQ/mqdefault.jpg)



![Getting Started Building Pong in my Terminal - Pong in Bash - Part 1
Ive been exploring a few of the fun ways you can write text to a terminal. One of the more interesting commands available for this is `tput`. The `tput` command provides a variety of options for updating or checking the state of your terminal. This includes things like making text **bold**, *italics* or underlined. You can leverage `tput` to change the color of the foreground and background of your terminal. For us though were going to use it to position the cursor. This will allow us to simulate moving an object in the terminal like the ball in pong by updating the cursor position we draw at.
For this video well be looking to explore that capability by starting work on building pong in our shell. Our initial goal is to build a simple ball that bounces left and right horizontally across our screen (vertical movement and paddles will come later). This will involve creating a basic REPL (read-execute-print-loop) script in bash that can track the velocity and position of the ball, print the ball at its current position and test if the ball has collided with either side of the terminal.
* `tput cup [row] [column]` updates the cursor position to the provided row and column (zero indexed).
* `tput cols` returns the number of columns in the current terminal window.
* `tput rows` returns the number of rows in the current terminal window.
Our basic script looks like this after implementing this:
```sh
#!/bin/bash
width=$(tput cols)
echo width = ${width}
ball_x=$((width / 2))
echo ball pos = ${ball_x}
ball_vel_x=$((1))
trap tput cnorm; exit SIGINT
tput civis
while true; do
ball_x=$((ball_x + ball_vel_x))
# Hit the right hand wall
if [ $ball_x -gt $width ]; then
ball_vel_x=$((-1))
fi
if [ $ball_x -lt 1 ]; then
ball_vel_x=$((1))
fi
clear
tput cup 0 $ball_x
echo o
done
```
Note: not mentioned in the video, but Ive included a `trap` to restore the cursor to its normal visibility when you exit the script (more on this in a future video).
If youre looking for a deeper dive into tput linuxcommand.org has put together a great resource with a number of examples demonstrating many of the features of tput: http://www.linuxcommand.org/lc3_adv_tput.php
Ive been live streaming development and some games on Twitch at: https://www.twitch.tv/worldofzerodev
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Getting Started Building Pong in my Terminal - Pong in Bash - Part 1](https://i.ytimg.com/vi/fEtcGFEiuQM/mqdefault.jpg)



![Adding an Accent to our Contrast Shader - Lets Make a Side Scrolling Shooter - Part 4
Lets spice up our our contrasting transition shader with an accent color that more clearly marks the border between one color and the next.
Part 1 of building this contrasting shader is here: https://www.youtube.com/watch?v=jJcSbixSy5c
Most of the magic of this shader happens in these lines which select the color we want to draw:
```
float maskPrimary = (_Transition + barrierSize [LESS THAN] maskStrength);
float maskSecondary = (_Transition - barrierSize [GREATER THAN] maskStrength);
float maskAccent = !(maskPrimary || maskSecondary);
o.Albedo = maskPrimary * _PrimaryColor
+ maskSecondary * _SecondaryColor
+ maskAccent * _AccentColor;
```
Come join the World of Zero Discord channel to talk software, game development and more: https://discord.gg/hU5Kq2u Adding an Accent to our Contrast Shader - Lets Make a Side Scrolling Shooter - Part 4](https://i.ytimg.com/vi/gu_bFoI2fIg/mqdefault.jpg)
