環境設定(Unity, Android SDK, JDK、GoogleVR)は設定してあるとします。
VRの環境設定は、
https://developers.google.com/vr/unity/get-started
を参考にします。 この中にもリンクはありますが、GoogleVRは
https://github.com/googlevr/gvr-unity-sdk/releases
からダウンロードしておきます。
注意点として、AndroidStudio2.3.3では
/Users/mizuno/Library/Android/sdk/tools
このtoolsの構造が変更されたらしく、Unityでアクセスできなかったので、toolsをダウンロードしてフォルダごと置き換える必要があります。僕はtools_r25.2.5-macosx.zipをダウンロードして置き換えました。
(1) プロジェクト作成
今回はVR01というプロジェクトにします。
プリミティブオブジェクトを用意していきます。
Planeを用意
GameObject->3DObject->Plane
同様にSphereを持ってきます。
この2つに色をつけるためのスクリプトを作成します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class changeColorScript : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
Renderer rend = GetComponent<Renderer>(); | |
rend.material.shader = Shader.Find("Object"); | |
rend.material.SetColor("_Object",Color.red); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
} |
これをAdd Component -> Script -> changeColorScript.cs を選択しておきます。
次に、もう一つPlaneを持ってきて設定します(PhotoPlane)。
Project -> Assets -> Materials に画像ファイルを置いておき、PhotoPlaneに適用します。
(2) VRの設定
Assetを右クリックして、import package -> cunsom Package -> VRファイルを選択
全てをインポートします。
Game Object -> Create Emptyで作成したオブジェクトの名前をVREyeとします。
この中にMain Cameraを入れて値をリセットします。
さらにAssete -> GoogleVR -> Prefabs -> GvrEditorEmulatorを入れます。
(3) VRのAndrtoid転送
File -> Build Setting でAndroidを選択し、Switch Platformを押します。
次にPlayer Settingで次のように設定します。
これでAndroid端末に転送し、確認します。
0 件のコメント:
コメントを投稿