x


Pragma Strict Scripting Problem for Time

Hello I'm trying to build my game to my iPhone but it won't let me build cause I didn't use pragma strict scripting. I'm having error with this line: var guiTime = Time.time - startTime; The error being: Operator '-' cannot be used with a left hand side of type 'float' and a right hand side of type 'Object'. How do I get it to work? I have read the unity documentation on Pragma Strict and was wondering whether there are any more examples on Pragma Strict. Thank you so much.

more ▼

asked Sep 07 '11 at 04:12 AM

RamboPanda gravatar image

RamboPanda
16 9 12 13

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

1 answer: sort voted first

It seems that you're not declaring the startTime type. Declare it as a float:

var startTime: float;

And declare guiTime type as float too:

var guiTime: float = Time.time - startTime;
more ▼

answered Sep 07 '11 at 04:33 AM

aldonaletto gravatar image

aldonaletto
42.5k 16 43 202

Thank you it worked!!! :D Cheers!

Sep 07 '11 at 04:37 AM RamboPanda

Technically guiTime doesn't need to be declared as a float, since the other two variables are floats, so it will be automatically typed as a float by type inference.

Sep 07 '11 at 05:12 AM Eric5h5

Oh okay. Noted! Thank you for the advice. :)

Sep 07 '11 at 05:31 AM RamboPanda
(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:

x5272
x32

asked: Sep 07 '11 at 04:12 AM

Seen: 596 times

Last Updated: Sep 07 '11 at 05:31 AM