Unity or Xcode?

I’m working on a spec for an iPhone app and am wondering whether to go with Unity or just write in straight Xcode. I already own Unity iPhone pro and am developing an app (in C#) with it. So my question isn’t about which is easier or whether I need to learn Objective C. The question is about feasibility given the current release of Unity iPhone. Here are some requirements. Can someone tell me whether each can be done with Unity iPhone?

Thanks in advance,

Brian

  • Does the latest version of Unity iPhone support audio streaming? This is a music application, so even with compression, the files will be much too big to download along with the app. If audio streaming is not supported, is there a timeline for when it will be?

  • How do I support features such as the scrollwheel in the calendar application? By the way, is the scrollwheel a standard iPhone sdk feature?

  • Is there some kind of library or sample code available which will allow me to write visual effects similar to those used in Windows Media Player?

Thanks,

Brian

Was there an answer to this? I got an email to that effect but when I clicked the linke, it said “message not found.” Forum problems?

No, I decided to remove my own post again as it is only partially right and highly depends on how much work you are willing to do, because the solution clearly will be pretty hard.

Especially 3 will, until Unity iPhone Advanced allows you to integrate ObjC code into the scripting back end, be a real problem as the audio must be handled on the objc end, while the visualization would be on the unity end, communication through the user preference structure. There are no sample codes or anything alike available as the majority of users likely does not intend to use a game technology for a media player. Also you won’t release such a thing on the iphone, apply will not tolerate any application that competes with their own as the podcast developers have learned the hard way, so if you create a wmp like thing ensure that your product also can survive if you have to cut it.

and no, iphone has no streaming audio support so you would have to do the playback on the objc end if possible at all and sync the visuals as explained above.

I’m no unity employee, but the general thing on timeline is: there is nothing to share unless its already in and ready for release.
As it was not mentioned yet, I wouldn’t expect to see it with Unity iPhone 1.1 actually (and to the majority of the users it likely is pretty much of no importance as the traffic costs on your server the costs for the app users aren’t exactly small on the longer go)

Don’t know which scroll wheel you mean actually, the calendar is nothing more than a “bit” more complex table with a scrolling grid view for the blocks

Thanks for the reply. Here are a couple of follow-ups…

This is not a standard “music player”. It’s more like music a player with specific tracks used to engender a psychoacoustic response. There is at least one other app available that does this. Do you think this will be easier to get through the Apple gates?

I mean the scrolling wheels that allow you to change the date and time when entering or changing a calendar event. Is this standard in the iPhone sdk?

Yes, if it is not directly a music player, then there is not much of a problem with it I think unless apple has that on their plans for the next release.

Its a sad truth that you don’t know if you wasted your time till the date when you try to get it approved …

Ah those wheels.
Yeah they are normal cocoa elements actually

It’s been said that 1.1 will have support for obj-c plugins. But, whether or you’ll be able to use that to stream audio assets in and play them back using unity’s audiosource is questionable. Even streaming aside, I don’t think an app like that would be possible to do in just unity, given the audio api.

Most likely you would have to handle all audio via a plugin that uses apples toolkit. You’d than need to interface back and forth so that you can relay the information back to the visualizer in unity. I tend to imagine this would be a performance nightmare.

The other issue with unity is the load times. Which are reasonable for games, but some applications it’s just overkill.

I wrote a long reply to this yesterday but I don’t see it here. Weird. Anyway, the short version is, Unity is not the right tool for this job. You want streaming audio: you’ll have to roll your own in obj-c. Standard UIKit controls: you’ll have to duplicate them in Unity. Aside from the visualizations (which it sounds like you’re starting from scratch and have no existing Unity code for these, and also, it will not be easy to get audio data over into Unity quickly enough for sound-based visualizations) there’s not much reason to use Unity in this project.

I’ve done an iPhone app with an integrated streaming audio player, and it’s enough of a chore by itself. Integrating that and Unity will make the difficulty level 2x for not much of a gain.

I wrote a long reply to this yesterday but I don’t see it here. Weird. Anyway, the short version is, Unity is not the right tool for this job. You want streaming audio: you’ll have to roll your own in obj-c. Standard UIKit controls: you’ll have to duplicate them in Unity. Aside from the visualizations (which it sounds like you’re starting from scratch and have no existing Unity code for these, and also, it will not be easy to get audio data over into Unity quickly enough for sound-based visualizations) there’s not much reason to use Unity in this project.

I’ve done an iPhone app with an integrated streaming audio player, and it’s enough of a chore by itself. Integrating that and Unity will make the difficulty level 2x for not much of a gain.

stinkbot:
I just want to know how the heck I call the default Apple keyboard from inside Unity. I see you sell a premade obj-set with that and other stuff already included… I just want to know who to do that one little thing…

Any hints?

Well, communicating with Unity and Objective-C is a very interesting and challenging work. I spent some times on it I found that it’s very easy to add most of the functionality of Obj-C in Unity.

  1. First of all you have to go through establish a communication protocol between Obj-C to Unity by PlayerPrefs. It’s the NSUserdefault [not the exact name, find it please].

  2. You will find that in AppController.mm ReJ’s creating his own UIWindow. So, either you have to use your own UIWindow [Like FlashBang, thanks to FlashBang]or you have to control the Rej’s window.

  3. Unity doen’t use default window this is why you will face some problem to use MainWindow.xib file, but you can use it if you configure your app properly.

So, basically what the options you chose, to add a keyboard you need to maintain the UIView. I did a bridge for it and it’s working good. I added:
-Keyboard
-Media Player: I added my own control over it. Even if you want, you can hack the undocumented API function of it. I did my own, pause resume. But it will not permit by apple may be :(.
-Camera

While you add one functionality then it will very easy to add others :slight_smile:

how did you implement your initial bridge to make the two (code / Unity) see each other?

I read somewhere that you should make XCODe constantly monitor a variable and when you set the value in PlayerPrefs some Obj-C function of your choice then executes. How do I define the PlayerPrefs in XCode? Hardcode the place where Unity normally stores Playerprefs? I think it is com.unity.yourappname, isn’t it?

Some VERY basic setup code to get me started on the XCOde side would be highly appreciated…

Yes, this will be a constant monitor but less frequent. You should create a NSTimer and use a callback function with certain interval. In that function you should check the availability.

It’s hard to explain all of it. I will try to post the basic of it. I will recommend to see apple example code. Here you will find all help :).

I used the NSUserdeafult in Obj-C side and PlaerPref in Unity. It’s very nice way to deal it. Even it will give you the power of doing anything in Unity by help of Obj-C.

Unity has some sound problem. I also did control the sound functionality in Obj-C side. Like, if you on/off the silent button in iPhone then there will be no effect in Unity sound, but you can do it by sound session programming. It’s a lot of power, feel it :).

