https://github.com/stefanocecere/gamelab_ar_unity
Game Lab for Augmented and Mixed Reality with Unity
https://github.com/stefanocecere/gamelab_ar_unity
arcore arfoundation arkit augmented-reality examples gamedev gamelab2042 mixed-reality unity
Last synced: about 1 month ago
JSON representation
Game Lab for Augmented and Mixed Reality with Unity
- Host: GitHub
- URL: https://github.com/stefanocecere/gamelab_ar_unity
- Owner: StefanoCecere
- Created: 2020-05-31T15:12:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-24T19:06:50.000Z (over 2 years ago)
- Last Synced: 2025-04-04T15:54:36.500Z (about 1 year ago)
- Topics: arcore, arfoundation, arkit, augmented-reality, examples, gamedev, gamelab2042, mixed-reality, unity
- Language: C#
- Size: 70.1 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AR demo lessons
Unity version used: 2021.2.x
supported Android devices: https://developers.google.com/ar/discover/supported-devices
iOS: iPhone o iPad con iOS >= 12.0
---
creo Prefab
aggiungo package ARFoundation e ARcore
creo Prefab Plane ->
Empty
AR Plane
AR Plane visualizer
mesh filter
mesh rendererd
LInerendered (0,01) e no world space
creo materiale tranparent
poi script ARPlace
```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
namespace MyDemo
{
public class ARPlaceOnTap : MonoBehaviour
{
public GameObject gameToInstatiate;
private GameObject spawnedObject;
private ARRaycastManager raycatManager;
private Vector2 touchPosition;
static List hits = new List();
private void Awake()
{
raycatManager = GetComponent();
}
void Update()
{
if (Input.touchCount > 0) {
touchPosition = Input.GetTouch(0).position;
if (raycatManager.Raycast(touchPosition, hits, TrackableType.PlaneWithinPolygon)) {
var hitPose = hits[0].pose;
if (spawnedObject == null) {
spawnedObject = Instantiate(gameToInstatiate, hitPose.position, hitPose.rotation);
} else {
spawnedObject.transform.position = hitPose.position;
}
}
}
}
}
}
```