- Home /
Unity Iphone "It is not possible to invoke an expression of type 'Object'.
I'm trying to rewrite all my code without using dynamic typing as I just installed Unity Iphone and need all of my scripts to exist without dynamic typing.
I am having a rough time converting everything as I am quite the amature at scripting, currently I'm having a hard time with the following lines (they are from a timer script I found on the wiki/forums):
if (f_timer_done) {
f_timer_done();
}
I get the following error:
"It is not possible to invoke an expression of type 'Object'."
. . . and it points to the second line above (the one with f_timer_done();)
How do I resolve this error?
Answer by Mike 3 · May 31, 2010 at 07:44 AM
Since it's not using dynamic typing, it's confused as to what type the object is
Your best bet will be to assign a function to it at the start, so it knows what sort of delegate it needs (e.g. add a function called Blank which takes no parameters and does nothing, then do var f_timer_done = Blank; )
That should hopefully kick it into gear
Edit to make it a little clearer:
var f_timer_done = Blank; //this variable should already be in your code at the top
function Blank() { }
When I literally make a function toward the top of the script that states:
function Blank()
{
var f_timer_done=Blank;
}
Nothing changes, the code still spits out the same error as above. What did I misunderstand here?
Or did you mean to put a "function Blank()" at the top of the script, and then do "var f_timer_done=Blank; after "if (f_timer_done){"
I ask because when I do that, the error goes away. I do not quite understand why though, nor do I know if the script will still function as I intend.
no, not like that - there should already be an f_timer_done variable at the top - assign Blank to that
Your answer
Follow this Question
Related Questions
It is not possible to invoke an expression of type 'SpriteManager[]'. 1 Answer
Animation not playing when returning to a previous loaded scene 2 Answers
signal 11 (SIGSEGV), fault 2 Answers
Ani.Mate error when port a PC game to iPhone 2 Answers
What prevents an app from hitting a link that works in browser? 1 Answer