Skip to content

Commit d1e8b8c

Browse files
Update ToF AR Samples Basic V1.3.0
1 parent f9d7aa0 commit d1e8b8c

File tree

157 files changed

+10078
-1434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+10078
-1434
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
3+
*
4+
* Copyright 2023 Sony Semiconductor Solutions Corporation.
5+
*
6+
*/
7+
8+
#if UNITY_EDITOR && UNITY_ANDROID
9+
using System.IO;
10+
using UnityEditor;
11+
using UnityEditor.Build;
12+
using UnityEditor.Build.Reporting;
13+
using UnityEngine;
14+
15+
public class AndroidSettingsPreProcess : IPreprocessBuildWithReport
16+
{
17+
private const string UNITY_PROJECT_SETTINGS_PATH = "/ProjectSettings/ProjectSettings.asset";
18+
private const string TARGET_SDK_VERSION_CHECK_NAME = "AndroidTargetSdkVersion";
19+
private const string TARGET_SDK_VERSION_OVERWRITE = " AndroidTargetSdkVersion: ";
20+
21+
private const string ANDROID_MANIFEST_PATH = "/Assets/Plugins/Android/AndroidManifest.xml";
22+
private const string USES_NATIVE_LIBRARY_CHECK_NAME = "libOpenCL";
23+
private const string APPLICATION_END_LINE = "</application>";
24+
25+
private const string USES_NATIVE_LIBRARY_ADD = "<uses-native-library android:name=\"libOpenCL.so\" android:required=\"false\" />\r\n<uses-native-library android:name=\"libOpenCL-car.so\" android:required=\"false\" />\r\n<uses-native-library android:name=\"libOpenCL-pixel.so\" android:required=\"false\" />";
26+
27+
string projectFolderPath = Application.dataPath.Replace("/Assets", "");
28+
29+
char separater = '\n';
30+
31+
public int callbackOrder
32+
{
33+
get { return 0; }
34+
}
35+
36+
public void OnPreprocessBuild(BuildReport report)
37+
{
38+
if (report.summary.platform == BuildTarget.Android)
39+
{
40+
#if UNITY_2022_1_OR_NEWER
41+
AndroidProjectSettings(32);
42+
AndroidManifestSetting(true);
43+
44+
#else
45+
AndroidProjectSettings(30);
46+
AndroidManifestSetting(false);
47+
#endif
48+
}
49+
50+
}
51+
52+
private void AndroidProjectSettings(int apiLevel)
53+
{
54+
string projectSettingsPath = projectFolderPath + UNITY_PROJECT_SETTINGS_PATH;
55+
string projectSettingsText = File.ReadAllText(projectSettingsPath);
56+
57+
if (!string.IsNullOrEmpty(projectSettingsText))
58+
{
59+
string newProjectSettings = string.Empty;
60+
61+
string[] splits = projectSettingsText.Split(separater);
62+
63+
foreach (string text in splits)
64+
{
65+
if (text.Contains(TARGET_SDK_VERSION_CHECK_NAME))
66+
{
67+
newProjectSettings += TARGET_SDK_VERSION_OVERWRITE + apiLevel + separater;
68+
}
69+
else
70+
{
71+
newProjectSettings += text + separater;
72+
}
73+
}
74+
75+
newProjectSettings = newProjectSettings[..^1];
76+
77+
File.WriteAllText(projectSettingsPath, newProjectSettings);
78+
EditorUtility.RequestScriptReload();
79+
}
80+
}
81+
82+
private void AndroidManifestSetting(bool apiLevel31Over)
83+
{
84+
string androidManifPath = projectFolderPath + ANDROID_MANIFEST_PATH;
85+
string androidManifText = File.ReadAllText(androidManifPath);
86+
87+
if (!string.IsNullOrEmpty(androidManifText))
88+
{
89+
string newAndroidManifText = string.Empty;
90+
91+
bool libraryCheckState = androidManifText.Contains(USES_NATIVE_LIBRARY_CHECK_NAME);
92+
93+
if (!libraryCheckState && apiLevel31Over)
94+
{
95+
newAndroidManifText = androidManifText.Replace(APPLICATION_END_LINE, USES_NATIVE_LIBRARY_ADD + separater + APPLICATION_END_LINE);
96+
97+
}
98+
else if (libraryCheckState && !apiLevel31Over)
99+
{
100+
string[] splits = androidManifText.Split(separater);
101+
102+
foreach (string text in splits)
103+
{
104+
if (!text.Contains(USES_NATIVE_LIBRARY_CHECK_NAME))
105+
{
106+
newAndroidManifText += text + separater;
107+
}
108+
}
109+
110+
newAndroidManifText = newAndroidManifText[..^1];
111+
}
112+
113+
if (!string.IsNullOrEmpty(newAndroidManifText))
114+
{
115+
File.WriteAllText(androidManifPath, newAndroidManifText);
116+
AssetDatabase.Refresh();
117+
}
118+
}
119+
}
120+
}
121+
#endif

