x


xCode to Unity communication?

Hey everybody,

The guys at Unity have done a great job implementing access to plug-in's through Unity iPhone. But I was wondering if there was a way to communicate the other way. For example, if I would like to respond to the user pushing the sleep button on the top of their device by responding to the "applicationWillResignActive" delegate.

Is there a way that I can tell Unity that this happened when it happened?

Thanks,

-Phil

more ▼

asked Feb 02 '10 at 08:45 PM

user-1104 gravatar image

user-1104
21 1 1 3

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

1 answer: sort voted first

The easiest way to do this is to do polling on the Unity side of things.

One way to do it is use the PlayerPrefs. Unity iPhone has this handy hack that the PlayerPrefs (on the Unity side of things) and the NSUserDefaults (on the Objective C side) are basically the same thing. So you could store data in there and poll it from within Unity.

Or you could set up something yourself where you call a function from within Unity that essentially is a native function you wrote that returns whether or not that particular callback happened. This one requires Unity iPhone Advanced.

Another way to do it that involves calling mono functions directly is described here: http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/ and discussed on this forum post http://forum.unity3d.com/viewtopic.php?t=41092

more ▼

answered Feb 03 '10 at 08:23 PM

Tetrad gravatar image

Tetrad
7.3k 27 37 89

(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:

x409
x351
x46
x44

asked: Feb 02 '10 at 08:45 PM

Seen: 6515 times

Last Updated: Feb 02 '10 at 08:45 PM