Google Cardboard Virtual reality Glasses Development Preliminary (ii)
Cardboard SDK for unity use
The previous article as the beginning of the series, mainly on some of the virtual reality of the technology and principles, this article will lead you to see Google's cardboard SDK for Unity, although the current data and documents less, but this package is still very convenient to use, It's easy to use only if you have a little touch with unity. I will explain in the way that unity has just begun to learn.
For the convenience of everyone to read. I will try to write the steps as carefully as possible, the relevant Google official online English materials and my own translation of Chinese references I will also be published in the form of blog, easy to access Google's students to read and download.
(a) download cardboard SDK for Unity on official website
Google Cardboard Official site:
https://www.google.com/get/cardboard/
Go to the Developer Guide page of the Google Cardboard official site and click Download and Samples under the unity SDK on the left:
Https://developers.google.com/cardboard/unity/download
Click Download Cardboard SDK for Unity, direct link to zip, to download;
Students who don't have access to Google can also download it in the files I upload:
http://download.csdn.net/detail/sunmc1204953974/8888421
Just better go to the official website to download the latest package. Because of how long this just haunted. The replacement is very fast.
(ii) Import Cardboardsdkforunity.unitypackage
Note here, assuming that the SDK package was previously downloaded, There is only one cardboardsdkforunity.unitypackage, including the support code and a sample after the import, and the new SDK package downloaded from the official website includes cardboardsdkforunity.unitypackage and cardboardsdkfor Unity.unitypackage two packs, the first one is the library, the second one is the demo. are imported to execute the instance.
First open unity,new a new project.
(I'm using the latest unity5,unity5 compared to the previous version number has a big change, the current data is less, but now also has a lot of people use.)
)
After. Custom package, assets, Import package ...
Introduce the downloaded SDK package. (as the Scarlet Letter said, the newly downloaded SDK package needs to be introduced two times)
(iii) Implementation of the demoscene
We see that after importing the. unitypackage file, there is a cardboard directory in the Project panel's resource directory, which is the SDK plug-in Code and demo demo sample to see the demoscene directory under the cardboard directory. This is one of the demo examples (there is also a demo sample under the Legacy directory.) In the following article I do the code to stare at the time to speak again). Double-click the scene file demoscene. Open the Demo sample.
Click the Execute button (small arrow) above to see how the demo demo will perform.
After execution. Press ALT to move the mouse to simulate head rotation, and hold CTRL to simulate the change of perspective when the crooked neck. Click the mouse equivalent to trigger, can be used to operate.
This demo has a few features in general:
Look at the small yellow dots pointing at the box, click the mouse. The block will be driven to a random position on a distance-constrained sphere.
When looking at a block, the block will turn from red to green, and the block will change from green to red when looking away from the block.
At the foot there are three buttons, each naturally
- Reset: Once again put the block back in its original position
- Recenter: To return to the middle in the left and right direction again
- VR mode: Turn VR on or off (split screen or not)
We see that the demo code has only one file, and it's very short, just a few lines of script to achieve this effect (split screen, gyroscope, perspective rotation ...) , I have to say that the Cardboard SDK is very powerful, perhaps I will write an article to analyze this demo and code, to help you understand the use of the Cardboard SDK at a high speed.
In the process of reading Code and development. To be able to participate in the examiner's Web document, I will also send an English document and a copy of the documents I read by the way, help inconvenient on Google's classmates.
Then set the ANDROIDSDK path. Package Export to Android project, after installation on the phone. Can be placed in the cardboard or storm mirror and other finished mirror to feel the ~ if the phone screen resolution is high, the feeling is very good.
Set ANDROIDSDK:
There's no detail here. A whole bunch of tutorials online.
Export Android APK:
Note here that the following player Settings is required and some settings will appear on the right side. The package name must be set again here. Otherwise, using the default package name is not packaged. At the same time can also be set in this app's icon, name. Wait a minute
Effects after installation to the phone:
My cell phone pixel is relatively low, but put in the storm magic mirror feeling is still good. Next time I will teach you how to create a scene of your own, put your own model into the scene, with virtual reality glasses to appreciate the operation. Maybe I'll dissect the demo's Code and official documentation, enumerate the methods that are often called in virtual reality development, and how to do further development. Please look forward to ~
Preliminary study on virtual reality development of cardboard (II.)