AR (For Android) Unity - My Notes

*Android does not require a developers licence fee.

Unity AR Project

> On Disk
> Project
> Select Folder

Organise Interface

> Window
> Package Manager
> Ads Remove
> Analytics Remove
>In App Purchasing remove

> Advanced
> Show Preview Packages
> Install
   AR Foundation
   AR Core
   AR Kit

Directional Light 
> Mode: Real Time (Tick)
> Shadow Type: Hard Shadows (tick)
> Right Click in the hierarchy   
> Create Empty
> Name: AR Session
> Add Component
> AR Session

> Game Object
> XR
> AR Session Origin

Now Delete the Main Camera 


> Game Object
> 3D Object
> Cube

(Check AR Camera view)
Turn Gizmos off

Checking the AR Camera 

> Clear Flags = Solid Colour
> Background = Black
> Field of View = 60
> Clipping Panes Near 0.1 Far 20
> MSAA (Multi Sample Anti Aliasing) Turn off (For better performance & AR Application)
> Tracked Posed Driver Component Device = Generic XR Device (Tick)
>  AR Background Component (This pipes the video into unity)

Adding Debug Visualisation
> AR Session Origin Object
> Add Component
> AR Manager
> AR Point Cloud Manager
> Plane Manager

>Game Object
> XR
> AR Default Plane
> Mesh
> Mesh Collider

Make the AR Default into a Prefab

> Drag the AR Default Plane into the content folder (it will turn blue which signifies it’s  now a Prefab)
> Delete the AR Default Plane from the scene.

> Game Object
>XR
> Default Point Cloud
> Drag from the scene hierarchy into the contents folder
> Remove AR point cloud

Connect Defaults to Managers
> Drag AR Default Plane Prefab to the AR Plane Anaher (Script)
> Drag AR Default Point Cloud Prefab to AR Point Cloud Manager (Script)

N.B Preview Code is not Production Code

Build
> File
> Build Settings
> Click Build
> Save as Agent_01


To Set up the old Android Phone (Minimum version Nougat 7)

  • Requires Java 8 or Above is required (If you dont have Java 8 it is possible to download it from Oracle). 
  •  Go to Developer.Android.Com 
  • Connect Android Phone to PC via USB 
  • Set up with USB Debugging enable 

In Unity install Logcat

> Window
> Package Manager
>  Advanced
> Show Review Packages
> Android Logcat
> Install

Compiling to AR 

> File
> Build Settings
> Add Open Scenes
> Android
> Development Build (Tick)
> SWITCH PLATFORM
> Run Device
> Select Mobile phone device

> Player Settings
> Company Name - Resilience
> Product Name - Agent
> Vulcan (use minus - sign) remove
> Multithreaded Rendering (Untick)
> Package Name - agent.remote
> Minimum API Level Android 7 'Nougat'
> Scripting Backend IL2PP
> Target Architecture
> XR Setting - Arcore Supported (Not Selected)


Install XR Remoting (This streams the device into the editor)
> packages
> XR Remoting
> Com.unity.xr.remoting
> Scenes
> Remoting  app
> Double click

> Right click
> Copy
> Assets
> Paste item
> Move remoting scene into scene folder

Build App 

>  File
> Build settings
Android
> Main scene
> Delete
> Add open scenes
> Scenes/remoting  app
> Player settings
> Change product name to AR Remote
> Bundle identifier - Change To .remote

Save file in  build folder as project name. Remote

Select the device 

Build
Android
Player settings
Product name AR Remote
Package Name add .remote
Delete
Build settings
Run device : Android
Build and Run
Save as remote in the build folder

> Scenes
> Main
> Add open scenes
> Main scene
> iOS/android build target

> Player settings
> Product name - Change To app
> Bundle - remove .remote

>AR  Tools
> Remote window
> Advanced options (hook up camera) tick
> Grab AR Camera and drag the camera to stream
> Enter IP Address

✔️ Same WiFi
✔️ plug in device
✔️ iOS is more stable


Add Assets (.fbx models)
> Drag Model into hierarchy
> Right Click in hierarchy
> Game Object Empty
> Rename as CCTV
>  Right Click
> Game Object Empty
> Rename to Content
> nest content under cctv
> Drag Into Content (to make into a Prefab)
>Scale adjust to surroundings - use cube (1 metre) to scale accordingly
> gizmos turn off

Scripts
>scripts
> right click
> create c# script
> new behaviour script
> rename as AR Manager
> double click
> open in Visual Studio

Visual Studio
> remove mono behaviour
> Ad

> Add Object
> AR Manager
> Drag and drop script on to object

Connect hierarchy objects to AR Manager Script











Popular posts from this blog

Seraphina Stormrider

Metahome Development