I’m trying to start scripting in Boo, because it looks nicer than Javascript. I can’t seem to make anything work worth a damn in any language- but this is extremely frustrating.
I put a variable in the Start function, as I read you have to do it that way in Boo. Next time I bring it up, two lines later in Update, the compiler doesn’t recognize it.
Obviously there needs to be more in the script for it to do anything, but this is as far as I got before I came to an error I can’t fix.
(I tried, and got “Unexpected token: ‘public’”, after which I throw up my hands in despair.)
import UnityEngine
class BooBites (MonoBehaviour):
def Start ():
age = 0
exp = 0
gen = 0
def Update ():
if gen == 0:
age = Time.time
Class variables are private are private by default in boo, so you can leave that out. Also, you can initialize them when defining:
class BooBites (MonoBehaviour):
# All numbers are initialized to 0 by default
age as single # Time.time is a float
exp as int
gen as int
example as string = "hello"
def Update():
if gen == 0:
age = Time.time
Since Boo is not limited to Unity as its JavaScript is, there’s actually an official documentation with examples and a discussion group for the odd cases: http://boo.codehaus.org/
But I still don’t see those variables appearing in the inspector. When I do the same thing in Javascript, they show up. Is this just an, um, feature of Unity? (If so, I see why everyone just uses Javascript for scripting.)
There are a few things with Boo and Unity that you first have to figure out and unfortunately most people are either working with JavaScript or C#. But there’s not too many of those and once you’ve got them you can enjoy the clean syntax of Boo with most advanced features that C# offers.
Hashes, lists, callables, closures, events or type inference / duck typing are just a couple of nice features you can read more on the Boo homepage.
I mean, in which other Unity language can you do:
myList = [1,"test",null,{arg | Debug.Log(arg)},0.02]
for i in range(len(myList)):
continue unless myList[i]
if myList[i] isa callable:
myList[i]("hello")
If you have any further questions, feel free to ask.