Debugging DLL’s in Unity

Just recently I’ve been attempting to debug custom DLL’s in Unity with Visual Studio.

After a bit of fooling around with pdb2mdb.exe as it is mentioned in the Unity documentation I came across a little gem in the Visual Studio Tools for Unity (VSTU) documentation, there it mentions that VSTU automatically generates an MDB from the PDB file, so i figured now that VSTU is integrated in Unity it should happen automatically.

And indeed Unity can automatically convert the PDB file to an MDB file on import. Just copy the PDB file along with the DLL and unity will generate an MDB file automatically. Saves having to call pdb2mdb.exe yourself.

There you go another complexity saving tip from yours truly.

If anyone knows if this works on OSX aswell let me know.

Unity GameObjects only in Editor please

Say you have a project with objects you don’t want in your final build. With unity you can go about this is a whole bunch of different ways.
You can add a script that can do a bunch of things like destroy the objects if it’s not running in the editor, or you could just simply disable the object.
Or if you want an unsafe and impractical method you could delete the gameobjects build the player and then undo.

Why go to all that trouble when you can just add the EditorOnly tag this causes Unity to not include these tagged gameobjects in the built player.
Without requiring even a single line of code. Ok, it’s possible you’ve already added a specific tag to your special gameobjects, then you just create an empty gameobject and give it the EditorOnly tag and hang your objects as child objects under it.

EditorOnly

Unity Post Process Mayhem

Are you sick and tired of forgetting to copy that data file to the build directory after each and every standalone build in unity? Sure you could incorporate it into the project but you don’t want that, you just wish that PostProcessBuildPlayer script would work on windows. As of Unity 3.5.2 life just got better…

A long awaited function in Unity was a working post process build player script for standalone players on windows as it was already working on mac’s. As seen in the latest Release Notes and stated in the BuildPipeline a few things have changed.. Apparently the PostProscessBuildplayer script is not supported on windows, which is a bummer for windows users on the other hand it’s easily solved with a new and improved UnityEditor.Callbacks which is both usable on Windows and Mac, So here goes…

P.S. No this is not a custom build window script, it actually triggers from the existing Unity BuildWindow.

NB: -10 is a higher priority than 100, the default priority is 1
NB2: This is an Editor Script not something for a gameobject (you should know this)

You can use the method to do all kinds of things on your computer after a build is complete just a couple ideas:

  • After a large build send an email with a link to the file saying the build is complete.
  • Play a sound notifiying you build is complete
  • Run a test on your build
  • And lots more…

Anyway now you have the tools go make 🙂

Unity Editor Macros

A while back the guys at unity released a version of their editor with macros enabled (by accident) in the current version is has been removed/disabled. (this because it’s something they use for testing and not meant for production environments)
But with recent endeavours I found it’s possible to enable it in the editor making debugging stuff within the editor more entertaining, plus it adds a new window to the editor making your editor more of an editor.
Please note this is not documented by unity and probably not supported either.

Simple script:

How to use:
Place this script in an Editor directory in your Assets and then:
Go to Window->Macros and tadaa.. you have a new editor window that can record all your editor actions and execute new ones.
May this help you on your endeavors of making cool new stuff for unity