Unity WebGL Export on Azure

hypernaut


Play Hypernaut


Recommended Reading

+ Building and running a WebGL project
+ WebGL performance considerations


Attention

+ This post requires you to have a pre-existing website on Azure. If you need one, it takes 2min to setup WordPress on Azure.

+ My project did not use add-ons or plugins. Using either may not be compatible with WebGL.


wwwroot/web.config

mimeTypes
By default, Azure restricts access to the .mem and .data mimeTypes. In order for our project to run, we’ll need to add them to our web.config file located in our root folder.
webconfig_webgl


Unity Build Settings

+ Select File > Build Settings.
+ Switch platform to WebGL.
+ Edit Optimization Level to Fastest. This means our build will takes some time but will have all optimizations and a smaller build size which is great for the user.

WebGL allows you to select an Optimization level in the Build Player window. These correspond to optimization flags (-O1 – -O3) passed to the emscripten compiler. In general, “Slow” produces unoptimized builds, but has much lower build times then the other options, so it can be used for iterating on code issues. “Fast” produces optimized builds, and “Fastest” enables some additional optimizations, but makes your builds take a long time to complete (so you might want to use it only for final releases).

+ Select Player Settings > WebGL > Publishing Settings.
+ Edit WebGL Memory Size to the amount of memory required to run your project.

The WebGL memory size field in Publishing Settings lets you specifiy how much memory (in MB) the content should allocate for it’s heap. If this value is too low, you will get out of memory errors when your loaded content and scenes would not fit into the available memory. But if you set this value too high, your content might fail to load in some browsers or on some machines, because the browser might not have enough available memory to allocate the requested heap size.

webglexport


Build Performance tips
+ Don’t build Development builds when publishing as they are unminified to preserve function names.
+ Set Optimization Level to “Fastest”.
+ Set “Enable Exceptions” in Player Settings to “None”.
+ Enable “Stripping Level” in Player Settings, removes unused features.
+ Data caching downloads files to make additional launches faster.


FTP to Azure

From the Azure portal, navigate to your web app dashboard and scroll down to get your FTP settings. If you do not remember you password, you can reset via the Reset your deployment credentials link under quick glance section on the right side.
azureftpsettings

 

Open up your FTP program and transfer your Unity WebGL export over to Azure.

+ Place build folder under wwwroot.
+ Delete the file .htaccess from your project folder on Azure.
azureftp


Ready set play!

Play example http://glitchbeam.com/game/hypernaut.
hypernaut_webgl


What’s next?

+ Build a virtual arcade or apply towards your portfolio.
+ Monetization – Add Ads for additional revenue. Place them on the web pages and keep your projects clean.

Windows 10 Insider Preview on a MacBook Pro with Retina

This guide is about upgrading a Bootcamp install of Windows 8.1 to the Windows 10 Insider Preview on a MacBook Pro with a Retina display.

WARNING
Back up user data on each partition before OS upgrades.


Tested on the following computer
+  MacBook Pro 13” Retina | Fall 2014
+  OS X Yosemite w/ latest updates
+  Windows 8.1 w/ latest updates installed on Boot camp.

Resolves
+  Missing Apple Boot camp software and drivers.
+  Installation issues w/ Apple Boot camp software and drives.
+  System Freezing.
+  Black screens during and/or post login.


Boot into OS X
+  Download the latest OS updates and reboot if necessary.
+  Launch Boot Camp app and download the latest Windows drivers to USB drive.
+  Reboot back into Windows 8.1


Boot back into Windows 8.1
Get the Windows 10 Insider Preview.


Post Windows 10 upgrade
Plug in USB drive,  and run setup.exe to install Bootcamp software, then reboot.


Fixing Event Error 129, Storahci
Apply the registry fixes from the following site:
http://sebastian-foss-ee.blogspot.de/2015/01/storahci-id-129-reset-to-device.html

3D Modeling in Visual Studio Community

Visual Studio Model Editor features
+ Cone, cube, cylinder, disc, plane, sphere, and teapot
+ Edit vertices, faces, edges
+ Extrude faces
+ Subdivide faces
+ Merge objects
+ Materials
+ Shaders
+ Animation
+ Exports to FBX


Requirements
Visual Studio Community


