{"id":730,"date":"2017-07-23T23:04:46","date_gmt":"2017-07-23T14:04:46","guid":{"rendered":"http:\/\/naochang.me\/?p=730"},"modified":"2017-07-29T23:41:15","modified_gmt":"2017-07-29T14:41:15","slug":"vr%e4%bd%bf%e7%94%a8%e3%81%ae%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88","status":"publish","type":"post","link":"https:\/\/stacstar.jp\/blog\/?p=730","title":{"rendered":"VR\u30e2\u30fc\u30c9\u3068\u30ce\u30fc\u30de\u30eb\u30e2\u30fc\u30c9\u306e\u5207\u308a\u66ff\u3048"},"content":{"rendered":"<p>Unity\u3067\u306eVR\u5bfe\u5fdc\u3092\u4f5c\u308b\u306e\u306f\u975e\u5e38\u306b\u7c21\u5358\u3067\u3001PlayerSettings\u306eOther Settings\u304b\u3089Virtual Reality Supported\u3092ON\u306b\u3057\u3066\u3001SDK\u306bCardboard\u306a\u3069\u3092\u5165\u308c\u308c\u3070\u3082\u3046VR\u30b3\u30f3\u30c6\u30f3\u30c4\u306b\u306a\u308b\u3002<br \/>\nUnity2017.2b3\u304b\u3089\u306fVR\u3067\u306f\u306a\u304f\u3001XR\u3068\u540d\u79f0\u304c\u4ee3\u308f\u308a\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3084\u3001PlayerSettings\u306e\u9805\u76ee\u3082\u3001XR Settings\u3078\u3068\u79fb\u884c\u3002<br \/>\n\u73fe\u72b6\u306e\u6700\u65b0Google VR Unity SDK v1.7\u3067\u3059\u304c\u3001Unity\u306b\u5165\u3063\u3066\u3044\u308b\u3082\u306e\u306fv1.6\u3002<br \/>\nVR\u3068\u901a\u5e38\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u5207\u308a\u66ff\u3048\u306f\u3001\u57fa\u672c\u7684\u306b\u306f\u3002<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nVRSettings.enabled = !VRSettings.enabled;\r\n<\/pre>\n<p>(2017.2b3\u304b\u3089\u306fXRSettings)<\/p>\n<p>\u3068\u3059\u308c\u3070OK\u3002<br \/>\n\u305f\u3060\u3001\u3053\u308c\u3067\u6210\u308a\u7acb\u3064\u306e\u306f<\/p>\n<p>\u30fb\u8d77\u52d5\u76f4\u5f8c\u304b\u3089VR\u30b3\u30f3\u30c6\u30f3\u30c4<br \/>\n\u30fb\u30ce\u30fc\u30de\u30eb\u30b3\u30f3\u30c6\u30f3\u30c4\u3082VR\u540c\u69d8\u306e\u6a2a\u5411\u304d<\/p>\n<p>\u3068\u3044\u3046\u6761\u4ef6\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n\u4e21\u65b9\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u4f7f\u3046\u5834\u5408\u591a\u304f\u306f\u8d77\u52d5\u6642\u306b\u30ce\u30fc\u30de\u30eb\u30e2\u30fc\u30c9\u3060\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001Virtual Reality SDKs\u306bNone\u3092\u8ffd\u52a0\u3057\u3001\u4e00\u756a\u4e0a\u306b\u6301\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\nDefault Orientation\u306fVirtual Reality Supported\u304cON\u306e\u72b6\u614b\u3067\u306f\u5909\u66f4\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u3053\u3053\u3092OFF\u306b\u3057\u3066\u304b\u3089Portrait\u306b\u3057\u3001\u518d\u3073ON\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3042\u3068\u306f\u4e0b\u306b\u3042\u308b\u53c2\u8003\u30b5\u30a4\u30c8\u3092\u3082\u3068\u306b\u3053\u3093\u306a\u611f\u3058\u3067\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3061\u306a\u307f\u306bUnity2017.2b3\u304b\u3089\u306fVR\u304b\u3089XR\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3084\u30af\u30e9\u30b9\u540d\u304c\u5909\u308f\u3063\u3066\u307e\u3059\u306d\u3002<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nusing System.Collections;\r\nusing UnityEngine;\r\nusing UnityEngine.VR;\r\n\r\npublic class XRTest : MonoBehaviour {\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ VR\u30c7\u30d0\u30a4\u30b9\u540d\u3002\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tstatic string DeviceCardboard = &quot;Cardboard&quot;;\r\n\tstatic string DeviceNone =&quot;None&quot;;\r\n\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ Update.\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tvoid Update() {\r\n\t\t\/\/ \u753b\u9762\u30bf\u30c3\u30c1\u3067\u5207\u308a\u66ff\u3048\r\n\t\tif (Input.GetMouseButtonDown (0)) {\r\n\t\t\tToggleXR ();\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ XR\u5207\u308a\u66ff\u3048\u3002\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tvoid ToggleXR() {\r\n\t\tif (VRSettings.loadedDeviceName.ToLower() == XRTest.DeviceCardboard.ToLower()) {\r\n\t\t\tStartCoroutine(LoadDevice(XRTest.DeviceNone));\r\n\t\t} else {\r\n\t\t\tStartCoroutine(LoadDevice(XRTest.DeviceCardboard));\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ VR\u30c7\u30d0\u30a4\u30b9\u306e\u30ed\u30fc\u30c9\u3002\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tIEnumerator LoadDevice(string newDevice) {\r\n\t\tbool vrMode = newDevice != XRTest.DeviceNone;\r\n\r\n\t\t\/\/ VR\u306e\u969b\u306b\u306f\u3053\u3053\u3067\u5207\u308a\u66ff\u3048\r\n\t\tif (vrMode) \r\n\t\t\tScreen.orientation = ScreenOrientation.LandscapeLeft;\r\n\r\n\t\tVRSettings.LoadDeviceByName(newDevice);\r\n\t\tyield return null;\r\n\r\n\t\tVRSettings.enabled = vrMode;\r\n\r\n\t\t\/\/ \u30ce\u30fc\u30de\u30eb\u306e\u969b\u306f\u3053\u3053\u3067\u5207\u308a\u66ff\u3048\r\n\t\tif (!vrMode)\r\n\t\t\tScreen.orientation = ScreenOrientation.Portrait;\r\n\t}\r\n}\r\n<\/pre>\n<p>\u53c2\u8003\uff09<br \/>\n<a href=\"http:\/\/talesfromtherift.com\/googlevr-cardboard-switch-between-normal-mode-and-vr-mode-at-run-time\/\" target=\"_blank\">Tales From The Rift | GoogleVR Cardboard: Switch between normal mode and VR mode at run-time<\/a><br \/>\n<a href=\"https:\/\/www.gaprot.jp\/pickup\/tips\/googlevr-sdk-1-5\" target=\"_blank\">\u30ae\u30e3\u30c3\u30d7\u30ed | Unity5.6\u304b\u3089\u306eGoogleVR SDK\u3068\u306e\u5411\u304d\u5408\u3044\u65b9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity\u3067\u306eVR\u5bfe\u5fdc\u3092\u4f5c\u308b\u306e\u306f\u975e\u5e38\u306b\u7c21\u5358\u3067\u3001PlayerSettings\u306eOther Settings\u304b\u3089Virtual Reality Supported\u3092ON\u306b\u3057\u3066\u3001SDK\u306bCardboard\u306a\u3069\u3092\u5165\u308c\u308c\u3070\u3082\u3046VR [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12],"tags":[],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-unity","category-xrvr"],"_links":{"self":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=730"}],"version-history":[{"count":9,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":744,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions\/744"}],"wp:attachment":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}