Forum Scripting Cannot Convert 'anonymous method'...

Post your problems and discussions relating to scripting in Unity here.

Cannot Convert 'anonymous method'...

Postby Loftless » May 23rd, 2011, 10:48 pm

So, trying to test out the Mushroom Demo, just to check things out, and got a compiler error "Cannot convert 'anonymous method' to non-delegate type 'string' " on line 55 of GameManager. That line being : delegate(Client client) { .

Obviously, my thought was an issue with outdated code or something of the like, so I figured I would simply re-write my own test code to check things out. However, as I inspected the error line, it seems the error was stemming from the base PlayerIOClient.PlayerIO.Connect() method.

Sorry if the error seems amateur, but I can't seem to figure out the root of the issue.

Thanks for any help :lol: :lol:
Loftless
 
Posts: 2
Joined: May 23rd, 2011, 8:43 pm

Re: Cannot Convert 'anonymous method'...

Postby Loftless » May 24th, 2011, 8:16 am

99.99% sure I solved the issue. Re-read through the documentation, checked the expected parameters for PlayerIO.Connect, and found this:
Code: Select all
PlayerIOClient.PlayerIO.Connect(
   "mushroomsdemo-lsk7kvt7ikizyexwp5xkg",   
   "public",
   userid,
   null,
   delegate(Client client) {
   ...etc...


That was the called code for the parameters. The issue was hard to spot just because of how simple and stupid it was. I don't know if this was an issue created by Unity when it converted the project to 3.0, or whether it's just a code issue that comes with the package, but the fix is simple.

After
Code: Select all
null,


just add another
Code: Select all
null,


make sure it's before the delegate, and you should be fine.

This is just in case anyone has the same issue. It seems the null just... disappeared. Happy coding :lol:

Also, here's a quick update of what the PlayerIO.Connect call should look like now, in case of any confusion:
Code: Select all
PlayerIOClient.PlayerIO.Connect(
   "mushroomsdemo-lsk7kvt7ikizyexwp5xkg",   
   "public",
   userid,
   null,
   null,
   delegate(Client client) {
   ...etc...
Loftless
 
Posts: 2
Joined: May 23rd, 2011, 8:43 pm

Re: Cannot Convert 'anonymous method'...

Postby Oliver » May 24th, 2011, 5:20 pm

Oh, thanks for that great catch!

We missed that parameter when we added PartnerPay.

It'll be fixed in the next development package.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Cannot Convert 'anonymous method'...

Postby TheMeanPenguin » May 24th, 2011, 10:14 pm

gah! thanks. that saved me a lot of suffering...
User avatar
TheMeanPenguin
 
Posts: 3
Joined: July 8th, 2010, 2:35 am

Re: Cannot Convert 'anonymous method'...

Postby biggthree » May 25th, 2011, 4:13 am

saved me some time i was thinking :mrgreen: it was missing a parameter but hit the forum before i dug deeper good catch my friend!!!!
biggthree
 
Posts: 1
Joined: May 25th, 2011, 4:07 am


Return to Scripting