Since the original shaders slightly changed, I needed to update the project.

You can see the changes on GitHub.

And the unitypackage file is also in GitHub.

And now to support specular shaders...

Categorized in: Unity
A lot has happened since my last update!

First of all, I have joined Unity Technologies as a software developer!! This means I will be fixing some bugs, doing some code, and more. It's an amazing place and I'm really happy.

For obvious reasons I cannot really talk about what I am currently working on inside Unity Technologies, but I will keep posting about my hobby projects, problems I'm facing, and code stuff :)

Unity has improved their 2d joints user interface, making my last post a bit redundant, however it was still a great learning experience and I will update the project soon (tm) to remove code redundancies.

I have obtained a Razer OSVR Hacker Developer Kit, and am trying to get it to work with Steam VR, and may contribute to that project there. I like VR and open source, this is a good project.

I also created a ReactJS / THREE.js renderer (I had started working on this before joining Unity) and released it around a month ago, the reception was much better than I had expected, people are already using it for their projects! Even though it's in alpha and I told them not to! Amazing! Here are some demos I made if you're interested in that sort of thing: http://toxicfork.github.io/react-three-renderer-example/
Categorized in: Uncategorized

Lately I have been working on an extension for Unity3D.

Why?

I tried to make a 2D platformer game and I quickly became frustrated with the amount of effort necessary to connect objects.

Here's a few gifs to express my main issues:


Continue reading →

Categorized in: Projects, Uncategorized, Unity
I have made an update to the XML Spritesheet Slicer project, and created a Github repo for it! Check the video above for the details :)
Categorized in: Projects, Unity
So I use SourceTree and I love it. However it was crashing on me every time I tried to open a repository!

Additionally, my visual studio just stopped using line numbers as well, and was giving me an error message. So I looked it up.

Ran into this link: http://stackoverflow.com/questions/14897032/visual-studio-2012-line-number-outlining-gutter-missing.

So I went into my AppData/Local/Temp folder and saw there were more than 60 thousand files there! So I just deleted them all. That fixed it :D
Categorized in: Uncategorized
For a project of mine, I wanted to have custom clipping planes for objects, so that if an object is intersection with another, it would hide any part after the intersection.

It looks like this:





I decided to extend the Standard shader provided by Unity3D to achieve this effect.

Continue reading →
Categorized in: Projects, Unity

This little snippet allows you to see which objects you are hovering over in the Unity3D hierarchy pane. It also shows which objects are being dragged.


Here's the script. You will need to place this script into your Assets directory, inside the 'Editor' folder. If the 'Editor' folder does not exist, you need to create it.

