I was passing the UnityPlayer.getView () at the time of the onCreateView
I was able to till Unity4.1.5, no longer able to Unity 4.3.4
I examined, there was a difference following.
UnityPlayer.calss
Unity 4.1.5
public class UnityPlayer extends FrameLayout
implements android.opengl.GLSurfaceView.Renderer, a.a
Unity 4.3.4
public class UnityPlayer extends FrameLayout
implements a.a
I think this is the cause.
Unity 4.3.4 is no way to use the Fragment?
The following is the code I’m using.
package jp.exe.TestFlagment;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.unity3d.player.*;
public class Fragment2 extends Fragment {
private UnityPlayer mUnityPlayer;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d("Fragment2", "onCreateView");
mUnityPlayer = new UnityPlayer(getActivity());
// if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
// getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mUnityPlayer.init(glesMode, trueColor8888);
View playerView = mUnityPlayer.getView();
return playerView;
// setContentView(playerView);
// playerView.requestFocus();
// return inflater.inflate(R.layout.main, null);
}
// UnityPlayer.init() should be called before attaching the view to a layout.
// UnityPlayer.quit() should be the last thing called; it will terminate the process and not return.
public void onCreate (Bundle savedInstanceState)
{
Log.d("Fragment2", "onCreate");
super.onCreate(savedInstanceState);
}
public void onDestroy ()
{
Log.d("Fragment2", "onDestroy");
super.onDestroy();
mUnityPlayer.quit();
}
// onPause()/onResume() must be sent to UnityPlayer to enable pause and resource recreation on resume.
public void onPause()
{
Log.d("Fragment2", "onPause");
super.onPause();
mUnityPlayer.pause();
if (getActivity().isFinishing())
mUnityPlayer.quit();
}
public void onResume()
{
Log.d("Fragment2", "onResume");
super.onResume();
mUnityPlayer.resume();
}
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Pass any keys not handled by (unfocused) views straight to UnityPlayer
public boolean onKeyMultiple(int keyCode, int count, KeyEvent event)
{
return mUnityPlayer.onKeyMultiple(keyCode, count, event);
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
return mUnityPlayer.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
return mUnityPlayer.onKeyUp(keyCode, event);
}
}
Thanks in advance