Posts By: Sam

Type-safe object pool for Unity

Managing memory usage can be crucial for decent performance in game development, especially on memory-constrained devices like mobile phones or consoles. It’s usually best to allocate what you need up-front at startup or on level load rather than mid-game during a frame, because the default memory allocators can be slow at finding free memory blocks…. Read more »

Decoding iOS crash call stacks

Wow it’s been a while since I updated the blog! I think we’re due for a web site refresh too. But first let’s talk about call stacks! Let’s say your iOS game crashes outside of the debugger. Assuming your device is plugged into your mac, you can get the device log from Xcode by bringing… Read more »

Hdg Remote Debug – How It Works

Hdg Remote Debug works using .NET’s reflection features; it doesn’t use any sort of built-in Unity serialisation. Every second it gathers all GameObjects that are currently active, finds all Components on them, and for each component, uses reflection to find all serialised and public fields. This data is sent back to the client running in… Read more »

Visual Studio shader syntax highlighting part 2

I have updated the NShader syntax highlighter to allow adding extra extensions dynamically via the Visual Studio settings. This is one of the most requested features, and it really is a feature that makes sense. The plugin was previously hard-coded to specific file extensions. The reason for this is because that’s just the way you… Read more »

Ring buffers / circular buffers

A ring buffer, also known as a circular buffer or cyclic buffer, is a very useful data structure for certain situations, and worth having around in your programmer’s toolchest. It’s a fixed-size buffer but treated as though it’s connected end to end (that is, the end is connected to the start) and data is written… Read more »

The case of the continually checked out prefabs

I’ve been helping out my friends over at Three Phase Interactive on their game Defect: Spaceship Destruction Kit a little bit. The game is being developed in Unity, and they’re using Perforce for source control. We’re using different combinations of the built-in Unity Perforce support and the P4Connect plugin. We’ve had a strange issue in Unity for… Read more »

Shader syntax highlighting in Visual Studio 2013

If you edit shader code in Visual Studio 2013, you might like to use NShader to get syntax highlighting. NShader was originally written by Alexandre Mutel. His version is available here but it only supports VS2008, VS2010, and VS2012. Issam Khalil had forked it and added VS2013 support, as well as Unity shader highlighting. I’ve… Read more »

BinaryFormatter on iOS

If you’re trying to use a BinaryFormatter under iOS you may discover that it doesn’t work. You may get exceptions like “ExecutionEngineException: Attempting to JIT compile method ..”. This is because by default the mono BinaryFormatter uses runtime generated class serializers. This won’t work on iOS because JIT compilation is not permitted. To get around… Read more »

EditorWindow and play mode

If you’re trying to write custom editors in Unity you may run into a snag. I just spent several hours hitting my head against a wall trying to solve this issue. When you enter play mode, Unity will reload all mono assemblies. This means that your EditorWindow object is recreated, and you will need to… Read more »