3

A menu button appeared on my app

As seen above, a menu button appears when I run my app. I want to hide the button as usual. I didn't know this problem till I changed my phone to Nexus5 using soft keys. I developed this app in Unity3d, and there was no code receiving messages from soft keys except a back button. Of course, nothing happens when I push the menu button. How can I control configuration about this in an Unity project?

2
  • That menu doesn't normally appear in Unity Android apps as far as I know (not seeing it on my device). Have you added any plugins to your build that might be adding this? What comes up when you tap that menu?
    – Calvin
    Nov 28, 2013 at 20:01
  • I didn't install any plugins and nothing happens when I tap the menu as I wrote the text.
    – Dish
    Nov 30, 2013 at 2:04

2 Answers 2

3
  1. Go to Unity -> File -> Build Setting… -> Switch Platform to Android. Then, select Player Settings -> Bundle Identifier -> Copy Bundle Identifier.

  2. Go to Assets/Plugins/Android

Create new file AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<application
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:debuggable="true">
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
              android:launchMode="singleTask"
              android:label="@string/app_name"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
</application>
</manifest>

Or you can go to /Applications/Unity/Unity.app/Contents/PlaybackEngines And copy file AndroidManifest.xml, and then adding

   <uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="14" />

Note: targetSdkVersion >=14 is Ok, (i.e: 15, 16…)

Rebuild your app

Good luck!

1
  • Good, they was unintentionally set to 6, both of the android:minSdkVersion and targetSdkVersion. Then I removed the uses-sdk tag instead of increasing version numbers, and it worked! Thank you!
    – Dish
    May 24, 2014 at 23:44
2

Unity handles those with KeyCode.Escape and KeyCode.Menu.

void Update() {
    if (Input.GetKeyDown(KeyCode.Escape)) {
        //user pressed back key
    }

    if (Input.GetKeyDown(KeyCode.Menu)) {
        //user pressed menu key
    }
}

If you want to hide the softkeys, you might try this suggestion from the forums.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.