0

I am building a unity iOS plugin that other developers can integrate in their unity projects. Is it possible to build a unity plugin that loads a UIViewController which can contain UIViews like UICollectionView that show data from web service. Also can that UIViewController come from a xib file? How about handling of iOS auto layouts, will those work from within a unity iOS plugin?

I am new to Unity and it seems to me it only supports .h and .m files indicating that I'll have to programmatically create all uiviews?

Backs
  • 24,430
  • 5
  • 58
  • 85
2cupsOfTech
  • 5,953
  • 4
  • 34
  • 57

1 Answers1

1

After long time spent research, reading I manage to figure out the steps to develop a unity plugin that would work with an existing Objective-C Cocoa Touch Framework binary.

  1. You need to build a regular unity plugin to access Objective-C code. The Lazy Coder has great tutorials on how to do that. I recommend going through the initial few videos before reading further.

  2. Within your .mm file you can access UnityGetGLViewController() which gives you access to the root view controller and now you can load view controllers in your framework binary with something like: [UnityGetGLViewController() presentViewController: animated: completion:nil]; as its of type UIViewController

  3. The Cocoa Touch Framework will be added under Embedded Binaries in the resulting XCode project from Unity build. This is a critical point as I was thinking somehow I will be able to include the framework file within the unity plugin package but I don't think that is possible.

Community
  • 1
  • 1
2cupsOfTech
  • 5,953
  • 4
  • 34
  • 57