x


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
more ▼

asked May 17 '11 at 06:41 PM

Lacrymology gravatar image

Lacrymology
3 5 5 11

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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.

more ▼

answered May 17 '11 at 07:01 PM

flaviusxvii gravatar image

flaviusxvii
3k 13 19 43

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...

May 17 '11 at 08:06 PM Lacrymology

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.

May 17 '11 at 08:08 PM flaviusxvii

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 instead makes 'self' a keyword meaning 'this'. It preserves the style of Python while unfortunately not being able to provide the same functionality.

Dec 05 '11 at 12:52 AM ironmagma
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered May 17 '11 at 07:07 PM

almo gravatar image

almo
1.8k 3 6 18

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.

May 17 '11 at 08:07 PM Lacrymology

Hmm... tricky. If I think of anything else, I'll update my answer and leave another comment so your mail icon turns blue. :)

May 17 '11 at 08:25 PM almo
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered May 17 '11 at 09:03 PM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

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().

Dec 05 '11 at 12:49 AM ironmagma
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 05 '11 at 12:49 AM

ironmagma gravatar image

ironmagma
1 2 2 3

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x135
x71
x71

asked: May 17 '11 at 06:41 PM

Seen: 776 times

Last Updated: Dec 05 '11 at 03:04 AM