Help us understand the problem. What is going on with this article?

VR内にオーバーレイでブラウザを持ち込む

More than 1 year has passed since last update.

注意

Embedded Browserは任意のサイトを見るための作りではないようです。
「信頼できないコードを読み込まないように」とドキュメントに書かれていますし、Chromiumのバージョンは古く、Googleにアクセスすると更新するように表示が出ます。
自作のHTMLやjavascriptを読み込む、信頼できるサイトのみを読み込むようにしてください。

紹介

ちなみに、別のアセットを使った完成品を配布している方がいます。
こちらはIE11です。
VROverlayWebView
https://github.com/Narazaka/VROverlayWebView

手順

1 この記事のとおりに作る

空間タップできるVRオーバーレイアプリケーションをUnityで作る【コーディングなし】
https://qiita.com/gpsnmeajp/items/3b67223f7f11bb6d93c3

2 このアセットを買う
ZEN FULCRUM LLC - Embedded Browser
https://assetstore.unity.com/packages/tools/gui/embedded-browser-55459

3 Assets/ZFBrowser/Prefabs/Browser (GUI)を、Canvasに突っ込む

4 以下のコードを書き、Browser (GUI)のPointer UIGUI(Script)を置き換える。
この際、Inspector上で
・Enable Touch Inputをオンに
・EasyOpenVROverlayには、OverlaySystemを突っ込む

MyBrowserUI
//gpsnmeajp 2019
//These codes are licensed under CC0.
//http://creativecommons.org/publicdomain/zero/1.0/deed.ja
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ZenFulcrum.EmbeddedBrowser;

public class MyBrowserUI : PointerUIGUI
{
    public EasyOpenVROverlayForUnity EasyOpenVROverlay;
    public Vector2 PointerPositionLeft = Vector2.zero;
    public bool IsClickLeft = false;
    public Vector2 PointerPositionRight = Vector2.zero;
    public bool IsClickRight = false;

    protected override void FeedTouchPointers()
    {
        if (EasyOpenVROverlay.LeftHandU >= 0 && EasyOpenVROverlay.LeftHandV >= 0)
        {
            PointerPositionLeft = new Vector2(EasyOpenVROverlay.LeftHandU, EasyOpenVROverlay.LeftHandV);
        }
        IsClickLeft = EasyOpenVROverlay.tappedLeft;

        if (EasyOpenVROverlay.RightHandU >= 0 && EasyOpenVROverlay.RightHandV >= 0)
        {
            PointerPositionRight = new Vector2(EasyOpenVROverlay.RightHandU, EasyOpenVROverlay.RightHandV);
        }
        IsClickRight = EasyOpenVROverlay.tappedRight;

        FeedPointerState(new PointerState
        {
            id = 10 + 0,
            is2D = true,
            position2D = PointerPositionLeft,
            activeButtons = IsClickLeft ? MouseButton.Left : 0,
        });
        FeedPointerState(new PointerState
        {
            id = 10 + 1,
            is2D = true,
            position2D = PointerPositionRight,
            activeButtons = IsClickRight ? MouseButton.Left : 0,
        });
    }
}

5 実行して、VR空間にブラウザが現れればOK

gpsnmeajp
電子工作が主な趣味ですが、PC用のツールを作るのも好きです。 特にライセンスを明記していないソースコードのライセンスについてはCC0です。
https://sabowl.sakura.ne.jp/gpsnmeajp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした