資源簡介
unity android obb

代碼片段和文件信息
package?com.mydemo.test;
import?java.io.File;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.OutputStream;
import?java.util.Set;
import?com.unity3d.player.UnityPlayer;
import?com.unity3d.player.UnityPlayerActivity;
import?android.app.AlertDialog;
import?android.content.Context;
import?android.content.DialogInterface;
import?android.content.Intent;
import?android.os.Bundle;
import?android.os.Handler;
import?android.os.storage.OnObbStateChangeListener;
import?android.os.storage.StorageManager;
import?android.view.KeyEvent;
import?android.content.res.Configuration;
import?android.widget.Toast;
import?android.util.Log;
import?android.view.WindowManager;
import?android.provider.Settings.System;
public?class?MainActivity?extends?UnityPlayerActivity?{
//這些東西都是與google?obb有關的
//拷貝到項目主Activity中
/*?google?obb?*/
public?String?UnityGetObbPath()?{
String?obbPath?=?getObbDir().getPath();
//?Log.v(“debug“obbPath);
return?obbPath;
}
public?String?UnityGetAbsoluteObbPath()?{
String?absobbPath?=?getObbDir().getAbsolutePath();
//?Log.v(“debug““Abs?ObbPath?is?“);
//?Log.v(“debug“absobbPath);
return?absobbPath;
}
public?String?UnityGetMountedPath(String?rawPath)?{
final?StorageManager?storageManager?=?(StorageManager)?getSystemService(STORAGE_SERVICE);
String?mountedObbPath?=?storageManager.getMountedObbPath(rawPath);
return?mountedObbPath;
}
public?boolean?UnityMountObb(String?rawPath)?{
final?StorageManager?storageManager?=?(StorageManager)?getSystemService(STORAGE_SERVICE);
boolean?isAddToQueue?=?storageManager.mountObb(rawPath?null
new?OnObbStateChangeListener()?{
@Override
public?void?onObbStateChange(String?path?int?state)?{
super.onObbStateChange(path?state);
switch?(state)?{
case?ERROR_ALREADY_MOUNTED:
Log.v(“Unity“?“The?OBB?has?already?been?mounted“);
case?ERROR_COULD_NOT_MOUNT:
Log.v(“Unity“
“The?OBB?could?not?be?mounted?by?the?system“);
break;
case?ERROR_COULD_NOT_UNMOUNT:
Log.v(“Unity“?“The?OBB?could?not?be?unmounted“);
break;
case?ERROR_INTERNAL:
Log.v(“Unity“
“There?was?an?internal?system?error?encountered?while?trying?to?mount?the?OBB“);
break;
case?ERROR_NOT_MOUNTED:
Log.v(“Unity“
“A?call?was?made?to?unmount?the?OBB?when?it?was?not?mounted“);
break;
case?ERROR_PERMISSION_DENIED:
Log.v(“Unity“
“The?current?application?does?not?have?permission?to?use?this?OBB“);
break;
case?MOUNTED:
Log.v(“Unity“
“The?OBB?container?is?now?mounted?and?ready?for?use“);
break;
case?UNMOUNTED:
Log.v(“Unity“
“The?OBB?container?is?now?unmounted?and?not?usable.“);
break;
default:
break;
}
}
});
return?isAddToQueu
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3244??2016-04-27?20:42??unity?android?obb\MainActivity.java
?????文件???????3273??2016-04-28?10:19??unity?android?obb\ObbPathUtility.cs
?????目錄??????????0??2016-04-28?10:20??unity?android?obb
-----------?---------??----------?-----??----
?????????????????6517????????????????????3
評論
共有 條評論