using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class HighlightHelper {
private static readonly Type HierarchyWindowType;
static HighlightHelper() {
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGUI;
EditorApplication.update += EditorUpdate;
SceneView.onSceneGUIDelegate += OnSceneGUIDelegate;
Assembly editorAssembly = typeof (EditorWindow).Assembly;
HierarchyWindowType = editorAssembly.GetType("UnityEditor.SceneHierarchyWindow");
}
private static void EditorUpdate() {
var currentWindow = EditorWindow.mouseOverWindow;
if (currentWindow && currentWindow.GetType() == HierarchyWindowType) {
if (!currentWindow.wantsMouseMove) {
//allow the hierarchy window to use mouse move events!
currentWindow.wantsMouseMove = true;
}
} else {
_hoveredInstance = 0;
}
}
private static readonly Color HoverColor = new Color(1, 1, 1, 0.75f);
private static readonly Color DragColor = new Color(1f, 0, 0, 0.75f);
private static void OnSceneGUIDelegate(SceneView sceneView) {
switch (Event.current.type) {
case EventType.DragUpdated:
case EventType.DragPerform:
case EventType.DragExited:
sceneView.Repaint();
break;
}
if (Event.current.type == EventType.repaint) {
var drawnInstanceIDs = new HashSet<int>();
Color handleColor = Handles.color;
Handles.color = DragColor;
foreach (var objectReference in DragAndDrop.objectReferences) {
var gameObject = objectReference as GameObject;
if (gameObject && gameObject.activeInHierarchy) {
DrawObjectBounds(gameObject);
drawnInstanceIDs.Add(gameObject.GetInstanceID());
}
}
Handles.color = HoverColor;
if (_hoveredInstance != 0 && !drawnInstanceIDs.Contains(_hoveredInstance)) {
GameObject sceneGameObject = EditorUtility.InstanceIDToObject(_hoveredInstance) as GameObject;
if (sceneGameObject) {
DrawObjectBounds(sceneGameObject);
}
}
Handles.color = handleColor;
}
}
private static void DrawObjectBounds(GameObject sceneGameObject) {
var bounds = new Bounds(sceneGameObject.transform.position, Vector3.one);
foreach (var renderer in sceneGameObject.GetComponents<Renderer>()) {
Bounds rendererBounds = renderer.bounds;
rendererBounds.center = sceneGameObject.transform.position;
bounds.Encapsulate(renderer.bounds);
}
float onePixelOffset = HandleUtility.GetHandleSize(bounds.center)*1/64f;
float circleSize = bounds.size.magnitude*0.5f;
Handles.CircleCap(0, bounds.center,
sceneGameObject.transform.rotation, circleSize - onePixelOffset);
Handles.CircleCap(0, bounds.center,
sceneGameObject.transform.rotation, circleSize + onePixelOffset);
Handles.CircleCap(0, bounds.center, sceneGameObject.transform.rotation, circleSize);
}
private static int _hoveredInstance;
private static void HierarchyWindowItemOnGUI(int instanceID, Rect selectionRect) {
var current = Event.current;
switch (current.type) {
case EventType.mouseMove:
if (selectionRect.Contains(current.mousePosition)) {
if (_hoveredInstance != instanceID) {
_hoveredInstance = instanceID;
if (SceneView.lastActiveSceneView) {
SceneView.lastActiveSceneView.Repaint();
}
}
} else {
if (_hoveredInstance == instanceID) {
_hoveredInstance = 0;
if (SceneView.lastActiveSceneView) {
SceneView.lastActiveSceneView.Repaint();
}
}
}
break;
case EventType.MouseDrag:
case EventType.DragUpdated:
case EventType.DragPerform:
case EventType.DragExited:
if (SceneView.lastActiveSceneView) {
SceneView.lastActiveSceneView.Repaint();
}
break;
}
}
}



How it works:

When the Unity3D editor loads, it calls the static constructor of this script. Then, the HighlighHelper hooks on to the scene view’s GUI callbacks, editor update callbacks, as well as the editor’s Hierarchy Pane’s item callbacks.

Whenever the Unity3D editor updates, the script checks whether the user is hovering over the hierarchy pane or not. If so, then it allows the window to get MouseMove callbacks. It's hacky, but it works! Then, during the MouseMove events, the script checks if the mouse is inside the rectangle of the name label for any gameobject in the hierarchy, and if so, it notes down which object’s name is hovered over.

The scene view gui method then looks up if any gameobjects match that ‘instance ID’, and draws some circles around them. It does the same for dragged objects. I hope it helps! If you have any questions, please write it in the comments.

Update: I have just created a repository for the script here: https://github.com/toxicFork/Unity3D-HighlightHelper so it will be easier to track any changes or allow any pull requests.

Categorized in: Projects, Unity
Edit: Update here!



Starling Framework's spritesheets are described by the TextureAtlas XML files.

Recently I have donated to the KenneyLand crowdfund and Kenney (www.kenney.nl) has sent me an asset pack containing a lot of spritesheets and other great assets. The spritesheets also came with XML files next to them. I currently use Unity3D as my main development tool and wanted to use these spritesheets for some of my game ideas.

I will now explain how I wrote a script to let me easily slice 2D sprites.

We will use the UI pack: Space extension by Kenney as an example. The spritesheet looks like this:

Continue reading →
Cover of the Unity 2D Game Development book
Cover of the Unity 2D Game Development book


The Unity 2D Game Development book, written by Dave Calabrese and technically reviewed by me has recently been published!

The book teaches the readers how to:
  • Build a 2D game using the native 2D development support in Unity 4.3
  • Create a platformer with jumping, falling, enemies, and a final boss
  • Full of exciting challenges which will help you polish your game development skills
You may view it in Packt!
Categorized in: books, Unity, Unity3D
Site was down for a while, this was caused by an update to Wordpress which revealed that I had installed a bad plugin or theme. After a fresh install, it's back! :D Please do let me know if there are any broken links (there probably will be).
Categorized in: Uncategorized