"Unity" 1.2 helloworld--test whether desktop and Android games work
Source: Internet
Author: User
<span id="Label3"></p><p><p>Categories: Unity, C #, VS2015</p></p><p><p>Date created: 2016-03-23 I. INTRODUCTION</p></p><p><p>This section first has one of the simplest unity games to verify if there is a problem with Unity's desktop game development environment and Android game development Environment. The functions implemented Are:</p></p><p><p>Deploy the game on a desktop computer, and a "Hello world!" appears in the Run WINDOW.</p></p><p><p>The game is deployed in the Android x86 emulator and a "Hello world!" is displayed on the run Screen. second, the design Steps</p></p><p><p>1. New Project</p></p><p><p>Run unity, Select "New", Enter the project name helloworld, Select "3D":</p></p><p><p></p></p> <p><p>Click "Create Project" and it will automatically enter the Unity3d development interface.</p></p><p><p>The following are common actions for views in the scene Panel:</p></p><p><p>Press the middle mouse button: pan view</p></p><p><p>Alt + left: Rotate View</p></p><p><p>Alt + Right (or wheel): push-pull view</p></p><p><p>2. Create a script file</p></p><p><p>Right-click "Asset" under project, Select "Create"-"folder", and the folders are named "Scripts".</p></p> <p><p></p></p> <p><p>Right-click "Scripts" and "Create" à "c # Script" under "Asset" and name it HELLOWORLD.</p></p><p><p>Double-click HelloWorld and it will automatically open the file in VS2015.</p></p><p><p></p></p> <p><p>Change the HelloWorld.cs file to the Following:</p></p><pre><span style="color: #0000ff"><span style="color: #0000ff">using</span></span><span style="color: #000000"><span style="color: #000000">unityengine;</span></span><span style="color: #0000ff"><span style="color: #0000ff">using</span></span><span style="color: #000000"><span style="color: #000000">system.collections;</span></span><span style="color: #0000ff"><span style="color: #0000ff"></span> public</span> <span style="color: #0000ff"><span style="color: #0000ff">class</span></span><span style="color: #000000"><span style="color: #000000">helloworld:monobehaviour{</span></span><span style="color: #008000"><span style="color: #008000">//</span></span><span style="color: #008000">Use this for <span style="color: #008000">initialization</span></span> <span style="color: #0000ff"><span style="color: #0000ff">void</span></span><span style="color: #000000"><span style="color: #000000">Start () {screen.fullscreen</span></span>=<span style="color: #0000ff"><span style="color: #0000ff">false</span></span><span style="color: #000000"><span style="color: #000000">; } </span></span><span style="color: #008000"><span style="color: #008000">//</span></span><span style="color: #008000"><span style="color: #008000">Update is called once per frame</span></span> <span style="color: #0000ff"><span style="color: #0000ff">void</span></span><span style="color: #000000"><span style="color: #000000">Update () {}</span></span><span style="color: #008000"><span style="color: #008000">//</span></span><span style="color: #008000"><span style="color: #008000">Show Hello</span> world</span> <span style="color: #0000ff"><span style="color: #0000ff">void</span></span><span style="color: #000000"><span style="color: #000000">Ongui () {GUI.skin.label.fontSize</span></span>=<span style="color: #800080"><span style="color: #800080"></span> -</span><span style="color: #000000"><span style="color: #000000">; </span></span><span style="color: #008000"><span style="color: #008000">//</span></span><span style="color: #008000"><span style="color: #008000">display area (x,y,w width, H height), "displayed Text")</span></span>Gui. Label (<span style="color: #0000ff"><span style="color: #0000ff">New</span></span>Rect (<span style="color: #800080"><span style="color: #800080"></span> the</span>,<span style="color: #800080"><span style="color: #800080"></span> -</span>, screen.width, screen.height),<span style="color: #800000"><span style="color: #800000">"</span></span><span style="color: #800000"><span style="color: #800000">Hello world!</span></span><span style="color: #800000"><span style="color: #800000">"</span></span><span style="color: #000000"><span style="color: #000000">); }}</span></span></pre><p><p>Press <F5> attach to Unity (atach to unity), after compilation succeeds, Press <Shift>+<F5> to End.</p></p><p><p>3. Add the script to the main camera (main Cameras)</p></p><p><p>Switch to the Unity development environment and add THE. CS script you just created to the main CAMERA.</p></p><p><p>Method 1: Drag and drop the script file in the assets to "Main Camera" in Hierarchy.</p></p> <p><p></p></p><p><p></p></p><p><p>Method 2: First select "Main Camera" in Hierarchy (hierarchy view), then select HelloWorld Script from "Scripts" in the "Component" menu. When the main camera is selected, you can see the HelloWorld script file for the camera from the Inspector panel.</p></p><p><p>4. Test Run Effect</p></p><p><p>Press the Play (triangle) button in the middle of the top to see the following results:</p></p><p><p></p></p><p><p>Press the play button again to end the Test.</p></p><p><p>5. Save the scene</p></p><p><p>Select "File" and "Save scene" to enter the scene name "HelloWorld":</p></p> <p><p></p></p><p><p>6. Add a scene as a level</p></p><p><p>The game is a close to let the player to play, each level is called a "checkpoint." Iii. publish the project as a game running on the desktop</p></p><p><p>1. Setting the window size</p></p><p><p>Select "file"--"build Settings ..." and in the pop-up "build Settings" window, click the "add Open Scenes" button and it will automatically add the Helloworld.unity file to the scene Collection. As shown in the Following:</p></p><p><p></p></p><p><p>In the Build Settings window, click Player Settings to set the game window to 800x600 (you can also set to a different size):</p></p> <p><p></p></p><p><p>2. Release the game</p></p><p><p>In the build Settings window, Select the level you want to publish (helloworld.unity), click the "build and Run" button, and in the popup window, change the file name to "HelloWorld.exe", as shown in, click "save":</p></p><p><p></p></p><p><p>You can now see the running window that pops up and the same results you see by pressing the play Button.</p></p> <p><p></p></p><p><p>This interface appears, stating that Unity's Desktop game development environment was successfully installed. Iv. publish the project as a game running on Android</p></p><p><p>1. Modify the Preferences</p></p><p><p>Select "Edit", "Preference ...":</p></p><p><p></p></p><p><p>In the preferences window, set the SDK, JDK path (see installation steps described in C # for Android app development), where the NDK is Empty. As shown in the Following:</p></p> <p><p>The window is closed after Setting.</p></p><p><p>Note Unity uses the 64-bit Android NDK r10e, not the 32-bit andoid NDK r10e that was originally Installed. If you want to enter the NDK path in this interface, click "Download" to download the 64-bit self-extracting file directly, download it and extract it to a folder and specify the Path.</p></p><p><p>2. Modify Android Inventory configuration</p></p><p><p>Select "File"--"build Settings ...", in the pop-up "build Settings" window, in the "Platform" option, select "Android" and click "Player Settings":</p></p> <p><p></p></p><p><p></p></p><p><p>Then modify "other Settings" to the following content:</p></p><p><p></p></p><p><p>3. Launch the x86 API 23 simulator</p></p><p><p>Switch to VS2015 and launch the x86 API 23 emulator:</p></p> <p><p></p></p><p><p></p></p><p><p></p></p><p><p>Wait a moment, wait until the simulator starts, then perform the following release game Steps.</p></p><p><p>4. Release the game</p></p><p><p>In the build Settings window, click the Build and Run button:</p></p><p><p></p></p><p><p>In the pop-up window, change the file name to "helloworld.apk", as shown in, click "save":</p></p> <p><p>You can see the effect of the run in the x86 emulator, as shown in:</p></p> <p><p></p></p><p><p></p></p><p><p>As you can see, whether You're publishing a game to the desktop or publishing it to an Android phone or simulator, the basic design steps (ii) are the same (the different platforms will be slightly different later in the individual locations). so, in the next chapters, we'll just master the basic development steps for desktop games, because mastering the basic steps of desktop game development, and then modifying the relevant code based on the platform you publish To.</p></p><p><p>"Unity" 1.2 helloworld--test whether desktop and Android games work</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service