Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by reid1256 · Jul 09, 2015 at 01:19 PM · controllerplugin

How do I Edit Moga Plugin to Work with Unity 5

I tried the plug in with Unity 4 as a test and it worked successfully but I get a message when I import into Unity 5 "this plugin is using obsolete APIs"

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by spmonahan · Sep 23, 2015 at 11:43 AM

I got this warning as well but just clicked the "ok" (or whatever it's called) button and had Unity do its auto-update procedure for updating assets.

After this I deleted the Windows Phone stuff in the Assets/Plugins folder as it was throwing a bunch of errors and I only care about supporting Android for my current project. I expect the issues with Windows Phone are fixable if they matter to you. At this point I was able to build and run the test scene successfully on an Android device but the controller wasn't being recognized.

The first issue I had was that I needed to installed the Moga Pivot app and sync the controller to the device. Once I did this...still no joy. So I dug into a bunch of Google results and eventually found this.

I won't completely regurgitate the post here but the gist is that APIs on the Android side of things changed which broke Moga support in Unity. Unfortunately the code in question is inside a compiled jar and would be a pain to update, however, the article describes a fix on the C# side that fixed everything for me and got the Moga working with my Android device in a Unity app.

The solution is to replace the init() method in Moga_Controller.cs with the following:

public bool init() { //return mController.Call<bool>("init"); bool mIsBound = mController.Get<bool>("mIsBound"); // We're going to manually initialize the moga controller due to MOGA's method not working on Lollipop. Debug.Log("MOGA manual lollipop initialization!"); if (!mIsBound) { AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", "com.bda.controller.IControllerService"); // Set the intent to be explicit to fix Moga not supporting lollipop. intent.Call<AndroidJavaObject>("setPackage", "com.bda.pivot.mogapgp"); AndroidJavaObject mContext = mController.Get<AndroidJavaObject>("mContext"); mContext.Call<AndroidJavaObject>("startService", intent); bool result = mContext.Call<bool>("bindService", intent, mController.Get<AndroidJavaObject>("mServiceConnection"), 1); mController.Set("mIsBound", true); mIsBound = true; Debug.Log("MOGA initialization succeeded!"); } return mIsBound; }

For reference I'm using Unity 5.2.0f3 Personal (on a Mac). My controller is the Moga Pocket. My Android device is a Samsung Galaxy S5 running Android 5.0.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to make a P2P Unity Android Game 0 Answers

Unity to Arduino through Unity App 1 Answer

Using Android plugin to access android controller information. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges