当前位置:网站首页>Arfoundation starts from scratch 3- create an arfoundation project
Arfoundation starts from scratch 3- create an arfoundation project
2022-07-29 05:16:00 【suelee_ hm】
Project sample source code :
https://github.com/sueleeyu/framework
One 、 Create project project
1. unity edition 2020.2.6f1, New projects :

2.Hieraychy Next Scene Rename it to GeospatialScene, choice Window-Package Manager- Unity Register, Download... In turn :
XR Plugin Management 4.0.7
AR Foundation 4.1.10
ARCore XR Plugin 4.1.10
ARKit XR Plugin 4.1.10

3. as follows :

4. Delete the original camera , Click on Hierarchy Of “+”, add to AR Session Origin and AR Session:

5. Switch project platform ,File-Build Settings, To add Scene, then Platform Next switch to Android:

6.Player Settings Set up , Click on Build Setting Under the Player Settings:


Scripting Backend choice IL2CPP, such Target Architectures You can check ARM64:

7.XR-Plugin Management:

8. Package settings : because ARCore Extensions need build gradle Plug in 4.0.1 above , When packing, you need to check the following options :

And android Correspondence between projects :
Main Gradle Template–> unityLibrary Library build.gradle file
Launcher Gradle Template->launcher Library build.gradle file
Base Gradle Template->android engineering build.gradle file
Gradle Properties->android engineering gradle.properties file
Otherwise, packaging errors will occur :

9. Test Packet APK

If the packaging time is long ,
a. Open the project
\Assets\Plugins\Android\baseProjectTemplate.gradle file , Change to :
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
}
dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:4.2.2'
**BUILD_SCRIPT_DEPS**
}
}
repositories {**ARTIFACTORYREPOSITORY**
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}b.\Assets\Plugins\Android\mainTemplate.gradle file , Change it to :
//AAA Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven {
url "https://maven.aliyun.com/repository/google/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
}
mavenLocal()
jcenter()
mavenCentral()
}
}
//AAA Android Resolver Repos End
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**If the first line is the following, it should also be deleted :
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

Tips : If we modify Unity Generated files , such as build.gradle, such as UnityPlayerActivity.java etc. , Then you can delete the following comments in these files , To prevent Unity Overlay the file :
GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
c. open Android Resolver Set up :

d. Cancel overwrite mainTemplate.gradle Set up :

10. Signature packed APK: Open Command Prompt - Enter the directory where the certificate is located , Put the unsigned APK Put it in the current directory , renamed orient.apk, Command line input :
jarsigner -verbose -keystore user.keystore -signedjar sign.apk orient.apk 212
user.keystore For certificate , Such as :F:\unity\sign\user.keystore
orient.apk Is unsigned APK, Such as :F:\unity\sign\orient.apk
sign.apk For the signed APK
212 Alias set for Certificate creation

11. see SHA-1 The fingerprint , Command line input :
keytool -list -printcert -jarfile sign.apk

Two 、 install ARCore Extensions software package ( It does not involve geospatial and cloud anchors, and there is no need to install )
Installation requirements :
1. Over the wall
2.ARCore The expansion pack requires ARFoundation4.1.5 above .
3.unity edition 2020.2.6f1 above
google Reference documents :
Start using ARCore Foundation for AR Foundation | Google Developers
1. Import ARCore Expansion pack, :windows-package manager, Click on “+” Button , Then select from the drop-down menu Add package from git URL... Options

2. Copy the following URL into the text field , Click on Add:
GitHub - google-ar/arcore-unity-extensions: Google ARCore Extensions for Unity's AR Foundation

After installation :

2. add to ARCore Extensions The game object :Hierarchy-“+”-XR-ARCore Extensions

3. Associate game objects : Drag the object to the corresponding field

4. Make ARCoreExtensionsConfig( and ARCoreExtensionsCameraConfigFilter) Material resources : Project > Assets- Right click to create Configurations Folder ,Configurations Right click inside Create > XR > ARCore Extensions Config, Click to add .

5. Drag the associated material resource :

6. stay Unity in , go to Edit > Project Settings > XR > ARCore Extensions. Android Authentiation Strategy Drop down menu , choice API Key

7. stay Android API Key Field , Paste from Google Cloud Platform To obtain the API secret key ( Following ), And check the Optional Features The next two are to be used API Check box :

