下準備
using UnityEngine;
using GoogleARCore;
publicclass AnchorScript : MonoBehaviour {
public GameObject andy;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update () {
Touch touch;
if (Input.touchCount < 1 ||
(touch = Input.GetTouch(0)).phase != TouchPhase.Began)
{
return;
}
クラス名をAnchorScriptに変更
最新のAnchorをクラウドに保存
using GoogleARCore;
using UnityEngine.EventSystems;
usingGoogleARCore.CrossPlatform;
using UnityEngine.UI;
public class AnchorScript : MonoBehaviour {
public GameObject andy;
Anchor currentAnchor = null;
public Text txt; //保存や位置合わせのステータス表示
bool connecting = false; //クラウドに接続中or切断
void Start()
{
}
public void HostAnchor()
{
}
環境情報をクラウドに保存 (次頁)
【動作確認の手順】
① 平面を認識させる
② Andyを配置
③Hostボタンをタップ
④ 画面下の文字がhosting...になる
⑤ アップロードに成功するとIDが表示される
【この後やりたいこと】
① アプリをいったん終了して再起動
② 前操作で生成したIDでCGP側に問い合わせ
③ CloudAnchorで現在の空間とマッチング
④ CGが同じ位置に表示!
まずはIDをスマホ内に保存
138.
Cloud AnchorのIDを保存
using UnityEngine.EventSystems;
usingUnityEngine.UI;
using System.IO;
public class AnchorScript : MonoBehaviour {
public GameObject andy;
Anchor currentAnchor = null;
public Text txt;
bool connecting = false;
string filePath;
void Start()
{
filePath = Application.persistentDataPath + "/anchorID.txt";
}
public void HostAnchor()
{
}
環境情報をクラウドに保存 (編集中)