Hey! don’t get me all that excited!!!

My chair is not of the most solid of builds…!
If I keep shivering in anticipation of feeling all that power I will b sitting on my arse pretty soon! :lol: :stuck_out_tongue:

I will be looking into this little feature, be sure of it! I can’t wait to see that sample source you’ll be uploading.

Earlier today I heard that “faking” a key board with an image and 30 GUI.Buttons actually work! I couldn’t believe it, but if it works it works… I think doing it that way is incredibly simple and I was planning on (and might still) do it that way, but if using the ACTUAL iPhone keyboard will take just as much time to do and give me the full array of LOCALIZED characters WITHOUT being a burden on Unity… WOW!!!

Again with the trembling… :roll:

forget unity iphone, use pure objective-c. you don’t need unity for your application.

For your case, you should move to Obj-C. Let, me know if I help you :). [I’m not a Obj-C geek though ;)]

BlackSp1der: I’M CONFUSED…

You mean I don’t need Unity iPhone for my keyboard input or my app? It sounds like you are dissing Unity… Blasphemy!

I am very keen on doing it this way, but my team seem to like the GUI keyboard idea so this gives me some slack in trying to figure this out. No longer pressured to do it by yesterday… but once I figure this out i can’t see me going the GUI route for any other project…

You can do this in Unity by:

1.GUITexture which is a dying case
2. Mapping texture on a keyboard mesh layout

Last one is reasonable. But iPhone Keybaord is the best solution. Moreover, if you don’t need it now or if you want to hold it to end of this month, may be you can get it from Unity. As far as I know, they will give a release it in this month and it will have iPhone key board.

YEAH, 30 GUITextures seems a bit of overkill for this…
Our artist was instructed today to start creating the keyboard image…
I would still prefer to do it using the actual keyboard, but that will only happen if i can figure this out before the other keyboard is implemented…

Problem is, I am not all that clued up on Obj-C. That was why I asked you for some basic Obj-C code so I can see where exactly you insert your code and how you implement the callback. The thing that most confuses me is how you say you use NSDefault in XCode and PlayerPrefs in Unity… How does NSDefault relate to PlayerPrefs?

I heard that the new update might include a keyboard but i had no idea it is coming out this month… How definite is this update?

i used to be a wizz in Pascal, loved Delphi, did a course in C… never got any experience in C++ and couldn’t get to grips with Obj-C now spend my days working in COBOL and my nights working in Unity Script… How sad :frowning:

	// Start listening for signal to return to menus
	[NSTimer scheduledTimerWithTimeInterval:1.0 target:self 
								   selector:@selector(callBack:) 
								   userInfo:nil repeats:YES];

Use this in applicationDidFinishLaunching of AppController.mm

- (void) callBack:(NSTimer *)timer
{
 //Do the checking here	
}

This function will call 1 sec interval as you set 1 in NStimer. To access PlyerPref of Unity

 	[[NSUserDefaults standardUserDefaults] setInteger:value forKey:key]; //to set value
[[NSUserDefaults standardUserDefaults] integerForKey:key]; // to get value

To play a move you can use following code:

-(void)playMovieAtURL:(NSURL*)theURL 
{ 
    MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] 
initWithContentURL:theURL]; 
    theMovie.scalingMode = MPMovieScalingModeAspectFill; 
    theMovie.movieControlMode = MPMovieControlModeHidden; 
    // Register for the playback finished notification. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                selector:@selector(myMovieFinishedCallback:) 
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:theMovie]; 
    // Movie playback is asynchronous, so this method returns immediately. 
    [theMovie play]; 
} 
// When the movie is done, release the controller. 
-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{ 
    MPMoviePlayerController* theMovie = [aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:theMovie]; 
    // Release the movie instance created in playMovieAtURL: 
    [theMovie release]; 
}

Hope that will help.

Another thing is that, you have understand the Obj-C, otherwise it’s hard to do it.