Tag: unity - page 2
-
Jul 17, 2016
Dependency injection in Unity with Zenject
Dependency injection in Unity projects is slightly complicated by the fact that we do not have full control over the initialization of the engine. Unity instantiates it’s various object types (
GameObject
,Component
,MonoBehaviour
,ScriptableObject
,Material
, etc) when scenes and assets are loaded. Put simply… the objects exist before we can do anything with them. -
Aug 28, 2015
Custom editor controls in Unity - Part 5: Custom styles
Sometimes it becomes necessary to define custom
GUIStyle
’s to get the most desirable user experience from your editor controls. Custom styles can be defined using a number of different approaches. You can createGUISkin
asset files; custom asset files or simply write some code that creates theGUIStyle
’s programmatically. The latter is nice when you want the styles to be embedded into a DLL. -
Aug 27, 2015
Custom editor controls in Unity - Part 4: Property drawers
Often it is nice to customize the way that some properties are presented in the inspector but you don’t necessarily want to define an entire custom inspector. Fortunately Unity has a feature that enables you to customize the drawing of properties without having to define how the entire inspector of a component should work.
-
Aug 26, 2015
Custom editor controls in Unity - Part 3: Input control
More often than not editor controls will have some sort of value that is shown and editable visually. In this post I am going to walk you through the creation of a custom control that allows some flags to be toggled using a simple grid.
-
Aug 25, 2015
Custom editor controls in Unity - Part 2: Buttons
I think that a great place to start with custom control development is to re-create the
GUI.Button
andGUILayout.Button
controls since these are straightforward to create and helps to establish some of the fundamentals of custom control development. Our custom button implementation will be used in the exact same way as the regular button controls: -
Aug 24, 2015
Custom editor controls in Unity - Part 1: Events
I frequently develop custom controls for custom editor windows, inspectors, property drawers, etc when working on Unity projects to ease project workflows. People often ask how I create these controls so I thought that I would dedicate a blog post towards it for anyone that might be interested.
-
Jul 9, 2015
Ordered dictionary for Unity
When working on projects it is often useful to have some sort of asset that maps values to keys. Since Unity doesn’t currently support the serialization of dictionaries this is something that I either try to avoid needing entirely or that I end up having to reinvent each time by implementing the ISerializationCallbackReceiver interface following the example in Unity’s documentation.
-
Apr 21, 2015
Maintaining asset releases for multiple versions of Unity
When Unity 4 was released I was able to continue to provide support for Unity 3 by tweaking logic so that it would satisfy both of the releases of Unity and in a couple of circumstances to use reflection to transparently select between Unity 3 and Unity 4 APIs. This mainly affected editor logic and so it was possible to get JIT compiled delegates to make the reflected invocations more efficient.
-
Apr 14, 2015
Automatically updating assembly version from git
Originally when I started developing Rotorz Tile System I would update the version number of the assembly manually with each update. Despite the simplicity of this approach there were a couple of occasions where I would forget to bump to version in the “AssemblyInfo.cs” files or in the readme file. I improved this workflow by automating the updating of these version numbers from the most recent semver encoded git tag along with the hash of the most recent commit.
-
Mar 22, 2015
Designer friendly component scripts with Unity events
Unity recently introduced a serializable
UnityEvent
class which allows scripts to expose events in the inspector allowing designers to wire up handlers without coding. This is a really powerful feature because it allows developers to implement components that can now be assembled much more freely by designers… almost like a basic form of visual scripting.