Skip to content

Commit a3b80e0

Browse files
committed
added Camera/Media UI
1 parent 87bc4ab commit a3b80e0

File tree

9 files changed

+3103
-36
lines changed

9 files changed

+3103
-36
lines changed

UnityNativeToolkit/Assets/NativeToolkit.unity

Lines changed: 2939 additions & 0 deletions
Large diffs are not rendered by default.

UnityNativeToolkit/Assets/NativeToolkit.unity.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

UnityNativeToolkit/Assets/Scripts/Plugins/NativeToolkit/NativeToolkit.cs

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,48 @@
11
using System.Collections;
22
using System.IO;
33
using System.Text;
4+
using TMPro;
45
using UnityEngine;
56
using UnityEngine.UI;
67
using static NativeToolkitPlugin;
78

89
public class NativeToolkit : MonoBehaviour, INativeToolkitPlugin
910
{
1011
private NativeToolkitPlugin plugin = null;
11-
public Button btn = null;
12-
public Button btn_bot = null;
13-
public Button btn_bot2 = null;
14-
public Texture2D target = null;
15-
public RawImage rawImage = null;
12+
13+
public TextMeshProUGUI resultText = null;
14+
[Header("Camera/Media")]
15+
public Button takeShot_btn = null;
16+
public Button visualizeShot_btn = null;
17+
public RawImage shotRawImg = null;
18+
[Space()]
19+
public Button pickPhotoFromGallery_btn = null;
20+
public Button visualizeGalleryPhoto_btn = null;
21+
public RawImage galleryPhotoImg = null;
22+
[Space()]
23+
public Toggle saveShotsOnGallery = null;
24+
public Toggle saveShotsOnPrivateDirectory = null;
25+
private string shotPath = "";
26+
private string galleryPhotoPath = "";
1627

1728
void Start()
1829
{
1930
plugin = NativeToolkitPlugin.GetPlatformPluginVersion(this.gameObject.name);
20-
21-
btn.onClick.AddListener(() => plugin.ShareText("Title of sharing", "https://github.com/EricBatlle"));
22-
btn_bot.onClick.AddListener(() => {
23-
plugin.Speak("Hello Eric, either you got a missile? Can you please say something longer to check if this is working? Thanks!", "en", "US");
24-
});
25-
btn_bot2.onClick.AddListener(() => {
26-
plugin.Speak("Hello Eric, either you got a missile? Can you please say something longer to check if this is working? Thanks!", "en", "IE");
27-
});
31+
//Camera/Media
32+
takeShot_btn.onClick.AddListener(() => { plugin.TakeShot(); });
33+
visualizeShot_btn.onClick.AddListener(() => { shotRawImg.texture = LoadPNG(shotPath); });
34+
visualizeGalleryPhoto_btn.onClick.AddListener(() => { galleryPhotoImg.texture = LoadPNG(galleryPhotoPath); });
35+
saveShotsOnGallery.onValueChanged.AddListener((isOn) => { plugin.SaveShotsOnGallery(isOn); });
36+
saveShotsOnPrivateDirectory.onValueChanged.AddListener((isOn) => { plugin.SaveShotsOnGallery(isOn); });
37+
pickPhotoFromGallery_btn.onClick.AddListener(() => { plugin.PickPhotoFromGallery(); });
38+
//
39+
}
40+
41+
public void SetResultText(string result)
42+
{
43+
resultText.text = result;
2844
}
45+
2946
public static Texture2D LoadPNG(string filePath)
3047
{
3148
Texture2D tex = null;
@@ -49,42 +66,46 @@ public void OnResult(string recognizedResult)
4966
Debug.Log(recognizedResult);
5067
//rawImage.texture = LoadPNG(recognizedResult);
5168
}
69+
5270
#region FeaturesCallbacks
53-
public void OnDialogPositive(string result)
71+
#region Camera/Media
72+
public void OnShotTaken(string shotPath)
5473
{
55-
Debug.Log(result);
74+
SetResultText("Shot taken and saved in: " + shotPath);
75+
this.shotPath = shotPath;
5676
}
5777

58-
public void OnDialogNegative(string result)
78+
public void OnGalleryPhotoPicked(string galleryPhotoPath)
5979
{
60-
Debug.Log(result);
80+
SetResultText("Photo picked from: " + galleryPhotoPath);
81+
this.galleryPhotoPath = galleryPhotoPath;
6182
}
62-
63-
public void OnDialogNeutral(string result)
83+
#endregion
84+
public void OnDialogPositive(string result)
6485
{
6586
Debug.Log(result);
6687
}
6788

68-
public void OnDatePicked(string result)
89+
public void OnDialogNegative(string result)
6990
{
7091
Debug.Log(result);
7192
}
7293

73-
public void OnTimePicked(string result)
94+
public void OnDialogNeutral(string result)
7495
{
7596
Debug.Log(result);
7697
}
7798

78-
public void OnShotTaken(string result)
99+
public void OnDatePicked(string result)
79100
{
80101
Debug.Log(result);
81102
}
82103

83-
public void OnGalleryPhotoPicked(string result)
104+
public void OnTimePicked(string result)
84105
{
85106
Debug.Log(result);
86107
}
87-
108+
88109
public void OnRatedApp(string result)
89110
{
90111
Debug.Log(result);

UnityNativeToolkit/Assets/Scripts/Plugins/NativeToolkit/NativeToolkitPlugin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public interface INativeToolkitPlugin : INativeCamera, INativeDialog, INativeCon
3131
{
3232
void OnResult(string result);
3333
}
34+
protected abstract void SetUp();
3435

3536
//Features
3637
#region Camera/Media
3738
public interface INativeCamera
3839
{
39-
void OnShotTaken(string result);
40-
void OnGalleryPhotoPicked(string result);
40+
void OnShotTaken(string shotPath);
41+
void OnGalleryPhotoPicked(string galleryPhotoPath);
4142
}
42-
protected abstract void SetUp();
4343
public abstract void TakeShot();
4444
public abstract void SaveShotsOnGallery(bool saveShotsOnGallery);
4545
public abstract void SaveShotsOnPrivateDirectory(bool saveShotsOnPrivateDirectory);

UnityNativeToolkit/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF.asset

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Material:
99
m_PrefabAsset: {fileID: 0}
1010
m_Name: LiberationSans SDF Material
1111
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
12-
m_ShaderKeywords:
12+
m_ShaderKeywords: UNDERLAY_ON
1313
m_LightmapFlags: 1
1414
m_EnableInstancingVariants: 0
1515
m_DoubleSidedGI: 0
@@ -34,7 +34,7 @@ Material:
3434
- _PerspectiveFilter: 0.875
3535
- _ScaleRatioA: 0.9
3636
- _ScaleRatioB: 1
37-
- _ScaleRatioC: 0.73125
37+
- _ScaleRatioC: 0.365625
3838
- _ScaleX: 1
3939
- _ScaleY: 1
4040
- _ShaderFlags: 0
@@ -46,9 +46,9 @@ Material:
4646
- _StencilWriteMask: 255
4747
- _TextureHeight: 1024
4848
- _TextureWidth: 1024
49-
- _UnderlayDilate: 0
50-
- _UnderlayOffsetX: 0
51-
- _UnderlayOffsetY: 0
49+
- _UnderlayDilate: 1
50+
- _UnderlayOffsetX: 1
51+
- _UnderlayOffsetY: 1
5252
- _UnderlaySoftness: 0
5353
- _VertexOffsetX: 0
5454
- _VertexOffsetY: 0
@@ -7798,6 +7798,7 @@ Texture2D:
77987798
m_TextureFormat: 1
77997799
m_MipCount: 1
78007800
m_IsReadable: 0
7801+
m_IgnoreMasterTextureLimit: 0
78017802
m_StreamingMipmaps: 0
78027803
m_StreamingMipmapsPriority: -92
78037804
m_AlphaIsTransparency: 0

UnityNativeToolkit/ProjectSettings/EditorBuildSettings.asset

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
EditorBuildSettings:
55
m_ObjectHideFlags: 0
66
serializedVersion: 2
7-
m_Scenes: []
7+
m_Scenes:
8+
- enabled: 1
9+
path: Assets/NativeToolkit.unity
10+
guid: 9fc0d4010bbf28b4594072e72b8655ab
811
m_configObjects: {}

UnityNativeToolkit/ProjectSettings/GraphicsSettings.asset

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ GraphicsSettings:
3535
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
3636
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
3737
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38+
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
39+
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
40+
- {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0}
41+
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
3842
m_PreloadedShaders: []
3943
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
4044
type: 0}

UnityNativeToolkit/ProjectSettings/ProjectSettings.asset

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PlayerSettings:
1212
targetDevice: 2
1313
useOnDemandResources: 0
1414
accelerometerFrequency: 60
15-
companyName: DefaultCompany
15+
companyName: Eric
1616
productName: UnityNativeToolkit
1717
defaultCursor: {fileID: 0}
1818
cursorHotspot: {x: 0, y: 0}
@@ -165,7 +165,7 @@ PlayerSettings:
165165
applicationIdentifier: {}
166166
buildNumber: {}
167167
AndroidBundleVersionCode: 1
168-
AndroidMinSdkVersion: 19
168+
AndroidMinSdkVersion: 24
169169
AndroidTargetSdkVersion: 0
170170
AndroidPreferredInstallLocation: 1
171171
aotOptions:
@@ -274,7 +274,99 @@ PlayerSettings:
274274
AndroidValidateAppBundleSize: 1
275275
AndroidAppBundleSizeToValidate: 150
276276
m_BuildTargetIcons: []
277-
m_BuildTargetPlatformIcons: []
277+
m_BuildTargetPlatformIcons:
278+
- m_BuildTarget: Android
279+
m_Icons:
280+
- m_Textures: []
281+
m_Width: 432
282+
m_Height: 432
283+
m_Kind: 2
284+
m_SubKind:
285+
- m_Textures: []
286+
m_Width: 324
287+
m_Height: 324
288+
m_Kind: 2
289+
m_SubKind:
290+
- m_Textures: []
291+
m_Width: 216
292+
m_Height: 216
293+
m_Kind: 2
294+
m_SubKind:
295+
- m_Textures: []
296+
m_Width: 162
297+
m_Height: 162
298+
m_Kind: 2
299+
m_SubKind:
300+
- m_Textures: []
301+
m_Width: 108
302+
m_Height: 108
303+
m_Kind: 2
304+
m_SubKind:
305+
- m_Textures: []
306+
m_Width: 81
307+
m_Height: 81
308+
m_Kind: 2
309+
m_SubKind:
310+
- m_Textures: []
311+
m_Width: 192
312+
m_Height: 192
313+
m_Kind: 0
314+
m_SubKind:
315+
- m_Textures: []
316+
m_Width: 144
317+
m_Height: 144
318+
m_Kind: 0
319+
m_SubKind:
320+
- m_Textures: []
321+
m_Width: 96
322+
m_Height: 96
323+
m_Kind: 0
324+
m_SubKind:
325+
- m_Textures: []
326+
m_Width: 72
327+
m_Height: 72
328+
m_Kind: 0
329+
m_SubKind:
330+
- m_Textures: []
331+
m_Width: 48
332+
m_Height: 48
333+
m_Kind: 0
334+
m_SubKind:
335+
- m_Textures: []
336+
m_Width: 36
337+
m_Height: 36
338+
m_Kind: 0
339+
m_SubKind:
340+
- m_Textures: []
341+
m_Width: 192
342+
m_Height: 192
343+
m_Kind: 1
344+
m_SubKind:
345+
- m_Textures: []
346+
m_Width: 144
347+
m_Height: 144
348+
m_Kind: 1
349+
m_SubKind:
350+
- m_Textures: []
351+
m_Width: 96
352+
m_Height: 96
353+
m_Kind: 1
354+
m_SubKind:
355+
- m_Textures: []
356+
m_Width: 72
357+
m_Height: 72
358+
m_Kind: 1
359+
m_SubKind:
360+
- m_Textures: []
361+
m_Width: 48
362+
m_Height: 48
363+
m_Kind: 1
364+
m_SubKind:
365+
- m_Textures: []
366+
m_Width: 36
367+
m_Height: 36
368+
m_Kind: 1
369+
m_SubKind:
278370
m_BuildTargetBatching:
279371
- m_BuildTarget: Standalone
280372
m_StaticBatching: 1

0 commit comments

Comments
 (0)