In Unity



A collider, which is invisible, does not need to be the exact same shape as the GameObject’s meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. Find 53 ways to say UNITY, along with antonyms, related words, and example sentences at Thesaurus.com, the world's most trusted free thesaurus. Description Interface into the Input system. Use this class to read the axes set up in the Conventional Game Input, and to access multi-touch/accelerometer data on mobile devices. To read an axis use Input.GetAxis with one of the following default axes. Standard Assets (for Unity 2018.4) (5099) FREE. Nature Starter Kit 2 (1379) FREE. Unity Technologies. 3D Game Kit (697) FREE. Free Platform Game Assets (411) FREE. Unity Technologies. Unity Particle Pack (260) FREE. Unity Technologies. Book Of The Dead: Environment. The easiest way to develop in Unity is with the Mixed Reality Toolkit. MRTK will help you automatically setup a project for Mixed Reality and provide a set of features to accelerate your development process.

Individuals, hobbyists and small businesses that have less than $100K of revenue or funds raised in the prior 12 months are eligible to use Unity Personal. Eligibility for individuals and hobbyists is based on revenues or funds in connection with the use of Unity. Eligibility for small businesses is based on any revenues or funds raised in the past 12 months.

Students enrolled in an accredited educational institution of legal age to consent to the collection and processing of their personal information (e.g., age 13 in the US, 16 in the EU) are eligible to use the free Unity Student plan.

If you or your company’s revenue or funding is less than $200K in the last 12 months, you are eligible to use Unity Plus.

Unity Pro or Unity Enterprise plans are required for businesses with revenue or funding greater than $200K in the last 12 months, and for those who do work with them. Pro and Enterprise plans have no financial eligibility limits – everyone is eligible. Please note that the Enterprise plan is for larger teams and requires a minimum purchase of 20 seats.

All plans are subject to Unity Terms of Service.

In Unity

In Unity

-->

Enabling the capability for camera access

The 'WebCam' capability must be declared for an app to use the camera.

  1. In the Unity Editor, go to the player settings by navigating to the 'Edit > Project Settings > Player' page
  2. Select the 'Windows Store' tab
  3. In the 'Publishing Settings > Capabilities' section, check the WebCam and Microphone capabilities

Only a single operation can occur with the camera at a time. You can check which mode the camera is currently in with UnityEngine.XR.WSA.WebCam.Mode in Unity 2018 and earlier or UnityEngine.Windows.WebCam.Mode in Unity 2019 and later. Available modes are photo, video, or none.

Photo capture

Namespace (before Unity 2019):UnityEngine.XR.WSA.WebCam
Namespace (Unity 2019 and later):UnityEngine.Windows.WebCam
Type:PhotoCapture

The PhotoCapture type allows you to take still photographs with the Photo Video Camera. The general pattern for using PhotoCapture to take a photo is as follows:

  1. Create a PhotoCapture object
  2. Create a CameraParameters object with the settings you want
  3. Start Photo Mode via StartPhotoModeAsync
  4. Take the photo you want
    • (optional) Interact with that picture
  5. Stop Photo Mode and clean up resources

Common set-up for PhotoCapture

For all three uses, start with the same first three steps above

Start by creating a PhotoCapture object

Next, store your object, set your parameters, and start Photo Mode

In the end, you'll also use the same clean-up code presented here

After these steps, you can choose which type of photo to capture.

Capture a photo to a file

Unity 3d

The simplest operation is to capture a photo directly to a file. The photo can be saved as a JPG or a PNG.

If you successfully started photo mode, take a photo and store it on disk

After capturing the photo to disk, exit photo mode and then clean up your objects

Capture a photo to a Texture2D with location

When capturing data to a Texture2D, the process is similar to capturing to disk.

Follow the setup process above.

In OnPhotoModeStarted, capture a frame to memory.

You'll then apply your result to a texture and use the common clean-up code above.

Locatable camera

To place this texture in the scene and display it using the locatable camera matrices, add the following code to OnCapturedPhotoToMemory in the result.success check:

Unity has provided sample code for applying the projection matrix to a specific shader on their forums.

Capture a photo and interact with the raw bytes

To interact with the raw bytes of an in memory frame, follow the same setup steps as above and OnPhotoModeStarted as in capturing a photo to a Texture2D. The difference is in OnCapturedPhotoToMemory where you can get the raw bytes and interact with them.

In this example, you'll create a List to be further processed or applied to a texture via SetPixels()

Video capture

Namespace (before Unity 2019):UnityEngine.XR.WSA.WebCam
Namespace (Unity 2019 and later):UnityEngine.Windows.WebCam
Type:VideoCapture

Unity

VideoCapture functions similarly to PhotoCapture. The only two differences are that you must specify a Frames Per Second (FPS) value and you can only save directly to disk as a .mp4 file. The steps to use VideoCapture are as follows:

  1. Create a VideoCapture object
  2. Create a CameraParameters object with the settings you want
  3. Start Video Mode via StartVideoModeAsync
  4. Start recording video
  5. Stop recording video
  6. Stop Video Mode and clean up resources

In Unity

Start by creating our VideoCapture object VideoCapture m_VideoCapture = null;

Next, set up the parameters you'll want for the recording and start.

In Unity And Peace

Once started, begin the recording

After recording has started, you could update your UI or behaviors to enable stopping. Here you just log.

At a later point, you'll want to stop the recording using a timer or user input, for instance.

Once the recording has stopped, stop video mode and clean up your resources.

Troubleshooting

  • No resolutions are available
    • Ensure the WebCam capability is specified in your project.

Next Development Checkpoint

If you're following the Unity development checkpoint journey we've laid out, you're in the midst of exploring the Mixed Reality platform capabilities and APIs. From here, you can continue to the next topic:

Or jump directly to deploying your app on a device or emulator:

You can always go back to the Unity development checkpoints at any time.

See Also