|   |   | 
| (10 intermediate revisions by the same user not shown) | 
| Line 1: | Line 1: | 
|  | + | * [[Unity AR Butterfly]] | 
|  | + | * [[Unity Course Notes]] | 
|  | + | * [[Unity Interface]] | 
|  | + | * [[Studying for the Unity Exam]] | 
|  |  |  |  | 
| − | == Create An Augmented Reality App Webinar by Gen Infiniti Academy, 13 Aug 2020, 7.30pm-9.30pm ==
 | + | <hr> | 
| − | * Change build settings to Android/mobile
 |  | 
| − | * Delete Main camera and Directional Light
 |  | 
| − | * Window >Package Manager > AR Foundation > Install
 |  | 
| − | * Window > Package Manager > ARCore XD Plugin > Install
 |  | 
| − | * Window > Package Manager > ARkit Xr Plugin > Install
 |  | 
| − | * Rightclick on Hierarchy Window > XR > AR Session origin
 |  | 
| − | * Double click the tiny AR Session origin > look under inspector > tag: MainCamera
 |  | 
| − | * Rightclick on Hierarchy Window > XR > AR Session (coordinates the real world)
 |  | 
| − | * Rightclick on Hierarchy Window > XR > AR Default Plane
 |  | 
| − | * Click on AR Session Origin in Hierarchy > Look in Inspector > Add Component > AR Raycast Manager (checks for floor)
 |  | 
| − | * Click on AR Session Origin in Hierarchy > Look in Inspector > Add Component > AR Plane Manager (allows you to tag and project things)
 |  | 
| − | * Now we want to add a plane prefab, first we create a folder in project called “prefabs”
 |  | 
| − | * Drag the AR Default Plane into the Prefabs folder
 |  | 
| − | * Drag the blue AR Default Prefab into inspector slot for AR Session Origin > plane manager > plane prefab
 |  | 
| − | * Create in project a scripts folder
 |  | 
| − | * Create a new C# script “PlaceOnPlane.cs” - open it in editor of choice (be careful about naming of file)
 |  | 
| − | * Drag and drop PlaceOnPlane script into AR session origin
 |  | 
| − | * Download free asset butterfly (just go to Asset Store and look for the free Animated Butterly asset
 |  | 
| − | * Download and import the butterfly asset - THIS ONE: https://assetstore.unity.com/packages/3d/characters/animals/butterfly-animated-58355
 |  | 
| − | * Newly imported Butterfly asset folder > Double click on FBX > Double click on Materials
 |  | 
| − | * Select second sphere (blue metallic) butterfly_Albedo > select the image material in emissions (otherwise butterfly will not show up)
 |  | 
| − | * Assets > Butterfly Animated > Prefab > left click on butterfly and drag it inside Place On Place Model (inside AR Session Origin)
 |  | 
| − | * Project Settings > Player > Other setting > Identification > Minimum API Level > Set to Android 7.1
 |  | 
| − | * Build and Run
 |  | 
| − | * Copy the apk to your phone
 |  | 
| − | * Recklessly install it on your phone
 |  | 
| − | * AR BUTTERFLY APP COMPLETE
 |  | 
|  |  |  |  | 
| − | === PlaceOnPlane.cs ===
 | + | '''Video Player in Unity''' | 
|  |  |  |  | 
| − | <pre>
 | + | # Import video into Assets | 
| − | using System.Collections;
 | + | # Create Render Texture and change dimensions of render texture to match video | 
| − | using System.Collections.Generic;
 | + | # Create Material (URP/Lit) and drag Render Texture into Base Map | 
| − | using UnityEngine;
 | + | # Create Video Player in Hierarchy and link the video clip to the Render Texture | 
| − | using UnityEngine.XR.ARFoundation;
 |  | 
| − | using UnityEngine.EventSystems;
 |  | 
|  |  |  |  | 
| − | public class PlaceOnPlane : MonoBehaviour
 | + | '''Spatial audio''' | 
| − | {
 | + | # Spatial Blend from 2D to 3D. | 
| − |     ARRaycastManager raycastManager;
 | + | # Volume Rolloff from logarithmic to linear. | 
| − |     List<ARRaycastHit> hits;
 | + | # Set Minimum and Maximum distance. | 
|  |  |  |  | 
| − |     public GameObject model;
 | + | '''Optimising VR in Unity''' | 
| − |     
 | + | * https://learn.unity.com/tutorial/optimizing-your-vr-ar-experiences | 
| − |     void Start()
 |  | 
| − |     {
 |  | 
| − |         raycastManager = GetComponent<ARRaycastManager>();
 |  | 
| − |         hits = new List<ARRaycastHit>();
 |  | 
| − |     }
 |  | 
| − |   |  | 
| − |     //Update is called once per frame
 |  | 
| − |     void Update()
 |  | 
| − |     {
 |  | 
| − |         if (Input.touchCount == 0)
 |  | 
| − |             return;
 |  | 
| − |   |  | 
| − |         Touch touch = Input.GetTouch(0);
 |  | 
| − |   |  | 
| − |         if (IsPointerOverUIObject(touch.position))
 |  | 
| − |             return;
 |  | 
| − |   |  | 
| − |         if (raycastManager.Raycast(touch.position, hits))
 |  | 
| − |         {
 |  | 
| − |             Pose pose = hits[0].pose;
 |  | 
| − |   |  | 
| − |             Instantiate(model, pose.position, pose.rotation);
 |  | 
| − |         }
 |  | 
| − |     }
 |  | 
| − |   |  | 
| − |     bool IsPointerOverUIObject(Vector2 pos)
 |  | 
| − |     {
 |  | 
| − |         if (EventSystem.current == null)
 |  | 
| − |             return false;
 |  | 
| − |         PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
 |  | 
| − |         eventDataCurrentPosition.position = new Vector2(pos.x, pos.y);
 |  | 
| − |         List<RaycastResult> results = new List<RaycastResult>();
 |  | 
| − |         EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
 |  | 
| − |         return results.Count > 0;
 |  | 
| − |     }
 |  | 
| − | }
 |  | 
| − |   |  | 
| − | </pre>
 |  |