diff options
Diffstat (limited to 'unityplugin/Android')
21 files changed, 992 insertions, 0 deletions
diff --git a/unityplugin/Android/.gitignore b/unityplugin/Android/.gitignore new file mode 100644 index 0000000..8334aec --- /dev/null +++ b/unityplugin/Android/.gitignore @@ -0,0 +1,6 @@ +.gradle +.idea +build +local.properties +**/*.iml +.externalNativeBuild
\ No newline at end of file diff --git a/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorApplication.java b/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorApplication.java new file mode 100644 index 0000000..b393e51 --- /dev/null +++ b/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorApplication.java @@ -0,0 +1,47 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.DiligentGraphics.UnityEmulator; + +import javax.microedition.khronos.opengles.GL10; + +import android.app.Application; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.opengl.GLUtils; +import android.util.Log; +import android.widget.Toast; + +public class UnityEmulatorApplication extends Application { + public void onCreate(){ + Log.w("native-activity", "onCreate"); + + final PackageManager pm = getApplicationContext().getPackageManager(); + ApplicationInfo ai; + try { + ai = pm.getApplicationInfo( this.getPackageName(), 0); + } catch (final NameNotFoundException e) { + ai = null; + } + final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)"); + Toast.makeText(this, applicationName, Toast.LENGTH_SHORT).show(); + } +} diff --git a/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorNativeActivity.java b/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorNativeActivity.java new file mode 100644 index 0000000..f49a282 --- /dev/null +++ b/unityplugin/Android/Common/Java/UnityEmulator/UnityEmulatorNativeActivity.java @@ -0,0 +1,164 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.DiligentGraphics.UnityEmulator; + +import android.app.NativeActivity; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup.MarginLayoutParams; +import android.view.WindowManager.LayoutParams; +import android.widget.LinearLayout; +import android.widget.PopupWindow; +import android.widget.TextView; +import android.util.Log; + +public class UnityEmulatorNativeActivity extends NativeActivity { + + static + { + try{ + System.loadLibrary("GraphicsEngineOpenGL"); + Log.i("native-activity", "Loaded GraphicsEngineOpenGL library\n"); + } catch (UnsatisfiedLinkError e) { + Log.e("native-activity", "Failed to load GraphicsEngineOpenGL library\n" + e); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + String pluginName = getString(R.string.plugin_name); + try{ + System.loadLibrary(pluginName); + Log.i("native-activity", "Loaded " + pluginName + " plugin\n"); + } catch (UnsatisfiedLinkError e) { + Log.e("native-activity", "Failed to load " + pluginName + " plugin\n" + e); + } + + //Hide toolbar + int SDK_INT = android.os.Build.VERSION.SDK_INT; + if(SDK_INT >= 19) + { + setImmersiveSticky(); + + View decorView = getWindow().getDecorView(); + decorView.setOnSystemUiVisibilityChangeListener + (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + setImmersiveSticky(); + } + }); + } + } + + protected void onResume() { + super.onResume(); + + //Hide toolbar + int SDK_INT = android.os.Build.VERSION.SDK_INT; + if(SDK_INT >= 11 && SDK_INT < 14) + { + getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN); + } + else if(SDK_INT >= 14 && SDK_INT < 19) + { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LOW_PROFILE); + } + else if(SDK_INT >= 19) + { + setImmersiveSticky(); + } + + } + // Our popup window, you will call it from your C/C++ code later + + void setImmersiveSticky() { + View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + + UnityEmulatorNativeActivity _activity; + PopupWindow _popupWindow; + TextView _label; + + public void showUI() + { + if( _popupWindow != null ) + return; + + _activity = this; + + this.runOnUiThread(new Runnable() { + @Override + public void run() { + LayoutInflater layoutInflater + = (LayoutInflater)getBaseContext() + .getSystemService(LAYOUT_INFLATER_SERVICE); + View popupView = layoutInflater.inflate(R.layout.widgets, null); + _popupWindow = new PopupWindow( + popupView, + LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + + LinearLayout mainLayout = new LinearLayout(_activity); + MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + params.setMargins(0, 0, 0, 0); + _activity.setContentView(mainLayout, params); + + // Show our UI over NativeActivity window + _popupWindow.showAtLocation(mainLayout, Gravity.TOP | Gravity.LEFT, 10, 10); + _popupWindow.update(); + + _label = (TextView)popupView.findViewById(R.id.textViewFPS); + + }}); + } + + protected void onPause() + { + super.onPause(); + if (_popupWindow != null) { + _popupWindow.dismiss(); + _popupWindow = null; + } + } + + public void updateFPS(final float fFPS) + { + if( _label == null ) + return; + + _activity = this; + this.runOnUiThread(new Runnable() { + @Override + public void run() { + _label.setText(String.format("%2.2f FPS", fFPS)); + + }}); + } +} + + diff --git a/unityplugin/Android/Common/Java/helper/NDKHelper.java b/unityplugin/Android/Common/Java/helper/NDKHelper.java new file mode 100644 index 0000000..b7f3a06 --- /dev/null +++ b/unityplugin/Android/Common/Java/helper/NDKHelper.java @@ -0,0 +1,359 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sample.helper; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.nio.ByteBuffer; + +import javax.microedition.khronos.opengles.GL10; + +import android.R.bool; +import android.opengl.GLES30; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.app.NativeActivity; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.Bitmap; +import android.graphics.Bitmap.CompressFormat; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.media.AudioManager; +import android.media.AudioTrack; +import android.opengl.GLUtils; +import android.os.Build; +import android.util.Log; +import android.view.View; +import android.view.View.MeasureSpec; + +@TargetApi(Build.VERSION_CODES.GINGERBREAD) +public class NDKHelper { + + public NDKHelper(NativeActivity act) { + activity = act; + } + + public void loadLibrary(String soname) { + if (soname.isEmpty() == false) { + System.loadLibrary(soname); + loadedSO = true; + } + } + + public static Boolean checkSOLoaded() { + if (loadedSO == false) { + Log.e("NDKHelper", + "--------------------------------------------\n" + + ".so has not been loaded. To use JUI helper, please initialize with \n" + + "NDKHelper::Init( ANativeActivity* activity, const char* helper_class_name, const char* native_soname);\n" + + "--------------------------------------------\n"); + return false; + } else + return true; + } + + private static boolean loadedSO = false; + NativeActivity activity; + + + + // + // Load Bitmap + // Java helper is useful decoding PNG, TIFF etc rather than linking libPng + // etc separately + // + private int nextPOT(int i) { + int pot = 1; + while (pot < i) + pot <<= 1; + return pot; + } + + private Bitmap scaleBitmap(Bitmap bitmapToScale, float newWidth, + float newHeight) { + if (bitmapToScale == null) + return null; + // get the original width and height + int width = bitmapToScale.getWidth(); + int height = bitmapToScale.getHeight(); + // create a matrix for the manipulation + Matrix matrix = new Matrix(); + + // resize the bit map + matrix.postScale(newWidth / width, newHeight / height); + + // recreate the new Bitmap and set it back + return Bitmap.createBitmap(bitmapToScale, 0, 0, + bitmapToScale.getWidth(), bitmapToScale.getHeight(), matrix, + true); + } + + public class TextureInformation { + boolean ret; + boolean alphaChannel; + int originalWidth; + int originalHeight; + Object image; + } + + public Object loadTexture(String path) { + Bitmap bitmap = null; + TextureInformation info = new TextureInformation(); + try { + String str = path; + if (!path.startsWith("/")) { + str = "/" + path; + } + + File file = new File(activity.getExternalFilesDir(null), str); + if (file.canRead()) { + bitmap = BitmapFactory.decodeStream(new FileInputStream(file)); + } else { + bitmap = BitmapFactory.decodeStream(activity.getResources() + .getAssets().open(path)); + } + // Matrix matrix = new Matrix(); + // // resize the bit map + // matrix.postScale(-1F, 1F); + // + // // recreate the new Bitmap and set it back + // bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), + // bitmap.getHeight(), matrix, true); + + } catch (Exception e) { + Log.w("NDKHelper", "Coundn't load a file:" + path); + info.ret = false; + return info; + } + + if (bitmap != null) { + GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); + } + info.ret = true; + info.alphaChannel = bitmap.hasAlpha(); + info.originalWidth = getBitmapWidth(bitmap); + info.originalHeight = getBitmapHeight(bitmap); + + return info; + } + + public Object loadCubemapTexture(String path, int face, int miplevel, boolean sRGB) { + Bitmap bitmap = null; + TextureInformation info = new TextureInformation(); + try { + String str = path; + if (!path.startsWith("/")) { + str = "/" + path; + } + + File file = new File(activity.getExternalFilesDir(null), str); + if (file.canRead()) { + bitmap = BitmapFactory.decodeStream(new FileInputStream(file)); + } else { + bitmap = BitmapFactory.decodeStream(activity.getResources() + .getAssets().open(path)); + } + } catch (Exception e) { + Log.w("NDKHelper", "Coundn't load a file:" + path); + info.ret = false; + return info; + } + + if (bitmap != null) { + if (sRGB) + { +// GLUtils.texImage2D(face, miplevel, bitmap, 0); +// GLUtils.texImage2D(face, miplevel, +// GLUtils.getInternalFormat(bitmap), bitmap, 0); +// int i = GLUtils.getInternalFormat(bitmap); +// if( i == GL10.GL_RGBA) +// { +// GLUtils.texImage2D(face, miplevel, +// GLES30.GL_SRGB, bitmap, 0); +// } + //Leave them for now + GLUtils.texImage2D(face, miplevel, bitmap, 0); + } + else + GLUtils.texImage2D(face, miplevel, bitmap, 0); + } + info.ret = true; + info.alphaChannel = bitmap.hasAlpha(); + info.originalWidth = getBitmapWidth(bitmap); + info.originalHeight = getBitmapHeight(bitmap); + + return info; + + } + + public Object loadImage(String path) { + Bitmap bitmap = null; + TextureInformation info = new TextureInformation(); + try { + String str = path; + if (!path.startsWith("/")) { + str = "/" + path; + } + + File file = new File(activity.getExternalFilesDir(null), str); + if (file.canRead()) { + bitmap = BitmapFactory.decodeStream(new FileInputStream(file)); + } else { + bitmap = BitmapFactory.decodeStream(activity.getResources() + .getAssets().open(path)); + } + } catch (Exception e) { + Log.w("NDKHelper", "Coundn't load a file:" + path); + info.ret = false; + return info; + } + + if (bitmap != null) { + GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); + } + info.ret = true; + info.alphaChannel = bitmap.hasAlpha(); + info.originalWidth = getBitmapWidth(bitmap); + info.originalHeight = getBitmapHeight(bitmap); + + int iBytes = bitmap.getWidth() * bitmap.getHeight() * 4; + ByteBuffer buffer = ByteBuffer.allocateDirect(iBytes); + + bitmap.copyPixelsToBuffer(buffer); + info.image = buffer; + return info; + } + + public Bitmap openBitmap(String path, boolean iScalePOT) { + Bitmap bitmap = null; + try { + bitmap = BitmapFactory.decodeStream(activity.getResources() + .getAssets().open(path)); + if (iScalePOT) { + int originalWidth = getBitmapWidth(bitmap); + int originalHeight = getBitmapHeight(bitmap); + int width = nextPOT(originalWidth); + int height = nextPOT(originalHeight); + if (originalWidth != width || originalHeight != height) { + // Scale it + bitmap = scaleBitmap(bitmap, width, height); + } + } + + } catch (Exception e) { + Log.w("NDKHelper", "Coundn't load a file:" + path); + } + + return bitmap; + } + + public int getBitmapWidth(Bitmap bmp) { + return bmp.getWidth(); + } + + public int getBitmapHeight(Bitmap bmp) { + return bmp.getHeight(); + } + + public void getBitmapPixels(Bitmap bmp, int[] pixels) { + int w = bmp.getWidth(); + int h = bmp.getHeight(); + bmp.getPixels(pixels, 0, w, 0, 0, w, h); + } + + public void closeBitmap(Bitmap bmp) { + bmp.recycle(); + } + + public String getNativeLibraryDirectory(Context appContext) { + ApplicationInfo ai = activity.getApplicationInfo(); + + Log.w("NDKHelper", "ai.nativeLibraryDir:" + ai.nativeLibraryDir); + + if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0 + || (ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { + return ai.nativeLibraryDir; + } + return "/system/lib/"; + } + + public String getApplicationName() { + final PackageManager pm = activity.getPackageManager(); + ApplicationInfo ai; + try { + ai = pm.getApplicationInfo(activity.getPackageName(), 0); + } catch (final NameNotFoundException e) { + ai = null; + } + String applicationName = (String) (ai != null ? pm + .getApplicationLabel(ai) : "(unknown)"); + return applicationName; + } + + public String getStringResource(String resourceName) + { + int id = activity.getResources().getIdentifier(resourceName, "string", activity.getPackageName()); + String value = id == 0 ? "" : (String)activity.getResources().getText(id); + return value; + } + + // + // Audio related helpers + // + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) + public int getNativeAudioBufferSize() { + int SDK_INT = android.os.Build.VERSION.SDK_INT; + if (SDK_INT >= 17) { + AudioManager am = (AudioManager) activity + .getSystemService(Context.AUDIO_SERVICE); + String framesPerBuffer = am + .getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); + return Integer.parseInt(framesPerBuffer); + } else { + return 0; + } + } + + public int getNativeAudioSampleRate() { + return AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM); + } + + /* + * Helper to execute function in UIThread + */ + public void runOnUIThread(final long p) { + if (checkSOLoaded()) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + RunOnUiThreadHandler(p); + } + }); + } + return; + } + + /* + * Native code helper for RunOnUiThread + */ + native public void RunOnUiThreadHandler(long pointer); +}
\ No newline at end of file diff --git a/unityplugin/Android/GhostCubeScene/build.gradle b/unityplugin/Android/GhostCubeScene/build.gradle new file mode 100644 index 0000000..886985f --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/build.gradle @@ -0,0 +1,44 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion = 25 + + defaultConfig { + applicationId = 'com.DiligentGraphics.UnityEmulator.UnityEmulatorApplication' + minSdkVersion 21 + targetSdkVersion 25 + ndk { + abiFilters 'armeabi-v7a'//, 'armeabi', 'arm64-v8a','x86', 'x86_64' + } + externalNativeBuild { + cmake { + arguments '-DANDROID_PLATFORM=android-21', + '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static' + } + } + } + buildTypes { + release { + minifyEnabled = false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path '../../../CMakeLists.txt' + } + } + sourceSets { + main { + java.srcDirs = ['../Common/Java'] + assets.srcDirs = ['../../GhostCubeScene/build/assets'] + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:25.4.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.1' +} diff --git a/unityplugin/Android/GhostCubeScene/src/main/AndroidManifest.xml b/unityplugin/Android/GhostCubeScene/src/main/AndroidManifest.xml new file mode 100644 index 0000000..bc885c2 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" +package="com.DiligentGraphics.UnityEmulator" +android:versionCode="1" +android:versionName="1.0" > + +<uses-feature android:glEsVersion="0x00030000" android:required="true"></uses-feature> +<application + android:allowBackup="false" + android:fullBackupContent="false" + android:supportsRtl="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" + android:name="com.DiligentGraphics.UnityEmulator.UnityEmulatorApplication" + > + + <!-- Our activity is the built-in NativeActivity framework class. + This will take care of integrating with our NDK code. --> + <activity android:name="com.DiligentGraphics.UnityEmulator.UnityEmulatorNativeActivity" + android:label="@string/app_name" + android:configChanges="orientation|keyboardHidden"> + <!-- Tell NativeActivity the name of our .so --> + <meta-data android:name="android.app.lib_name" + android:value="GhostCubeScene" /> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> +</application> +</manifest> diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/layout/widgets.xml b/unityplugin/Android/GhostCubeScene/src/main/res/layout/widgets.xml new file mode 100644 index 0000000..b6e86e6 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/layout/widgets.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="top" + android:orientation="vertical" > + + <TextView + android:id="@+id/textViewFPS" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="end" + android:text="@string/fps" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@android:color/white" /> + +</LinearLayout>
\ No newline at end of file diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-hdpi/ic_launcher.png b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..cde69bc --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-mdpi/ic_launcher.png b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..c133a0c --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xhdpi/ic_launcher.png b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..bfa42f0 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xxhdpi/ic_launcher.png b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..324e72c --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/values-v11/styles.xml b/unityplugin/Android/GhostCubeScene/src/main/res/values-v11/styles.xml new file mode 100644 index 0000000..541752f --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/values-v11/styles.xml @@ -0,0 +1,11 @@ +<resources> + + <!-- + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> + <!-- API 11 theme customizations can go here. --> + </style> + +</resources>
\ No newline at end of file diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/values-v14/styles.xml b/unityplugin/Android/GhostCubeScene/src/main/res/values-v14/styles.xml new file mode 100644 index 0000000..f20e015 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/values-v14/styles.xml @@ -0,0 +1,12 @@ +<resources> + + <!-- + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> + <!-- API 14 theme customizations can go here. --> + </style> + +</resources>
\ No newline at end of file diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/values/strings.xml b/unityplugin/Android/GhostCubeScene/src/main/res/values/strings.xml new file mode 100644 index 0000000..546c209 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ +<resources> + + <string name="app_name">Ghost Cube Scene Unity Emulator</string> + <string name="plugin_name">GhostCubePlugin</string> + <string name="fps">0.0 FPS</string> + +</resources>
\ No newline at end of file diff --git a/unityplugin/Android/GhostCubeScene/src/main/res/values/styles.xml b/unityplugin/Android/GhostCubeScene/src/main/res/values/styles.xml new file mode 100644 index 0000000..4a10ca4 --- /dev/null +++ b/unityplugin/Android/GhostCubeScene/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Light"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources>
\ No newline at end of file diff --git a/unityplugin/Android/build.gradle b/unityplugin/Android/build.gradle new file mode 100644 index 0000000..a4ea174 --- /dev/null +++ b/unityplugin/Android/build.gradle @@ -0,0 +1,17 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/unityplugin/Android/gradle/wrapper/gradle-wrapper.jar b/unityplugin/Android/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..13372ae --- /dev/null +++ b/unityplugin/Android/gradle/wrapper/gradle-wrapper.jar diff --git a/unityplugin/Android/gradle/wrapper/gradle-wrapper.properties b/unityplugin/Android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0fd14b1 --- /dev/null +++ b/unityplugin/Android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Dec 17 12:46:29 PST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/unityplugin/Android/gradlew b/unityplugin/Android/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/unityplugin/Android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/unityplugin/Android/gradlew.bat b/unityplugin/Android/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/unityplugin/Android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/unityplugin/Android/settings.gradle b/unityplugin/Android/settings.gradle new file mode 100644 index 0000000..38b61d6 --- /dev/null +++ b/unityplugin/Android/settings.gradle @@ -0,0 +1 @@ +include ':GhostCubeScene' |
