Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Unity-更改启动程序活动_Android_Unity3d - Fatal编程技术网

Android Unity-更改启动程序活动

Android Unity-更改启动程序活动,android,unity3d,Android,Unity3d,我刚刚开始学习团结,所以这似乎是一个愚蠢的问题 我制作了一个小游戏,当设备摄像头看到一个特定的图像时渲染一个角色。我的问题是,我想在unity活动触发之前显示某种菜单。 例如,在我的代码中,我将我的启动器活动更改为我的主要活动,当按下中的开始按钮时,我希望unity活动将被触发(我的设备摄像头将打开)。不幸的是,它不工作(当我按下按钮时,我的应用程序崩溃),我的logcat也没有显示任何内容 这是我的舱单 <manifest xmlns:android="http://schemas.an

我刚刚开始学习团结,所以这似乎是一个愚蠢的问题

我制作了一个小游戏,当设备摄像头看到一个特定的图像时渲染一个角色。我的问题是,我想在unity活动触发之前显示某种菜单。 例如,在我的代码中,我将我的启动器活动更改为我的主要活动,当按下中的开始按钮时,我希望unity活动将被触发(我的设备摄像头将打开)。不幸的是,它不工作(当我按下按钮时,我的应用程序崩溃),我的logcat也没有显示任何内容

这是我的舱单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="imp.diana.samurai"
    android:installLocation="preferExternal"
    android:theme="@android:style/Theme.NoTitleBar"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23" />

    <uses-feature android:name="android.hardware.camera" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature android:glEsVersion="0x00020000" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen.multitouch"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen.multitouch.distinct"
        android:required="false" />

    <android:uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:debuggable="false"
        android:icon="@drawable/app_icon"
        android:isGame="true"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        <activity
            android:name=".UnityPlayerNativeActivity"
            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="fullSensor" >

            <meta-data
                android:name="unityplayer.UnityActivity"
                android:value="true" />
            <meta-data
                android:name="unityplayer.ForwardNativeEventsToDalvik"
                android:value="false" />
        </activity>
        <activity
            android:name="com.unity3d.player.VideoPlayer"
            android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <!--
            To support devices using the TI S3D library for stereo mode we must 
            add the following library.
            Devices that require this are: ODG X6 
        -->
        <uses-library
            android:name="com.ti.s3d"
            android:required="false" />
<!--             To support the ODG R7 in stereo mode we must add the following library. -->
        <uses-library
            android:name="com.osterhoutgroup.api.ext"
            android:required="false" />

        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
    </application>

</manifest> <!-- android:installLocation="preferExternal" -->
单位实用性

public class UnityPlayerActivity extends Activity
{
    protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code

    // Setup activity layout
    @Override protected void onCreate (Bundle savedInstanceState)
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);

        getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy

        mUnityPlayer = new UnityPlayer(this);
        if (mUnityPlayer.getSettings().getBoolean("hide_status_bar", true))
        {
            getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                   WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        setContentView(mUnityPlayer);
        mUnityPlayer.requestFocus();
    }

    // Quit Unity
    @Override protected void onDestroy ()
    {
        mUnityPlayer.quit();
        super.onDestroy();
    }

    // Pause Unity
    @Override protected void onPause()
    {
        super.onPause();
        mUnityPlayer.pause();
    }

    // Resume Unity
    @Override protected void onResume()
    {
        super.onResume();
        mUnityPlayer.resume();
    }

    // This ensures the layout will be correct.
    @Override public void onConfigurationChanged(Configuration newConfig)
    {
        super.onConfigurationChanged(newConfig);
        mUnityPlayer.configurationChanged(newConfig);
    }

    // Notify Unity of the focus change.
    @Override public void onWindowFocusChanged(boolean hasFocus)
    {
        super.onWindowFocusChanged(hasFocus);
        mUnityPlayer.windowFocusChanged(hasFocus);
    }

    // For some reason the multiple keyevent type is not supported by the ndk.
    // Force event injection by overriding dispatchKeyEvent().
    @Override public boolean dispatchKeyEvent(KeyEvent event)
    {
        if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
            return mUnityPlayer.injectEvent(event);
        return super.dispatchKeyEvent(event);
    }

    // Pass any events not handled by (unfocused) views straight to UnityPlayer
    @Override public boolean onKeyUp(int keyCode, KeyEvent event)     { return mUnityPlayer.injectEvent(event); }
    @Override public boolean onKeyDown(int keyCode, KeyEvent event)   { return mUnityPlayer.injectEvent(event); }
    @Override public boolean onTouchEvent(MotionEvent event)          { return mUnityPlayer.injectEvent(event); }
    /*API12*/ public boolean onGenericMotionEvent(MotionEvent event)  { return mUnityPlayer.injectEvent(event); }
}
公共类UnityPlayerPractivity扩展活动
{
受保护的UnityPlayer mUnityPlayer;//不要更改此变量的名称;从本机代码引用
//设置活动布局
@在创建时覆盖受保护的void(Bundle savedInstanceState)
{
requestWindowFeature(窗口。功能\u无\u标题);
super.onCreate(savedInstanceState);

getWindow().setFormat(PixelFormat.rgbx8888);//您可能没有在AndroidManifest.xml文件中使用标记列出
UnityPlayerActivity
,例如

<activity
     android:name=".UnityPlayerActivity"
     android:label="@string/app_name"
     ... 
     >
</activity>

<activity
     android:name=".UnityPlayerActivity"
     android:label="@string/app_name"
     ... 
     >
</activity>