Documentation
Visual Studio Model Editor
Unity – How to import a model


New File
Click File > New > File > Graphics > 3D Scene (.fbx).
vs3d


Shape Toolbox
Drag shape to scene to edit.

Merging objects
Click the Scripts icon > Scene Management > Merge Objects.
vs_fbx


Saving
Click File > Save All > and select a name/path.
vsfbx_Save

Using Visual Studio for main Unity IDE

The following post will cover changing your Unity IDE from MonoDevelop to Visual Studio on Windows.


Download Visual Studio Community


Select EDIT from the Unity menu and click on Preferences:
IMG_1786


In Unity Preferences, select External Tools.
Click the dropdown for External Script Editor and select Browse.
unityvs_01


Browse to C:\Program Files(x86)\Microsoft Visual Studio 12.0\Common7\IDE
Select file devenv.exe.
unityvs_02


External Script Editor should now read “Microsoft Visual Studio 2013”.
unityvs_03


For each script creation or edit, Visual Studio will launch.
vsunity

Getting started with Kinect v2 and Unity

IMG_17761


System Requirements:
+ Kinect for Xbox One
+ Kinect Adapter for Windows
+  Windows 8.0 or higher


Downloads
Unity 5 or higher
Visual Studio Community
Kinect SDK
Unity Kinect v2 add-on


+  Install the Kinect SDK.
+  Create a new project in Unity 5:
kinect00


+  Drag folders KinectView and GreenScreen into your root Unity Asset folder.
+  Double-click the file Kinect.2.0.1410.19000.unitypackage.
kinect01


Import all of the items from the Kinect package.
kinect02


+  Expand the KinectView folder and launch MainScene.
+  Press play to view [RGB Cam, IR Cam, Skeletal, and Depth Map].
kinect03

Unity touch screen position to world coordinates

IMG_1774_small

In Unity, your touch position on the screen does not equally translate to the world coordinates. To solve this, Unity has created a function that handles all of the conversion for you: http://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html


In this code example, you can spawn a prefab where you touch. Attach to an empty gameobject in your scene, and then make sure to link a prefab in the inspector.


using UnityEngine;
using System.Collections;

public class TouchFollow : MonoBehaviour
{
public GameObject prefab;

// Use this for initialization
void Start ()
{
}

// Update is called once per frame
void Update ()
{
// if touches are detected...
if (Input.touchCount > 0)
{
// loop through touches...
for (var i = 0; i < Input.touchCount; ++i)
{
// look for a touch down or a touch moved...
if (Input.GetTouch(i).phase == TouchPhase.Began || Input.GetTouch(i).phase == TouchPhase.Moved)
{
// grab current touch position
Vector2 touchPos = Input.GetTouch(i).position;

// convert touch's screen position to world coordinates
// z position is 10, camera is set to -10
Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, 10));

// spawn object at the converted world position
Instantiate(prefab, worldPos, transform.rotation);
}
}
}
}
}

WordPress on Azure

This guide will show you how to deploy WordPress to Azure.


Click on Websites in the left menu, and then `Create a website`.
01


From the pop-up menu, select Compute > Website > From Gallery
02


Scroll all the way down and select WordPress.
03


All you need to do here is name your URL, and select the Region.
04


This screen is auto-populated so just hit next…
05


06


Now all you need to do is click the URL or click Browse from the bottom menu to access your new WordPress site.
07


Finish.
08

Unity app crashes when building to Windows Store on Windows 10 Technical Preview

I’ve recently upgraded to Windows 10 Technical Preview and had some issues with Unity when targeting the Windows Store. Here are the steps to replicate with the solution is below:

  • Create a new project in Unity.
  • Change platform target to Windows Store.
  • Click Build and create a new build folder.
  • Open finished build project, which launches Visual Studio.
  • Change project to target x86 (from ARM).
  • Click the button with the green play symbol that reads Local Machine.
  • Your project will start to launch, then immediate crash (see image above).

If you review the console output in Visual Studio.  There is a mention of missing DirectX SDK files.  Go to the following website and download the updated files.  Make sure to read the downloads Readme file for instructions on what to do.

Download:  Windows 10 Technical Preview versions of D3D SDK layers DLLs