@passerbycmc
You have macros, which are a mixed blessing. There are also compile-time macros, which allows you to build code based on metadata about your code that can then be used later on. I’m not quite sure about the details.
A very simple example is to create an enum based on the contents of a text-file where you have the names of some characters:
macro define_character_name_enum:
enumMembers = (s for s in System.IO.File.ReadAllLines("Path_To_Text"))
enumBody = Boo.Lang.Compiler.Ast.EnumDefinition(Name: "CharacterName")
for enumName in enumMembers:
enumBody.Members.Add( EnumMember (Name : enumName))
yield enumBody
define_character_name_enum
This enum can now be used just like any other enum. The text file is not needed anymore after the compilation is done.
This example isn’t very usefull (and would probably have been a bad idea!), but I can see uses. Say you have an RPG or and RTS or whatever, and need to define unit types. The usual way to allow designers easy access to tweak this stuff is to put the stats of units in XML or a scriptable object or some custom format, and then parse that when you start the game.
Using a macro like this, you might instead parse that data into classes compile time. This would allow you to not include the data files in your builds.
To see an example of this, check out the attached unitypackage, and follow the instructions in. How To make This Work. The short version is that you place a text file on your Desktop named “Names.txt”, and fill it with names. The built-in boo compiler will then create the enum as above, and put those values in a text mesh that’s the only thing in the scene.
This works in Unity 5. Unity didn’t stop supporting Boo, they just stopped having a create script → boo dropdown, and stopped referencing boo existing in the manual.
EDIT: adding the unitypackage
EDITEDIT: still not saying that this is neccessarily a good idea to do. The point was just that there are interesting things you can do in Boo that you can’t do in C#, which is not the case with UnityScript.
2315290–156051–DemoOfBooCapabilities.unitypackage (5.93 KB)