Assets/TofArSettings/Scripts/Hand/Controller/GestureFramesForDetectNoHandsController.cs.meta renamed to Assets/Editor/AndroidSettingsPreProcess.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins.meta

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

Assets/Plugins/Android.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.unity3d.player"
5+
xmlns:tools="http://schemas.android.com/tools">
6+
<application>
7+
<activity android:name="com.unity3d.player.UnityPlayerActivity"
8+
android:theme="@style/UnityThemeSelector">
9+
<intent-filter>
10+
<action android:name="android.intent.action.MAIN" />
11+
<category android:name="android.intent.category.LAUNCHER" />
12+
</intent-filter>
13+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
14+
</activity>
15+
</application>
16+
</manifest>

Assets/Plugins/Android/AndroidManifest.xml.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.

Assets/TofArSamplesBasic/ColoredPointCloud/Scripts/ColoredPointCloud.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
33
*
4-
* Copyright 2022 Sony Semiconductor Solutions Corporation.
4+
* Copyright 2022,2023 Sony Semiconductor Solutions Corporation.
55
*
66
*/
77

@@ -146,6 +146,7 @@ private void SetMaterials()
146146
break;
147147
case ColorFormat.RGB:
148148
case ColorFormat.BGRA:
149+
case ColorFormat.RGBA:
149150
rgbTextureMaterial.mainTexture = TofArColorManager.Instance.ColorTexture;
150151
meshRenderer.material = rgbTextureMaterial;
151152
break;

Assets/TofArSamplesBasic/Common/Scripts/CameraController.cs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
33
*
4-
* Copyright 2022 Sony Semiconductor Solutions Corporation.
4+
* Copyright 2022,2023 Sony Semiconductor Solutions Corporation.
55
*
66
*/
77

@@ -304,36 +304,7 @@ DeviceOrientation GetOrientation()
304304

305305
private float GetDPI()
306306
{
307-
if (TofArManager.Instance != null)
308-
{
309-
var deviceCapability = TofArManager.Instance.GetProperty<DeviceCapabilityProperty>();
310-
string modelName = deviceCapability.modelName;
311-
312-
if (modelName.Equals("iPhone14,7")) //iPhone 14 6.1inch 1170x2532
313-
{
314-
return 457;
315-
}
316-
else if (modelName.Equals("iPhone14,8")) //iPhone 14 Plus 6.7inch 1284x2778
317-
{
318-
return 457;
319-
}
320-
else if (modelName.Equals("iPhone15,2")) //iPhone 14 Pro 6.1inch 1179x2556
321-
{
322-
return 461;
323-
}
324-
else if (modelName.Equals("iPhone15,3")) //iPhone 14 Pro Max 6.7inch 1290x2796
325-
{
326-
return 460;
327-
}
328-
else
329-
{
330-
return Screen.dpi;
331-
}
332-
}
333-
else
334-
{
335-
return Screen.dpi;
336-
}
307+
return Screen.dpi;
337308
}
338309
}
339310
}

Assets/TofArSamplesBasic/Common/Scripts/XYZAxisManager.cs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
1+
/*
22
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
33
*
4-
* Copyright 2022 Sony Semiconductor Solutions Corporation.
4+
* Copyright 2022,2023 Sony Semiconductor Solutions Corporation.
55
*
66
*/
77

@@ -124,36 +124,7 @@ private void AdjustSafeArea(Rect newArea)
124124

125125
private float GetDPI()
126126
{
127-
if (TofArManager.Instance != null)
128-
{
129-
var deviceCapability = TofArManager.Instance.GetProperty<DeviceCapabilityProperty>();
130-
string modelName = deviceCapability.modelName;
131-
132-
if (modelName.Equals("iPhone14,7")) //iPhone 14 6.1inch 1170x2532
133-
{
134-
return 457;
135-
}
136-
else if (modelName.Equals("iPhone14,8")) //iPhone 14 Plus 6.7inch 1284x2778
137-
{
138-
return 457;
139-
}
140-
else if (modelName.Equals("iPhone15,2")) //iPhone 14 Pro 6.1inch 1179x2556
141-
{
142-
return 461;
143-
}
144-
else if (modelName.Equals("iPhone15,3")) //iPhone 14 Pro Max 6.7inch 1290x2796
145-
{
146-
return 460;
147-
}
148-
else
149-
{
150-
return Screen.dpi;
151-
}
152-
}
153-
else
154-
{
155-
return Screen.dpi;
156-
}
127+
return Screen.dpi;
157128
}
158129
}
159-
}
130+
}

0 commit comments

Comments
 (0)