- Home /
Boo help: method not defined
Hi, I'm a python lover, so I'm trying to get started in Boo, but the compiler fails saying among other things that "GetClickedGameObject is not a member of class ClickEnterGUI".
It's also complaining that GUIManager, Fader and OrtographicZoomer are unknown identifyers (they are behaviors defined in C#). Can someone give me a hand with this, please?
class ClickEnterGUI (MonoBehaviour):
public clickLayerMask as LayerMask;
def Start ():
pass
def Update ():
if Input.GetMouseButtonDown(0):
clickedObj = self.GetClickedGameObject()
if clickedObj is not null:
this.enabled = false
gui = GameObject.Find("GUI")
camera = GameObject.Find("MainCamera")
fadeTime = gui.GetComponent(GUIManager).ActiveGUI.fadeTime
camera.GetComponent(Fader).fadeOutIn(fadeTime, {
gn = clickedObj.GetComponent(GUIName);
computerGUI = gn.guiName;
gui.GetComponent(GUIManager).setGUI(computerGUI);
})
camera.GetComponent(OrtographicZoomer).zoom(2)
def GetClickedGameObject():
// Builds a ray from camera point of view to the mouse position
ray = Camera.main.ScreenPointToRay(Input.mousePosition)
hit as RaycastHit
// Casts the ray and get the first game object hit
if (Physics.Raycast(ray, hit, Mathf.Infinity, clickLayerMask)):
return hit.transform.gameObject
else:
return null
Answer by flaviusxvii · May 17, 2011 at 07:01 PM
In actual Python you'd have to declare your method as def GetClickedGameObject(self):
I LOVE Python more than any human alive. Boo is different enough I think it's a horrible language to use. Very inconsistent.
I love python as well, and even if its true about Boo's problems, still being able to use some python idioms will be a relief while coding this stuff. OTOH, this does not answer my question at all...
Do you need to use self.GetClickedGameObject() if 'self' is not required while declaring the method? I'm not on a Unity-friendly machine at the moment so I can't try it.
Boo isn't inconsistent or a horrible language. Boo is just a different language from Python.
In Python, you can apply methods of one class to instances of another class, as a result of that syntax. In .NET CIL, that's not possible, which is why Boo ins$$anonymous$$d makes 'self' a keyword meaning 'this'. It preserves the style of Python while unfortunately not being able to provide the same functionality.
Answer by almo · May 17, 2011 at 07:07 PM
Do you need to do some "import" statements to get access to the other C# stuff? Did you mean to spell OrtographicZoomer as OrthographicZoomer? (note the "h")
I'm not a Boo user, but these are the things I see that are suspicious.
I thought of this as well. The compiler complains at the import as well, I might be missing the path, but I'm not sure about this.
Hmm... tricky. If I think of anything else, I'll update my answer and leave another comment so your mail icon turns blue. :)
Answer by Eric5h5 · May 17, 2011 at 09:03 PM
the compiler fails saying among other things that "GetClickedGameObject is not a member of class ClickEnterGUI".
You don't need "self."; just leave it out. "clickedObj = GetClickedGameObject()
" Although it does work fine with it, so I guess you have some other issues.
It's also complaining that GUIManager, Fader and OrtographicZoomer are unknown identifyers (they are behaviors defined in C#).
See here.
While you don't need "self" in this instance, the keyword adds clarity to your code, and you should use it so other people (and you) know what you're doing when you call GetClickedGameObject().
Answer by ironmagma · Dec 05, 2011 at 12:49 AM
Check your whitespace. Make sure that whatever form of spacing (spaces vs. tabs) that precedes your methods is the same for the whole document.
Boo has a bug where it will not notify you if it encounters weird whitespace, and this sounds like the kind of problem that arises from that bug. I have notified the creator of Boo about it, but there is yet to be a patch for it.