Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
这一句代码不能直接放在
public void ShowMessage(String msg){
Log.e("-------", msg);
// And this is how you call it from the worker thread:
  Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
}
来接收Unity发送过来的消息。
具体是这样的,在继承UnityPlayerActivity或UnityNativePlayerActivity的Activity中:
在onCreate中加入下列代码:

(需要import android.os.Message;)
//处理事件
mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message message) {
// This is where you do your work in the UI thread.
// Your worker tells you in the message what to do.
if(message.what == 1111){
Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
}
}
};

然后在类体中加入
public void ShowMessage(String msg){
Log.e("-------", msg);
// And this is how you call it from the worker thread:
Message message = mHandler.obtainMessage( 1111,msg);
message.sendToTarget();
}