├── Java
└── unity-keyboard-hack
│ ├── .gitignore
│ ├── .idea
│ ├── .name
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
│ ├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── ru
│ │ │ └── mopsicus
│ │ │ └── keyboardhack
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── ru
│ │ │ │ └── mopsicus
│ │ │ │ └── keyboardhack
│ │ │ │ └── MainActivity.java
│ │ └── res
│ │ │ ├── layout
│ │ │ ├── activity_main.xml
│ │ │ └── content_main.xml
│ │ │ ├── menu
│ │ │ └── menu_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-v21
│ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── ru
│ │ └── mopsicus
│ │ └── keyboardhack
│ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── custominput
│ ├── .gitignore
│ ├── build.gradle
│ ├── libs
│ │ └── classes.jar
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── ru
│ │ │ └── mopsicus
│ │ │ └── custominput
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── ru
│ │ │ │ └── mopsicus
│ │ │ │ └── custominput
│ │ │ │ └── Plugin.java
│ │ └── res
│ │ │ ├── layout
│ │ │ └── input.xml
│ │ │ └── values
│ │ │ └── strings.xml
│ │ └── test
│ │ └── java
│ │ └── ru
│ │ └── mopsicus
│ │ └── custominput
│ │ └── ExampleUnitTest.java
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── LICENSE
├── README.md
└── Unity
├── Assets
├── Plugins.meta
├── Plugins
│ ├── Android.meta
│ ├── Android
│ │ ├── CustomInput.aar
│ │ └── CustomInput.aar.meta
│ ├── NiceJson.cs
│ ├── NiceJson.cs.meta
│ ├── iOS.meta
│ └── iOS
│ │ ├── CustomInput.mm
│ │ └── CustomInput.mm.meta
├── Scenes.meta
├── Scenes
│ ├── Demo.unity
│ └── Demo.unity.meta
├── Scripts.meta
└── Scripts
│ ├── CustomInput.cs
│ ├── CustomInput.cs.meta
│ ├── Demo.cs
│ └── Demo.cs.meta
└── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── NetworkManager.asset
├── Physics2DSettings.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── TagManager.asset
├── TimeManager.asset
└── UnityConnectSettings.asset
/Java/unity-keyboard-hack/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/.name:
--------------------------------------------------------------------------------
1 | KeyboardHack
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "ru.mopsicus.keyboardhack"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.2.1'
26 | compile 'com.android.support:design:23.2.1'
27 | }
28 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/igor/Documents/SDK/android/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/androidTest/java/ru/mopsicus/keyboardhack/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.keyboardhack;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/java/ru/mopsicus/keyboardhack/MainActivity.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.keyboardhack;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 |
21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
22 | fab.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
26 | .setAction("Action", null).show();
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 | // Inflate the menu; this adds items to the action bar if it is present.
34 | getMenuInflater().inflate(R.menu.menu_main, menu);
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | // Handle action bar item clicks here. The action bar will
41 | // automatically handle clicks on the Home/Up button, so long
42 | // as you specify a parent activity in AndroidManifest.xml.
43 | int id = item.getItemId();
44 |
45 | //noinspection SimplifiableIfStatement
46 | if (id == R.id.action_settings) {
47 | return true;
48 | }
49 |
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KeyboardHack
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/app/src/test/java/ru/mopsicus/keyboardhack/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.keyboardhack;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.5.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | provided files('libs/classes.jar')
23 | }
24 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/libs/classes.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/custominput/libs/classes.jar
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/igor/Documents/SDK/android/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/androidTest/java/ru/mopsicus/custominput/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.custominput;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/main/java/ru/mopsicus/custominput/Plugin.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.custominput;
2 |
3 |
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.res.Resources;
7 | import android.graphics.Color;
8 | import android.graphics.Rect;
9 | import android.os.Build;
10 | import android.text.Editable;
11 | import android.text.TextWatcher;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.MotionEvent;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.view.ViewTreeObserver;
18 | import android.view.inputmethod.InputMethodManager;
19 | import android.widget.EditText;
20 | import android.widget.FrameLayout;
21 |
22 | import com.unity3d.player.UnityPlayer;
23 |
24 | import org.json.JSONException;
25 | import org.json.JSONObject;
26 |
27 | public class Plugin {
28 |
29 | JSONObject data;
30 | InputMethodManager inputMethodManager;
31 | View view = null;
32 | Activity context;
33 | boolean multiLinesMode = false;
34 | boolean checkHeight = true;
35 | ViewTreeObserver.OnGlobalLayoutListener listener;
36 | TextWatcher textWatcher;
37 |
38 | public Plugin () {
39 | view = UnityPlayer.currentActivity.getWindow().getCurrentFocus();
40 | data = new JSONObject();
41 | context = UnityPlayer.currentActivity;
42 | inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
43 | listener = new ViewTreeObserver.OnGlobalLayoutListener() {
44 | @Override
45 | public void onGlobalLayout() {
46 | Rect rect = new Rect();
47 | view.getWindowVisibleDisplayFrame(rect);
48 | int screenHeight = view.getRootView().getHeight();
49 | int keypadHeight = screenHeight - rect.bottom;
50 | SendData(1, keypadHeight);
51 | if (checkHeight) {
52 | checkHeight = false;
53 | return;
54 | }
55 | if (keypadHeight == 0)
56 | close();
57 |
58 | }
59 | };
60 | textWatcher = new TextWatcher() {
61 | @Override
62 | public void onTextChanged(CharSequence s, int start, int before, int count) {
63 | if (!multiLinesMode) {
64 | if (s.length() == 0) {
65 | SendData(2, "");
66 | return;
67 | }
68 | char lastchar = s.toString().charAt(s.length()-1);
69 | if (lastchar == '\n')
70 | close();
71 | else
72 | SendData(2, s.toString());
73 | } else
74 | SendData(2, s.toString());
75 | }
76 | @Override
77 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
78 | }
79 | @Override
80 | public void afterTextChanged(Editable s) {
81 | }
82 | };
83 | }
84 |
85 | public void show (final String text, final boolean mode) {
86 | checkHeight = true;
87 | multiLinesMode = mode;
88 | context.runOnUiThread(new Runnable() {
89 | @Override
90 | public void run() {
91 | LayoutInflater inflater = context.getLayoutInflater();
92 | Resources resources = context.getResources();
93 | String packageName = context.getPackageName();
94 | int id = resources.getIdentifier("input", "layout", packageName);
95 | View view = inflater.inflate(id, null);
96 | FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
97 | param.setMargins(2000, 0, 0, 0); // move from screen
98 | context.addContentView(view, param);
99 | initText(text);
100 | }
101 | });
102 | }
103 |
104 | void initText (final String text) {
105 | context.runOnUiThread(new Runnable() {
106 | @Override
107 | public void run() {
108 | Resources resources = context.getResources();
109 | String packageName = context.getPackageName();
110 | final EditText textArea = (EditText)context.findViewById(resources.getIdentifier("textArea", "id", packageName));
111 | textArea.setText(text);
112 | textArea.setBackgroundColor(0x00000000);
113 | textArea.setTextColor(0x00000000);
114 | textArea.addTextChangedListener(textWatcher);
115 | textArea.setFocusableInTouchMode(true);
116 | textArea.requestFocus();
117 | textArea.setCursorVisible(false);
118 | if (!multiLinesMode)
119 | textArea.setMaxLines(1);
120 | // textArea.setOnTouchListener(new View.OnTouchListener() {
121 | // public boolean onTouch(View view, MotionEvent motionEvent) {
122 | // close();
123 | // return false;
124 | // }
125 | // });
126 | inputMethodManager.showSoftInput(textArea, InputMethodManager.SHOW_IMPLICIT);
127 | view.getViewTreeObserver().addOnGlobalLayoutListener(listener);
128 | }
129 | });
130 | }
131 |
132 | public void close () {
133 | inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
134 | SendData(0, null);
135 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
136 | view.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
137 | context.runOnUiThread(new Runnable() {
138 | @Override
139 | public void run() {
140 | Resources resources = context.getResources();
141 | String packageName = context.getPackageName();
142 | EditText textArea = (EditText) context.findViewById(resources.getIdentifier("textArea", "id", packageName));
143 | if (textArea != null) {
144 | ViewGroup viewGroup = (ViewGroup) textArea.getParent();
145 | viewGroup.removeView(textArea);
146 | }
147 | }
148 | });
149 | }
150 |
151 | void SendData (int code, Object info) {
152 | try {
153 | data.remove("code");
154 | data.remove("data");
155 | data.put("code", code);
156 | if (info != null)
157 | data.put("data", info);
158 | } catch (JSONException e) {
159 | e.printStackTrace();
160 | }
161 | UnityPlayer.UnitySendMessage("Plugins", "OnCustomInputAction", data.toString());
162 | }
163 |
164 |
165 | }
166 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/main/res/layout/input.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
21 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CustomInput
3 |
4 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/custominput/src/test/java/ru/mopsicus/custominput/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package ru.mopsicus.custominput;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Java/unity-keyboard-hack/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Java/unity-keyboard-hack/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':custominput'
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Igor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # New realization
2 | https://github.com/mopsicus/UnityMobileInput
3 |
4 | ## unity-keyboard-hack
5 |
6 | Hack for hiding mobile input box on Android (iOS).
7 | Just adding invisible native inputfield and catch entered symbols. Dirty, but works.
8 |
9 | If you know more beautiful solve - tell me.
10 |
11 | Take a look at gameobject "Plugins" in the Demo scene, it requered for receive messages from plugin.
12 |
13 | https://youtu.be/g2YR_NDA7i8
14 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39c9a88b1eceb4d168f99143c0daef26
3 | folderAsset: yes
4 | timeCreated: 1483090609
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/Android.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6b91a57ede8ba4c0997870392649a6d4
3 | folderAsset: yes
4 | timeCreated: 1483090615
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/Android/CustomInput.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/Assets/Plugins/Android/CustomInput.aar
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/Android/CustomInput.aar.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3297f08ecd9b84981aaa51b8ef175d7d
3 | timeCreated: 1483100565
4 | licenseType: Free
5 | PluginImporter:
6 | serializedVersion: 1
7 | iconMap: {}
8 | executionOrder: {}
9 | isPreloaded: 0
10 | isOverridable: 0
11 | platformData:
12 | Android:
13 | enabled: 1
14 | settings: {}
15 | Any:
16 | enabled: 0
17 | settings: {}
18 | Editor:
19 | enabled: 0
20 | settings:
21 | DefaultValueInitialized: true
22 | userData:
23 | assetBundleName:
24 | assetBundleVariant:
25 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/NiceJson.cs:
--------------------------------------------------------------------------------
1 | /*
2 | NiceJson 1.3 (2016-06-28)
3 |
4 | MIT License
5 | ===========
6 |
7 | Copyright (C) 2015 Ángel Quiroga Mendoza
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy of
10 | this software and associated documentation files (the "Software"), to deal in
11 | the Software without restriction, including without limitation the rights to
12 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 | of the Software, and to permit persons to whom the Software is furnished to do
14 | so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 |
27 | Appreciation Contributions:
28 | Rayco Sánchez García
29 | */
30 |
31 | using System;
32 | using System.Collections.Generic;
33 | using System.Collections;
34 | using System.Globalization;
35 |
36 | namespace NiceJson
37 | {
38 | [Serializable]
39 | public abstract class JsonNode
40 | {
41 | protected const char PP_IDENT_CHAR = '\t'; //Modify this to spaces or whatever char you want to be the ident one
42 | protected const int PP_IDENT_COUNT = 1; //Modify this to be the numbers of IDENT_CHAR x identation
43 | protected const bool ESCAPE_SOLIDUS = false; //If you are going to to embed this json in html, you can turn this on ref: http://andowebsit.es/blog/noteslog.com/post/the-solidus-issue/
44 |
45 | protected const char CHAR_CURLY_OPEN = '{';
46 | protected const char CHAR_CURLY_CLOSED = '}';
47 | protected const char CHAR_SQUARED_OPEN = '[';
48 | protected const char CHAR_SQUARED_CLOSED = ']';
49 |
50 | protected const char CHAR_COLON = ':';
51 | protected const char CHAR_COMMA = ',';
52 | protected const char CHAR_QUOTE = '"';
53 |
54 | protected const char CHAR_NULL_LITERAL = 'n';
55 | protected const char CHAR_TRUE_LITERAL = 't';
56 | protected const char CHAR_FALSE_LITERAL = 'f';
57 |
58 | protected const char CHAR_SPACE = ' ';
59 |
60 | protected const char CHAR_BS = '\b';
61 | protected const char CHAR_FF = '\f';
62 | protected const char CHAR_RF = '\r';
63 | protected const char CHAR_NL = '\n';
64 | protected const char CHAR_HT = '\t';
65 | protected const char CHAR_ESCAPE = '\\';
66 | protected const char CHAR_SOLIDUS = '/';
67 | protected const char CHAR_ESCAPED_QUOTE = '\"';
68 |
69 | protected const char CHAR_N = 'n';
70 | protected const char CHAR_R = 'r';
71 | protected const char CHAR_B = 'b';
72 | protected const char CHAR_T = 't';
73 | protected const char CHAR_F = 'f';
74 | protected const char CHAR_U = 'u';
75 |
76 | protected const string STRING_ESCAPED_BS = "\\b";
77 | protected const string STRING_ESCAPED_FF = "\\f";
78 | protected const string STRING_ESCAPED_RF = "\\r";
79 | protected const string STRING_ESCAPED_NL = "\\n";
80 | protected const string STRING_ESCAPED_TAB = "\\t";
81 | protected const string STRING_ESCAPED_ESCAPE = "\\\\";
82 | protected const string STRING_ESCAPED_SOLIDUS = "\\/";
83 | protected const string STRING_ESCAPED_ESCAPED_QUOTE = "\\\"";
84 |
85 | protected const string STRING_SPACE = " ";
86 | protected const string STRING_LITERAL_NULL = "null";
87 | protected const string STRING_LITERAL_TRUE = "true";
88 | protected const string STRING_LITERAL_FALSE = "false";
89 |
90 | protected const string STRING_ESCAPED_UNICODE_INIT = "\\u00";
91 |
92 | //Indexers and accesors
93 | public JsonNode this[string key]
94 | {
95 | get
96 | {
97 | if (this is JsonObject)
98 | {
99 | return ((JsonObject)this)[key];
100 | }
101 | else
102 | {
103 | return null;
104 | }
105 | }
106 |
107 | set
108 | {
109 | if (this is JsonObject)
110 | {
111 | ((JsonObject)this)[key] = value;
112 | }
113 | }
114 | }
115 |
116 | public JsonNode this[int index]
117 | {
118 | get
119 | {
120 | if (this is JsonArray)
121 | {
122 | return ((JsonArray)this)[index];
123 | }
124 | else
125 | {
126 | return null;
127 | }
128 | }
129 |
130 | set
131 | {
132 | if (this is JsonArray)
133 | {
134 | ((JsonArray)this)[index] = value;
135 | }
136 | }
137 | }
138 |
139 | public bool ContainsKey (string key)
140 | {
141 | if (this is JsonObject)
142 | {
143 | return ((JsonObject)this).ContainsKey(key);
144 | }
145 | else
146 | {
147 | return false;
148 | }
149 | }
150 |
151 | //escaping logic
152 |
153 | //Escaping/Unescaping logic
154 | protected static string EscapeString(string s)
155 | {
156 | string result = string.Empty;
157 |
158 | foreach (char c in s)
159 | {
160 | switch (c)
161 | {
162 | case CHAR_ESCAPE:
163 | {
164 | result += STRING_ESCAPED_ESCAPE;
165 | }
166 | break;
167 | case CHAR_SOLIDUS:
168 | {
169 | #pragma warning disable
170 | if (ESCAPE_SOLIDUS)
171 | {
172 | result += STRING_ESCAPED_SOLIDUS;
173 | }
174 | else
175 | {
176 | result += c;
177 | }
178 | #pragma warning restore
179 | }
180 | break;
181 | case CHAR_ESCAPED_QUOTE:
182 | {
183 | result += STRING_ESCAPED_ESCAPED_QUOTE;
184 | }
185 | break;
186 | case CHAR_NL:
187 | {
188 | result += STRING_ESCAPED_NL;
189 | }
190 | break;
191 | case CHAR_RF:
192 | {
193 | result += STRING_ESCAPED_RF;
194 | }
195 | break;
196 | case CHAR_HT:
197 | {
198 | result += STRING_ESCAPED_TAB;
199 | }
200 | break;
201 | case CHAR_BS:
202 | {
203 | result += STRING_ESCAPED_BS;
204 | }
205 | break;
206 | case CHAR_FF:
207 | {
208 | result += STRING_ESCAPED_FF;
209 | }
210 | break;
211 | default:
212 | if (c < CHAR_SPACE)
213 | {
214 | result += STRING_ESCAPED_UNICODE_INIT + Convert.ToByte(c).ToString("x2").ToUpper();
215 | }
216 | else
217 | {
218 | result += c;
219 | }
220 | break;
221 | }
222 | }
223 |
224 | return result;
225 | }
226 |
227 | protected static string UnescapeString(string s)
228 | {
229 | string result = string.Empty;
230 |
231 | for (int i=0;i splittedParts = SplitJsonParts(jsonPart.Substring(1, jsonPart.Length - 2));
403 |
404 | string[] keyValueParts = new string[2];
405 | foreach (string keyValuePart in splittedParts)
406 | {
407 | keyValueParts = SplitKeyValuePart (keyValuePart);
408 | if (keyValueParts [0] != null)
409 | {
410 | jsonObject [JsonNode.UnescapeString (keyValueParts [0])] = ParseJsonPart (keyValueParts [1]);
411 | }
412 | }
413 | jsonPartValue = jsonObject;
414 | }
415 | break;
416 | case JsonNode.CHAR_SQUARED_OPEN:
417 | {
418 | JsonArray jsonArray = new JsonArray();
419 | List splittedParts = SplitJsonParts(jsonPart.Substring(1, jsonPart.Length - 2));
420 |
421 | foreach (string part in splittedParts)
422 | {
423 | if (part.Length > 0)
424 | {
425 | jsonArray.Add (ParseJsonPart (part));
426 | }
427 | }
428 | jsonPartValue = jsonArray;
429 | }
430 | break;
431 | case JsonNode.CHAR_QUOTE:
432 | {
433 | jsonPartValue = new JsonBasic(JsonNode.UnescapeString(jsonPart.Substring(1, jsonPart.Length - 2)));
434 | }
435 | break;
436 | case JsonNode.CHAR_FALSE_LITERAL://false
437 | {
438 | jsonPartValue = new JsonBasic(false);
439 | }
440 | break;
441 | case JsonNode.CHAR_TRUE_LITERAL://true
442 | {
443 | jsonPartValue = new JsonBasic(true);
444 | }
445 | break;
446 | case JsonNode.CHAR_NULL_LITERAL://null
447 | {
448 | jsonPartValue = null;
449 | }
450 | break;
451 | default://it must be a number or it will fail
452 | {
453 | long longValue = 0;
454 | if (long.TryParse(jsonPart, NumberStyles.Any, CultureInfo.InvariantCulture, out longValue))
455 | {
456 | if (longValue > int.MaxValue || longValue < int.MinValue)
457 | {
458 | jsonPartValue = new JsonBasic(longValue);
459 | }
460 | else
461 | {
462 | jsonPartValue = new JsonBasic((int)longValue);
463 | }
464 | }
465 | else
466 | {
467 | decimal decimalValue = 0;
468 | if (decimal.TryParse(jsonPart, NumberStyles.Any, CultureInfo.InvariantCulture, out decimalValue))
469 | {
470 | jsonPartValue = new JsonBasic(decimalValue);
471 | }
472 | }
473 | }
474 | break;
475 | }
476 |
477 | return jsonPartValue;
478 | }
479 |
480 | private static List SplitJsonParts(string json)
481 | {
482 | List jsonParts = new List();
483 | int identLevel = 0;
484 | int lastPartChar = 0;
485 | bool inString = false;
486 |
487 | for (int i = 0; i < json.Length; i++)
488 | {
489 | switch (json[i])
490 | {
491 | case JsonNode.CHAR_COMMA:
492 | {
493 | if (!inString && identLevel == 0)
494 | {
495 | jsonParts.Add(json.Substring(lastPartChar, i - lastPartChar));
496 | lastPartChar = i + 1;
497 | }
498 | }
499 | break;
500 | case JsonNode.CHAR_QUOTE:
501 | {
502 | if (i == 0 || (json[i - 1] != JsonNode.CHAR_ESCAPE))
503 | {
504 | inString = !inString;
505 | }
506 | }
507 | break;
508 | case JsonNode.CHAR_CURLY_OPEN:
509 | case JsonNode.CHAR_SQUARED_OPEN:
510 | {
511 | if (!inString)
512 | {
513 | identLevel++;
514 | }
515 | }
516 | break;
517 | case JsonNode.CHAR_CURLY_CLOSED:
518 | case JsonNode.CHAR_SQUARED_CLOSED:
519 | {
520 | if (!inString)
521 | {
522 | identLevel--;
523 | }
524 | }
525 | break;
526 | }
527 | }
528 |
529 | jsonParts.Add(json.Substring(lastPartChar));
530 |
531 | return jsonParts;
532 | }
533 |
534 | private static string[] SplitKeyValuePart(string json)
535 | {
536 | string[] parts = new string[2];
537 | bool inString = false;
538 |
539 | bool found = false;
540 | int index = 0;
541 |
542 | while (index < json.Length && !found)
543 | {
544 | if (json[index] == JsonNode.CHAR_QUOTE && (index == 0 || (json[index - 1] != JsonNode.CHAR_ESCAPE)))
545 | {
546 | if (!inString)
547 | {
548 | inString = true;
549 | index++;
550 | }
551 | else
552 | {
553 | parts[0] = json.Substring(1, index - 1);
554 | parts[1] = json.Substring(index + 2);//+2 because of the :
555 | found = true;
556 | }
557 | }
558 | else
559 | {
560 | index++;
561 | }
562 | }
563 |
564 | return parts;
565 | }
566 |
567 | private static string RemoveNonTokenChars(string s)
568 | {
569 | int len = s.Length;
570 | char[] s2 = new char[len];
571 | int currentPos = 0;
572 | bool outString = true;
573 | for (int i = 0; i < len; i++)
574 | {
575 | char c = s[i];
576 | if (c == JsonNode.CHAR_QUOTE)
577 | {
578 | if (i == 0 || (s[i - 1] != JsonNode.CHAR_ESCAPE))
579 | {
580 | outString = !outString;
581 | }
582 | }
583 |
584 | if (!outString || (
585 | (c != JsonNode.CHAR_SPACE) &&
586 | (c != JsonNode.CHAR_RF) &&
587 | (c != JsonNode.CHAR_NL) &&
588 | (c != JsonNode.CHAR_HT) &&
589 | (c != JsonNode.CHAR_BS) &&
590 | (c != JsonNode.CHAR_FF)
591 | ))
592 | {
593 | s2[currentPos++] = c;
594 | }
595 | }
596 | return new String(s2, 0, currentPos);
597 | }
598 |
599 | //Object logic
600 |
601 | public abstract string ToJsonString();
602 |
603 | public string ToJsonPrettyPrintString()
604 | {
605 | string jsonString = this.ToJsonString();
606 |
607 | string identStep = string.Empty;
608 | for (int i = 0; i < PP_IDENT_COUNT; i++)
609 | {
610 | identStep += PP_IDENT_CHAR;
611 | }
612 |
613 | bool inString = false;
614 |
615 | string currentIdent = string.Empty;
616 | for (int i = 0; i < jsonString.Length; i++)
617 | {
618 | switch (jsonString[i])
619 | {
620 | case CHAR_COLON:
621 | {
622 | if (!inString)
623 | {
624 | jsonString = jsonString.Insert(i + 1, STRING_SPACE);
625 | }
626 | }
627 | break;
628 | case CHAR_QUOTE:
629 | {
630 | if (i == 0 || (jsonString[i - 1] != CHAR_ESCAPE))
631 | {
632 | inString = !inString;
633 | }
634 | }
635 | break;
636 | case CHAR_COMMA:
637 | {
638 | if (!inString)
639 | {
640 | jsonString = jsonString.Insert(i + 1, CHAR_NL + currentIdent);
641 | }
642 | }
643 | break;
644 | case CHAR_CURLY_OPEN:
645 | case CHAR_SQUARED_OPEN:
646 | {
647 | if (!inString)
648 | {
649 | currentIdent += identStep;
650 | jsonString = jsonString.Insert(i + 1, CHAR_NL + currentIdent);
651 | }
652 | }
653 | break;
654 | case CHAR_CURLY_CLOSED:
655 | case CHAR_SQUARED_CLOSED:
656 | {
657 | if (!inString)
658 | {
659 | currentIdent = currentIdent.Substring(0, currentIdent.Length - identStep.Length);
660 | jsonString = jsonString.Insert(i, CHAR_NL + currentIdent);
661 | i += currentIdent.Length + 1;
662 | }
663 | }
664 | break;
665 | }
666 | }
667 |
668 | return jsonString;
669 | }
670 | }
671 |
672 | [Serializable]
673 | public class JsonBasic : JsonNode
674 | {
675 | public object ValueObject
676 | {
677 | get
678 | {
679 | return m_value;
680 | }
681 | }
682 |
683 | private object m_value;
684 |
685 | public JsonBasic(object value)
686 | {
687 | m_value = value;
688 | }
689 |
690 | public override string ToString()
691 | {
692 | return m_value.ToString();
693 | }
694 |
695 | public override string ToJsonString ()
696 | {
697 | if (m_value == null)
698 | {
699 | return STRING_LITERAL_NULL;
700 | }
701 | else if (m_value is string)
702 | {
703 | return CHAR_QUOTE + EscapeString(m_value.ToString()) + CHAR_QUOTE;
704 | }
705 | else if (m_value is bool)
706 | {
707 | if ((bool) m_value)
708 | {
709 | return STRING_LITERAL_TRUE;
710 | }
711 | else
712 | {
713 | return STRING_LITERAL_FALSE;
714 | }
715 | }
716 | else
717 | {
718 | return m_value.ToString();
719 | }
720 | }
721 |
722 | }
723 |
724 | [Serializable]
725 | public class JsonObject : JsonNode, IEnumerable
726 | {
727 | private Dictionary m_dictionary = new Dictionary();
728 |
729 | public Dictionary.KeyCollection Keys
730 | {
731 | get
732 | {
733 | return m_dictionary.Keys;
734 | }
735 | }
736 |
737 | public Dictionary.ValueCollection Values
738 | {
739 | get
740 | {
741 | return m_dictionary.Values;
742 | }
743 | }
744 |
745 | public new JsonNode this[string key]
746 | {
747 | get
748 | {
749 | return m_dictionary[key];
750 | }
751 |
752 | set
753 | {
754 | m_dictionary[key] = value;
755 | }
756 | }
757 |
758 | public void Add(string key, JsonNode value)
759 | {
760 | m_dictionary.Add(key, value);
761 | }
762 |
763 | public bool Remove(string key)
764 | {
765 | return m_dictionary.Remove(key);
766 | }
767 |
768 | public bool ContainsKey(string key)
769 | {
770 | return m_dictionary.ContainsKey(key);
771 | }
772 |
773 | public bool ContainsValue(JsonNode value)
774 | {
775 | return m_dictionary.ContainsValue(value);
776 | }
777 |
778 | public void Clear()
779 | {
780 | m_dictionary.Clear();
781 | }
782 |
783 | public int Count
784 | {
785 | get
786 | {
787 | return m_dictionary.Count;
788 | }
789 | }
790 |
791 | public IEnumerator GetEnumerator()
792 | {
793 | foreach (KeyValuePair jsonKeyValue in m_dictionary)
794 | {
795 | yield return jsonKeyValue;
796 | }
797 | }
798 |
799 | IEnumerator IEnumerable.GetEnumerator()
800 | {
801 | return GetEnumerator();
802 | }
803 |
804 | public override string ToJsonString ()
805 | {
806 | if (m_dictionary == null)
807 | {
808 | return STRING_LITERAL_NULL;
809 | }
810 | else
811 | {
812 | string jsonString = string.Empty;
813 | jsonString += CHAR_CURLY_OPEN;
814 | foreach (string key in m_dictionary.Keys)
815 | {
816 | jsonString += CHAR_QUOTE+ EscapeString(key) + CHAR_QUOTE+ CHAR_COLON;
817 | if (m_dictionary[key] != null)
818 | {
819 | jsonString += m_dictionary[key].ToJsonString();
820 | }
821 | else
822 | {
823 | jsonString += STRING_LITERAL_NULL;
824 | }
825 |
826 | jsonString += CHAR_COMMA;
827 | }
828 | if (jsonString[jsonString.Length -1] == CHAR_COMMA)
829 | {
830 | jsonString = jsonString.Substring(0,jsonString.Length -1);//removing last ,
831 | }
832 | jsonString+= CHAR_CURLY_CLOSED;
833 |
834 | return jsonString;
835 | }
836 |
837 | }
838 | }
839 |
840 | [Serializable]
841 | public class JsonArray : JsonNode, IEnumerable
842 | {
843 | private List m_list = new List();
844 |
845 | public int Count
846 | {
847 | get
848 | {
849 | return m_list.Count;
850 | }
851 | }
852 |
853 | public new JsonNode this[int index]
854 | {
855 | get
856 | {
857 | return m_list[index];
858 | }
859 |
860 | set
861 | {
862 | m_list[index] = value;
863 | }
864 | }
865 |
866 | public IEnumerator GetEnumerator()
867 | {
868 | foreach (JsonNode value in m_list)
869 | {
870 | yield return value;
871 | }
872 | }
873 |
874 | IEnumerator IEnumerable.GetEnumerator()
875 | {
876 | return GetEnumerator();
877 | }
878 |
879 | //expose some methods of list extends with needs
880 |
881 | public void Add(JsonNode item)
882 | {
883 | m_list.Add(item);
884 | }
885 |
886 | public void AddRange(IEnumerable collection)
887 | {
888 | m_list.AddRange(collection);
889 | }
890 |
891 | public void Insert(int index,JsonNode item)
892 | {
893 | m_list.Insert(index,item);
894 | }
895 |
896 | public void InsertRange(int index,IEnumerable collection)
897 | {
898 | m_list.InsertRange(index,collection);
899 | }
900 |
901 | public void RemoveAt(int index)
902 | {
903 | m_list.RemoveAt(index);
904 | }
905 |
906 | public bool Remove(JsonNode item)
907 | {
908 | return m_list.Remove(item);
909 | }
910 |
911 | public void Clear()
912 | {
913 | m_list.Clear();
914 | }
915 |
916 | //end exposed methods
917 |
918 |
919 | public override string ToJsonString ()
920 | {
921 | if (m_list == null)
922 | {
923 | return STRING_LITERAL_NULL;
924 | }
925 | else
926 | {
927 | string jsonString = string.Empty;
928 | jsonString += CHAR_SQUARED_OPEN;
929 | foreach (JsonNode value in m_list)
930 | {
931 | if (value != null)
932 | {
933 | jsonString+= value.ToJsonString();
934 | }
935 | else
936 | {
937 | jsonString += STRING_LITERAL_NULL;
938 | }
939 |
940 | jsonString += CHAR_COMMA;
941 | }
942 | if (jsonString[jsonString.Length-1] == CHAR_COMMA)
943 | {
944 | jsonString = jsonString.Substring(0,jsonString.Length -1);//removing last ,
945 | }
946 | jsonString+= CHAR_SQUARED_CLOSED;
947 | return jsonString;
948 | }
949 | }
950 | }
951 | }
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/NiceJson.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5f4db44bd296d4277bf555c973cc831f
3 | timeCreated: 1483091348
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/iOS.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8e84fefd6a790463494ac7726389fd63
3 | folderAsset: yes
4 | timeCreated: 1483090622
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/iOS/CustomInput.mm:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | extern UIViewController *UnityGetGLViewController();
5 | extern void UnitySendMessage(const char *obj, const char *method, const char *msg);
6 |
7 | @interface Input : UIViewController {
8 | UITextView *textView;
9 | bool multiLines;
10 | NSMutableDictionary *data;
11 | }
12 | @end
13 |
14 | @implementation Input;
15 |
16 |
17 | - (char *)makeStringCopy:(const char *)string {
18 | return (string == NULL) ? NULL : strcpy((char *)malloc(strlen(string) + 1), string);
19 | }
20 |
21 | - (void)showInput:(NSString *)text mode:(bool)mode {
22 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyboardHide:) name:UIKeyboardWillHideNotification object:nil];
23 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
24 | data = [[NSMutableDictionary alloc] init];
25 | multiLines = mode;
26 | textView = [[UITextView alloc] initWithFrame:CGRectMake(2000, 0, 0, 0)];
27 | [textView setDelegate:self];
28 | [textView setOpaque: NO];
29 | [textView setAutocorrectionType:UITextAutocorrectionTypeNo];
30 | [textView setSpellCheckingType:UITextSpellCheckingTypeNo];
31 | [textView setTextColor:[UIColor clearColor]];
32 | [textView setTintColor:[UIColor clearColor]];
33 | [textView setBackgroundColor:[UIColor clearColor]];
34 | [UnityGetGLViewController().view addSubview:textView];
35 | [textView setText:text];
36 | [textView becomeFirstResponder];
37 | [textView setNeedsDisplay];
38 | }
39 |
40 | -(void)onKeyboardHide:(NSNotification *)notification {
41 | [self close];
42 | }
43 |
44 | -(void)onKeyboardWillShow:(NSNotification *)notification {
45 | NSDictionary *info = notification.userInfo;
46 | NSValue *value = info[UIKeyboardFrameEndUserInfoKey];
47 | CGRect rawFrame = [value CGRectValue];
48 | CGRect keyboardFrame = [self.view convertRect:rawFrame fromView:nil];
49 | CGFloat height = keyboardFrame.size.height;
50 | [self sendData:1 data:[NSNumber numberWithFloat:height]];
51 | }
52 |
53 | - (bool)isLandscape {
54 | UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
55 | return (orientation == 0 || orientation == UIInterfaceOrientationPortrait) ? NO : YES;
56 | }
57 |
58 | - (void)close {
59 | [[NSNotificationCenter defaultCenter] removeObserver:self];
60 | [textView removeFromSuperview];
61 | textView = NULL;
62 | [UnityGetGLViewController().view endEditing:YES];
63 | [self sendData:0 data:NULL];
64 | [self sendData:1 data:[NSNumber numberWithInt:0]];
65 | }
66 |
67 | - (void)textViewDidChange:(UITextView *)tView {
68 | if (!multiLines) {
69 | if ([tView.text length] == 0) {
70 | [self sendData:2 data:@""];
71 | return;
72 | }
73 | unichar lastChar = [tView.text characterAtIndex:[tView.text length] - 1];
74 | if (lastChar == '\n')
75 | [self close];
76 | else
77 | [self sendData:2 data:tView.text];
78 | } else
79 | [self sendData:2 data:tView.text];
80 | }
81 |
82 | - (void)sendData:(int)code data:(NSObject *)info {
83 | [data removeAllObjects];
84 | [data setObject:[NSNumber numberWithInt:code] forKey:@"code"];
85 | if (info != NULL)
86 | [data setObject:info forKey:@"data"];
87 | NSError *error;
88 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:&error];
89 | NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
90 | UnitySendMessage([self makeStringCopy:[@"Plugins" UTF8String]], [self makeStringCopy:[@"OnCustomInputAction" UTF8String]], [self makeStringCopy:[json UTF8String]]);
91 | }
92 |
93 | static Input *input = NULL;
94 |
95 | extern "C" {
96 |
97 | void inputLaunch (const char* text, bool mode) {
98 | if (input == NULL)
99 | input = [[Input alloc] init];
100 | [input showInput:[NSString stringWithUTF8String:text] mode:mode];
101 | }
102 |
103 | void inputClose () {
104 | [input close];
105 | }
106 |
107 | }
108 |
109 |
110 | @end
111 |
--------------------------------------------------------------------------------
/Unity/Assets/Plugins/iOS/CustomInput.mm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b4b4bfc2cc7fa43899e67627432fa4f6
3 | timeCreated: 1483104227
4 | licenseType: Free
5 | PluginImporter:
6 | serializedVersion: 1
7 | iconMap: {}
8 | executionOrder: {}
9 | isPreloaded: 0
10 | isOverridable: 0
11 | platformData:
12 | Any:
13 | enabled: 0
14 | settings: {}
15 | Editor:
16 | enabled: 0
17 | settings:
18 | DefaultValueInitialized: true
19 | iOS:
20 | enabled: 1
21 | settings: {}
22 | userData:
23 | assetBundleName:
24 | assetBundleVariant:
25 |
--------------------------------------------------------------------------------
/Unity/Assets/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 571f48672bda24216a035b9c4df0fe40
3 | folderAsset: yes
4 | timeCreated: 1483090772
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity/Assets/Scenes/Demo.unity:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/Assets/Scenes/Demo.unity
--------------------------------------------------------------------------------
/Unity/Assets/Scenes/Demo.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d7752f13e961a436fb65ad7730df57f3
3 | timeCreated: 1483090765
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Unity/Assets/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 008414e4713af4f7bb6962814c423aa8
3 | folderAsset: yes
4 | timeCreated: 1483090781
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Unity/Assets/Scripts/CustomInput.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Runtime.InteropServices;
4 | using System;
5 | using UnityEngine.UI;
6 | using NiceJson;
7 |
8 | public class CustomInput : MonoBehaviour {
9 |
10 | public delegate void CustomInputEnd (string data = null);
11 | private static CustomInputEnd CustomInputCallBack;
12 |
13 | #if UNITY_ANDROID
14 | private AndroidJavaObject _input;
15 | #elif UNITY_IOS
16 | [DllImport ("__Internal")]
17 | private static extern void inputLaunch (string text, bool mode);
18 | [DllImport ("__Internal")]
19 | private static extern void inputClose ();
20 | #endif
21 |
22 | private static CustomInput _instance;
23 |
24 | void Awake () {
25 | _instance = GetComponent ();
26 | }
27 |
28 | public static void Show (string text, bool multiLines, CustomInputEnd callBack) {
29 | CustomInputCallBack = callBack;
30 | #if UNITY_ANDROID
31 | if (_instance._input != null)
32 | Close ();
33 | _instance._input = new AndroidJavaObject("ru.mopsicus.custominput.Plugin");
34 | _instance._input.Call("show", text, multiLines);
35 | #elif UNITY_IOS
36 | inputLaunch (text, multiLines);
37 | #endif
38 | }
39 |
40 | public static void Close () {
41 | #if UNITY_ANDROID
42 | _instance._input.Call ("close");
43 | _instance._input.Dispose ();
44 | _instance._input = null;
45 | #elif UNITY_IOS
46 | inputClose ();
47 | #endif
48 | }
49 |
50 | void OnCustomInputAction (string data) {
51 | JsonObject info = (JsonObject)JsonNode.ParseJsonString (data);
52 | int code = info ["code"];
53 | switch (code) {
54 | case 0: // close or return for singleline
55 | //
56 | // info["data"] in null
57 | // can send event to save text in PlayerPrefs or send to server
58 | //
59 | if (CustomInputCallBack != null)
60 | CustomInputCallBack ();
61 | break;
62 | case 1: // keyboard height change
63 | //
64 | // in info["data"] contains keyboard height
65 | // can send event to move smth when keyboard hide or show
66 | // e.g. you can use my simple event manager http://mopsicus.ru/all/unity-event-manager-with-parameters/
67 | //
68 | Debug.Log ("keyboard height = " + info["data"]);
69 | break;
70 | case 2: // text input
71 | if (CustomInputCallBack != null)
72 | CustomInputCallBack (info["data"]);
73 | break;
74 | default:
75 | break;
76 | }
77 | }
78 |
79 |
80 | }
--------------------------------------------------------------------------------
/Unity/Assets/Scripts/CustomInput.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5c59e850927d4461186b6acb6706e89f
3 | timeCreated: 1483090798
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Unity/Assets/Scripts/Demo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using UnityEngine.UI;
5 |
6 | public class Demo : MonoBehaviour {
7 |
8 | public void SetSingleListner (Text singleText) {
9 | CustomInput.Show (singleText.text, false, (string data) => {
10 | if (data != null)
11 | singleText.text = data;
12 | else
13 | Debug.Log ("save or send singleText");
14 | });
15 | }
16 |
17 | public void SetMultiListner (Text multiText) {
18 | CustomInput.Show (multiText.text, true, (string data) => {
19 | if (data != null)
20 | multiText.text = data;
21 | else
22 | Debug.Log ("save or send multiText");
23 | });
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Unity/Assets/Scripts/Demo.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0092642dad8c644678f3839d8e90e3ee
3 | timeCreated: 1483090804
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Unity/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/AudioManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/ClusterInputManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/DynamicsManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/EditorBuildSettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/EditorSettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/GraphicsSettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/InputManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/NavMeshAreas.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/NetworkManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/Physics2DSettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/ProjectSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/ProjectSettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 5.5.0f3
2 |
--------------------------------------------------------------------------------
/Unity/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/QualitySettings.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/TagManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/TimeManager.asset
--------------------------------------------------------------------------------
/Unity/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mopsicus/unity-keyboard-hack/5b8fd124e773b90c081557e7b17f5a7381b4891f/Unity/ProjectSettings/UnityConnectSettings.asset
--------------------------------------------------------------------------------