Authorization complete .
3、 ... and 、 add to UI
1.Hierarchy Right click -Create Empty, Click on the created component , On the right side Inspector name UI.Hierarchy Right click -Create Empty, Click on the created component , On the right side Inspector name Game:

2.UI Under the new Text, name Log, Set up :

Four 、 Add a script
1. Assets- newly build Scripts Folder , newly build Logger.cs Script files :
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
namespace FrameworkDesign.Example
{
public class Logger : MonoBehaviour
{
[SerializeField]
Text m_LogText;
public Text logText
{
get => m_LogText;
set => m_LogText = value;
}
[SerializeField]
int m_VisibleMessageCount = 40;
public int visibleMessageCount
{
get => m_VisibleMessageCount;
set => m_VisibleMessageCount = value;
}
int m_LastMessageCount;
static List<string> s_Log = new List<string>();
static StringBuilder m_StringBuilder = new StringBuilder();
void Awake()
{
if (m_LogText == null)
{
m_LogText = GetComponent<Text>();
}
lock (s_Log)
{
s_Log?.Clear();
}
Log("Log console initialized.");
}
void Update()
{
lock (s_Log)
{
if (m_LastMessageCount != s_Log.Count)
{
m_StringBuilder.Clear();
var startIndex = Mathf.Max(s_Log.Count - m_VisibleMessageCount, 0);
for (int i = startIndex; i < s_Log.Count; ++i)
{
m_StringBuilder.Append($"{i:000}> {s_Log[i]}\n");
}
var text = m_StringBuilder.ToString();
if (m_LogText)
{
m_LogText.text = text;
}
else
{
Debug.Log(text);
}
}
m_LastMessageCount = s_Log.Count;
}
}
public static void Log(string message)
{
lock (s_Log)
{
if (s_Log == null)
s_Log = new List<string>();
s_Log.Add(message);
}
}
}
}2. mount Log, choice Log Components , take Logger.cs Drag to add as Component, relation Log( Drag the Log To LogTest bar )
5、 ... and 、 common problem
1. unity Operation tips :Display 1 No cameras rendering

resolvent :Game View - Right click - Uncheck the first

6、 ... and 、 reference
1. Unity api:
Unity - Manual: Unity User Manual 2021.3 (LTS)
2. Geospatial file :
Use ARCore Geospatial API Create a global scale immersive AR Experience | Google Developers
3. The sample source code of this project :
https://github.com/sueleeyu/framework
边栏推荐
- How to solve the problem of configuring the progress every time Office2010 is opened?
- JS daily question (12)
- MySQL sorts the queried result set according to the specified sequence
- Solution | get the relevant information about the current employees' highest salary in each department |
- 学习数据库的第一个程序
- Lenovo Savior r7000+ add ssd+ copy and partition the information of the original D disk to the new SSD
- Google GTEST event mechanism
- Reply from the Secretary of jindawei: the company is optimistic about the market prospect of NMN products and has launched a series of products
- js(forEach)出现return无法结束函数的解决方法
- Solve the warning prompt of MySQL mapping file
猜你喜欢

IDEA中使用注解Test

The difference between the two ways of thread implementation - simple summary

How to monitor micro web services

How to add a map to the legendary server
![[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]](/img/ee/b424d876c64dac652d76f9f26e4b20.png)
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]

JS (foreach) return cannot end the function solution

A little knowledge about management

Five correlation analysis, one of the most important skills of data analysts

开源汇智创未来 | 2022开放原子全球开源峰会 openEuler 分论坛圆满召开

Mysql语句中的函数
随机推荐
Deadlock analysis using jstack, jconsole, and jvisualvm
Google GTEST event mechanism
Quick start JDBC
Mysql把查询到的结果集按指定顺寻进行排序
How does word view document modification traces? How word views document modification traces
Original code, inverse code, complement code
搭建手机APP需要用到什么服务器
开区网站打开自动播放音乐的添加跟修改教程
优炫数据库启动失败,报网络错误
力扣------对奇偶下标分别排序
关于thymeleaf的配置与使用
< El table column> place multiple pictures
WPS insert hyperlink cannot be opened. What should I do if I prompt "unable to open the specified file"!
AttributeError: ‘module‘ object has no attribute ‘create_ connection‘
Introduction of JDBC preparestatement+ database connection pool
office2010每次打开都要配置进度怎么解决?
P2181 diagonal
A little knowledge about management
Vivo market API event reporting and docking
About realizing page Jump of website in Servlet