XCode project external files integration

aight, here is a tricky one,

i tested an iPad shaking detector on a separate xcode project using a view controller implementing UIViewController.

now how would i integrate this new view controller to the existing unity’s xcode project.

P.S: yes i am aware of the other “easier” way of trapping accelerometer readings, but it behaves weird when the game starts and the device is vertical.

Just hook it in your unity project and write a plugin binding so you can communicate with the functionality from unity (see manual - advanced topics - plugins)

hmm but i’m supposed to receive a message from the objective-C UIViewController method ( motionBegin ) so i can’t extern that, can i ?

Yes you can, you can send messages into unity

through UnitySendMessage correct ?

but please bare with me on this one, the motionBegin is an event, it makes no sense to extern it since it will be the one sending the message to my unityScript …

i need to override motionBegin along with few others from UIViewController … which is not inherited from in the AppController.h, i tried adding it as a subview with no luck.

You can’t inherit from the appcontroller anyway even if you wanted and it would not make any sense, unity does not use views and viewcontrollers.
All you need to do is make it a .mm file and import AppController.h so you have the declarations present.

In case you don’t need to send out anything to the code you have (to start it in game levels for example and stop it afterwards) you can focus on just doing the sendmessage part to send the information in, no need to call out then (though the call out is rather easy)

so i can’t handle UIViewController events then :frowning:

Sure you can

Your view controller manages them itself and it can send messages. There is no problem about that.

the idea of MVC as its done with UIKit is that you explicitely don’t have 1 totally overbombed class (like you seem to desire which neither makes sense nor is it of use)

also a class must not extend a view to handle events, thats what protocols are for after all

what i don’t understand tho, is why the ( applicationDidFinishLaunching ) overload in the ( iPhone_target2AppDelegate ) even there,
apparently it’s unreachable ( no print outs ) and it is where i’ve been trying to add my subview.

ok here is a step by step description of what i’m trying to do ( an overbombed class is not one of them )

there is an event called ( motionBegin ) i need to handle it.

i did so in a seperate project which includes an app delegate and a view controller

unity generated xcode project has a different structure ( Monkey see, Monkey do … not a real xcode expert )

when i added the 2 view controller files from the working project they did nothing.

i tried to add the code itself to the appcontroller when i found out that it doesn’t support UIViewController which contains the ( motionBegin ) event.

i hope i was able to get my problem through in a better way :slight_smile: