Unity missing custom initializers

One of the things I miss the most coming from Objective-C to Unity is the lack of custom initializers. Luckily-ish there is a way to kind of do this:


public class Meow()
    public int x
    public string name

new Meow{x = 10, name = "cat"}



Fastlane build numbers for Unity

Recently on a project, I came across a problem where the Fastlane Unity action I am using was blowing away the info.plist of the generated xcode project despite the Unity project being marked as “Append” instead of “Replace”.

The reason this is a problem is we wanted each build to be uploaded to hockey app with a unique build number. Fastlane has plugins to handle this but it depends on the info.plist not being destroyed.

So there’s a simple hack to fix this. Use a small ruby function in the fastlane file to write your version to a file and update each time the file is ran.

Here’s a snippet:

build_num = 1
filename = "build_number"
if File.exist?(filename)
File.open(filename) { |f|
    build_num = f.read.to_i + 1
File.open(filename, "w") { |f|

When you want to get your version number you simply just :

file = File.open("build_number", "r")
build_num = file.read

And Bob’s your uncle.

Image pinch zoom and swipe in Unity

Currently, I am working on a glorified slideshow for an app that I am rebuilding in Unity. After very little effort on my part, I was unable to find a slideshow framework I liked or a plugin that handled input the way I wanted.

So I just made it the way I wanted it to behave. It’s pretty straightforward. The only thing of interest in that I am using MouseDown for the swipe vs GetTouch for the pinch. This was so I could test the swipe in the editor. If I used GetTouch instead I wouldn’t need the Invoke function for blocking swipes during a pinch.


Simply deploy and view Unity logs on Android

Having to plug your phone into your computer every time you want to test your game or app on android sucks.

Luckily there is a simple way to do it.

  • Add adb to your path variables.
  • Connect your phone to your computer
  • In terminal run: adb tcpip 5555
  • Disconnect phone
  • Find phones IP address: Settings > About phone > Status
  • In terminal run: adb connect IP_ADDRESS
  • Confirm connection in terminal with:  adb devices

Boom. Device connected. Now in Unity when you hit Build & Run it will deploy right to device.

“But what about logs?” you may ask. In terminal run adb logcat -s "Unity".

Unnecessary phone permissions when build react native android

Yesterday when trying to release a simple app to the android store, I noticed that my apk was requesting phone permissions and this was requiring me to use a privacy policy on the play store.

After some digging I came across this comment on the react native github page and it solves it for me. Hopefully this will help other until they manage to resolve this issue



Git ‘cherry-pick’ individual file

Today the situation came up where I wanted the latest of a file in another branch. But only that file. Didn’t want to merge and reject so that get’s rid of cherrypick and merge as options.

Luckily there is a way to do this just using the checkout command.

[code]git checkout feature/meow Source/Cat.cs[/code]


Sauce : http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/

Get a patch file from a github commit

Writing this mostly so I don’t forget.

Let’s say you want a patch file of a particular commit, for example: https://github.com/bardic/StalkCoin/commit/8789de6bd0db33fb6622f4a25438b74d6b9317ec

Append .patch to the end of that ( https://github.com/bardic/StalkCoin/commit/8789de6bd0db33fb6622f4a25438b74d6b9317ec.patch ) and you have yourself a patch file!

Source: http://chem-bla-ics.blogspot.ca/2011/01/github-tip-download-commits-as-patches.html

Grouping signals in StrangeIoC

Recently I have started relearning Unity3d and because I very much enjoy DI and IoC I’m also relearning StrangeIoC. Since I’ve last looked at Strange, Signals have been added. This makes me very happy being an old AS3 dev that <3’d Robotlegs and AS3Signals.

Anywho, one “problem” with signals, that existed in flash as well, is that each signal is a class. The idea of making a 5 line class for each signal I want to dispatch irks me. My solution is an ugly one but I liked it when doing flash and so far like it here as well.

namespace ca.openbracket.signals{
    public class StartSignal:Signal{}
    public class TestSignal:Signal{}

What I like about this approach is that I can group my related signals into a single file and see them all.  The two big drawbacks are searching for a signal can be difficult if you aren’t accustomed to this and you don’t get more granulated version control details.

Is this worth it? I have no idea. But it makes me happy.

Font ascender’s cut off for custom fonts on ios7

Just look at that title. What a stupid bug.

Anyways, in one of the apps I work on we were seeing on ios7 that a custom bold font was clipping the ascenders on all uppercase characters. After some googling I found that it was an ios bug.  I luckily found a nicer way to correct the issue than having to increase the height of each textfield by 6 pixels and offsetting it’s ypos.

This post describes using the OSX Font Tool to pull the measurements from the font and allow you to edit them. So by setting the lineGap to 0 (the ios bug is that lineGap is ignored :/ ) and adding that amount to ascender you can fix the problem. I haven’t had design sign off on this yet so I’m not sure if it’s perfect but it works and looks pretty good to me


::MARCH 31st EDIT::

So the artist and I looked at the font change and it doesn’t work for our needs. Yes, it fixes the issue, but our text is not not in the right position and since only one field if effected we chose to just increase the height of the field and change its offset.

Getting started with HaxeFlixel

With Haxe gaining so much popularity, flash work declining and my want to make 2d games with a language I’m already fairly familiar with that I can publish to multiple platforms, I’ve decided that Haxe is the right move. With that decision I had to pick a game engine and it was really between Flambe or HaxeFlixel.

Since I don’t care about a html5 target and I feel slightly more comfortable in the HaxeFlixel API, I have decided to use it.

Getting started is actually pretty easy but there were a few points that tripped me up slightly. The official documentation for installation is actually spot on. Check it out here.

Once installed, you need some more of editor/IDE. Since I’m developing on a Mac, I have pretty limited options. Since the IntelliJ plugin is wonky at best, I’ve gone with Sublime Text.  When setting up Sublime I was easily able to set up the plugin following the instructions but could not for the life of me get it to actually get it to highlight or code complete.

The issue was the instructions I was following didn’t point out the need to set up some path variables.  The easiest way to do this is to add these variables to your .bashrc

In your home directory (~/) run nano .bashrc . If you have this file it’ll open it, if not it will create it. Then add this:

export haxe_path="/usr/bin/haxe"
export HAXE_LIBRARY_PATH="/usr/local/lib/haxe/std:."

Exit and save.

Once you have all your libs set up for HaxeFlixel you want to add a symlink to the subl command in Sublime. This will allow HaxeFlixel to open the project for you when creating new projects.  There are official instructions on this but it didn’t work for me.  My path was slightly different :

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl

And that there covers the initial setup issues I encountered. I’ll likely post more findings as I learn more of HaxeFlixel. I actually never used Flixel before, but have several years of Flash development behind so most of my findings will likely be differences from Flash to Haxe .