Skip to content

Articles about snippet

Thoughts on software development, games, design, and the things I learn along the way.

Advertisement Talescape
Create a List With Multiple Different Types in C#

Create a List With Multiple Different Types in C#

Generally C# is a very strongly typed language and usually lists allow only one defined data type. Using ArrayList, however, we can get around this restriction to some extent.

Capture Screenshot in Unity

Capture Screenshot in Unity

Screenshots can be created very easily in Unity using the ScreenCapture class respectively the CaptureScreenshot method. You can use the class defined below. Just create a new script CaptureScreenshot.cs and paste the code there. Then you just have to attach the new MonoBehaviour to a GameObject. You can select the folder and the key afterwards simply inside the Inspector. Screenshots will be saved in your system folder Pictures.

Runtime Storage in C#

Runtime Storage in C#

Sometimes you just want to store some random value. For this I wrote the RuntimeStorage class. It serves me in some games as a naive cache for a couple of less important values.

How To Create And Use a Singleton in C#?

How To Create And Use a Singleton in C#?

Creating a Singleton is relatively simple. First we create a static variable _instance. In addition, we create a property Instance. We will use it later to access the Singleton. In addition, a new instance of the class is provided there, if none should exist yet. This way we also ensure that the singleton is initialized at exactly the right moment. Namely, only when we need it.

Assign a Static IP Address in a Local Area Network

Assign a Static IP Address in a Local Area Network

You can change the assigned IP address of your computer by editing the file /etc/network/interfaces. Search there for your primary Ethernet controller (usually eth0). Change the value from dhcp to static. Then you can specify address (IP address) and gateway (usually your router). Then restart the network or computer. Tested under Ubuntu and Rasbperry Pi OS.