在Android应用程序中无法使用unity 3d播放视频

时间:2014-01-01 12:40:00

标签: android

我正在尝试将Unity 3d与android集成并播放旋转cuebe,问题是当我运行应用程序时我只得到空白活动..请帮我找到任何解决方案

         import android.app.Activity;
         import android.os.Bundle;
         import android.view.View;
         import android.view.WindowManager;
         import android.widget.FrameLayout;
          import android.widget.LinearLayout.LayoutParams;
         import com.unity3d.player.UnityPlayer;
        public class MainActivity extends Activity{
    //setContentView(R.layout.main);
    private UnityPlayer mUnityPlayer;
    @Override
    public void onCreate(Bundle savedInstanceState) { 

            super.onCreate(savedInstanceState);
        mUnityPlayer = new UnityPlayer(this);
       // mUnityPlayer.setScreenSize(300, 250, true);
        if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))

            getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,

                                   WindowManager.LayoutParams.FLAG_FULLSCREEN);

        View playview=(View)findViewById(R.id.view1);
        playview=mUnityPlayer.getView();
        int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);

        boolean trueColor8888 = false;
        mUnityPlayer.init(glesMode, trueColor8888); 
        setContentView(R.layout.main);
        FrameLayout layout = (FrameLayout) findViewById(R.id.framelayout2);     
        LayoutParams lp = new LayoutParams (LayoutParams.FILL_PARENT,          LayoutParams.FILL_PARENT);
        layout.addView(playview, 0, lp); 
}
           @Override
          public void onBackPressed() {
         // TODO Auto-generated method stub
          super.onBackPressed();
  }

 }

1 个答案:

答案 0 :(得分:0)

我认为您需要使用UnityPlayerActivity扩展活动,并在清单文件<activity android:name="com.unity3d.player.yourpackagename" >中添加此活动,它应该是您的主要活动。