Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Changelog
All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.1.0-preview.8] - 2018-07-30

* Updated UI for XR Manager to allow for adding, removing and reordering loaders. No more need for CreateAssetMenu attributes on loaders.
* Updated code to match formatting and code standards.

## [0.1.0-preview.7] - 2018-07-25

* Fix issue #3: Add ASMDEFs for sample code to get it to compile. No longer need to keep copy in project.
* Fix Issue #4: Update documentation to reflect API changes and to expand information and API documentation.
* Fix Issue #5: Move boilerplate loader code to a common helper base class that can be used if an implementor wants to.

## [0.1.0-preview.6] - 2018-07-17

### Added runtime tests for XRManager

### Updated code to reflect name changes for XR Subsystem types.

## [0.1.0-preview.5] - 2018-07-17

### Simplified settings for build/runtime

Since we are 2018.3 and later only we can take advantage of the new PlayerSettings Preloaded Assets API. This API allows us to stash assets in PLayerSettings that are preloaded at runtime. Now, instead of figuring out where to write a file for which build target we just use the standard Unity engine and code access to get the settings we need when we need them.

## [0.1.0-preview.4] - 2018-07-17

### Added samples and abiity to load settings

This change adds a full fledged sample base that shows how to work with XR Management from start to finish, across run and build. This includes serializing and de-serializing the settings.

## [0.1.0-preview.3] - 2018-07-17

## [0.1.0-preview.2] - 2018-06-22

### Update build settings management

Changed XRBuildData froma class to an attribute. This allows providers to use simpler SO classes for build data and not forece them to subclass anything.
Added a SettingsProvider subclass that wraps each of these attribute tagged classes. We use the display name from the attribute to populate the path in Unified Settings. The key in the attribute is used to store a single instance of the build settings SO in EditorBuildSettings as a single point to manage the instance.
Added code to auto create the first SO settings instance using a file panel since the Editor build settings container requires stored instances be backed in the Asset DB. There is no UI for creating the settings (unless added by the Provider) so this should allow us to maintain the singleton settings. Even if a user duplicates the settings instance, since it won't be in the Editor build settings container we won't honor it.

## [0.1.0-preview.1] - 2018-06-21

### This is the first release of *Unity Package XR SDK Management*.
  • Loading branch information
Unity Technologies committed Jul 29, 2018
0 parents commit ec68c87
Show file tree
Hide file tree
Showing 69 changed files with 2,273 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# see http://editorconfig.org/ for docs on this file

root = true

[*]
# help with sharing files across os's (i.e. network share or through local vm)
end_of_line = lf
#charset temporarily disabled due to bug in VS2017 changing to UTF-8 with BOM (https://favro.com/card/c564ede4ed3337f7b17986b6/Uni-17877)
#charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# formattable file extensions (keep in sync with format.ini from unity-meta repo)
#
# Note: We need to split the formattable files configs into shorter duplicate entries (logically grouped)
# due to known issue in VS editorconfig extension where there is a limit of 51 characters (empirically determined).
# see: https://github.com/editorconfig/editorconfig-visualstudio/issues/21
#
## uncrustify
[*.{c,h,cpp,hpp,m,mm,cc,cs}]
indent_style = space
indent_size = 4

## generic formatter (shaders)
[*.{cg,cginc,glslinc,hlsl,shader,y,ypp,yy}]
indent_style = space
indent_size = 4

## generic formatter (misc)
[*.{asm,s,S,pch,pchmm,java,sh,uss}]
indent_style = space
indent_size = 4

## perltidy
[*.{pl,pm,t,it}]
indent_style = space
indent_size = 4

## unity special
[*.{bindings,mem.xml}]
indent_style = space
indent_size = 4

# other filetypes we want to overwrite default configuration to preserve the standard
[{Makefile,makefile}]
# TAB characters are part of the Makefile format
indent_style = tab

[*.{md,markdown}]
# trailing whitespace is significant in markdown (bad choice, bad!)
trim_trailing_whitespace = false

# keep these and the VS stuff below in sync with .hgeol's CRLF extensions
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}]
end_of_line = crlf

# this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited.
# the settings are meant to closely match what VS does to minimize unnecessary diffs. this duplicates some settings in *
# but let's be explicit here to be safe (in case someone wants to copy-paste this out to another .editorconfig).
[*.{vcxproj,vcxproj.filters,csproj,props,targets}]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = false
[*.{sln,sln.template}]
indent_style = tab
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
8 changes: 8 additions & 0 deletions .gitattribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto

*.c text eol=lf
*.md text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.sh text eol=lf
*.cs text eol=lf
12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
image: node:6.10.0

stages:
- push_to_packman_staging

push_to_packman_staging:
stage: push_to_packman_staging
only:
- tags
script:
- curl -u $USERNAME:$API_KEY https://staging-packages.unity.com/auth > .npmrc
- npm publish
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Changelog
All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.1.0-preview.8] - 2018-07-30

* Updated UI for XR Manager to allow for adding, removing and reordering loaders. No more need for CreateAssetMenu attributes on loaders.
* Updated code to match formatting and code standards.

## [0.1.0-preview.7] - 2018-07-25

* Fix issue #3: Add ASMDEFs for sample code to get it to compile. No longer need to keep copy in project.
* Fix Issue #4: Update documentation to reflect API changes and to expand information and API documentation.
* Fix Issue #5: Move boilerplate loader code to a common helper base class that can be used if an implementor wants to.

## [0.1.0-preview.6] - 2018-07-17

### Added runtime tests for XRManager

### Updated code to reflect name changes for XR Subsystem types.

## [0.1.0-preview.5] - 2018-07-17

### Simplified settings for build/runtime

Since we are 2018.3 and later only we can take advantage of the new PlayerSettings Preloaded Assets API. This API allows us to stash assets in PLayerSettings that are preloaded at runtime. Now, instead of figuring out where to write a file for which build target we just use the standard Unity engine and code access to get the settings we need when we need them.

## [0.1.0-preview.4] - 2018-07-17

### Added samples and abiity to load settings

This change adds a full fledged sample base that shows how to work with XR Management from start to finish, across run and build. This includes serializing and de-serializing the settings.

## [0.1.0-preview.3] - 2018-07-17


## [0.1.0-preview.2] - 2018-06-22

### Update build settings management

Changed XRBuildData froma class to an attribute. This allows providers to use simpler SO classes for build data and not forece them to subclass anything.
Added a SettingsProvider subclass that wraps each of these attribute tagged classes. We use the display name from the attribute to populate the path in Unified Settings. The key in the attribute is used to store a single instance of the build settings SO in EditorBuildSettings as a single point to manage the instance.
Added code to auto create the first SO settings instance using a file panel since the Editor build settings container requires stored instances be backed in the Asset DB. There is no UI for creating the settings (unless added by the Provider) so this should allow us to maintain the singleton settings. Even if a user duplicates the settings instance, since it won't be in the Editor build settings container we won't honor it.

## [0.1.0-preview.1] - 2018-06-21

### This is the first release of *Unity Package XR SDK Management*.
7 changes: 7 additions & 0 deletions CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributing

## If you are interested in contributing, here are some ground rules:
* ... Define guidelines & rules for what contributors need to know to successfully make Pull requests against your repo ...

## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement)
By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions.

## Once you have a change ready following these ground rules. Simply make a pull request
7 changes: 7 additions & 0 deletions CONTRIBUTING.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions Documentation~/com.unity.xr.management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# About *XR SDK Management* package

Use the **XR SDK Management** package to help streamline **XR SDK** lifecycle management and potentially provide users with build time UI through the Unity **Unified Settings** system.

# End Users

## Add an **XRManager** instance to your scene

1) Create a new empty Game Object in your scene.
2) Add an instance of the **XRManager** component to this new Game Object.
3) Use the **XRManager** component Inspector UI to add/create, remove and reorder the loaders you widh to use.

## Customize build and runtime settings

Any package that needs build or runtime settings should provide a settings datatype for use. This will be surfaces in the **Unified Settings** UI window underneath a top leve **XR** node. By default a custom settings data instance will not be created. If you wish to modify build or runtime settings for the package you must go to the package authors entry in **Unified Settings** and select **Create**. This will create an instance of the settings that you can then modify inside of **Unified Settings**.

# Package Authors

## Lifecycle Management

This package provides for management of **XR SDK** subsystem lifecycles without the need for boilerplate code. The **XRManager** class provides a component that can be added to a game object in the scene that will manage initialization, start, stop and denitialization of a set of subsystems defined by an **XRLoader** instance. The **XRManager** instance can handle all of the lifecycle management, init/deinit only, subsystem start/stop only or can leave all of it up to the user.

A provider will create a subclass of **XRLoader** to provide a loader for their particular runtime scheme. An **XRLoader** is simply a **ScriptableObject** and as such, the user is able to create and instance (or more if they want) of the loader. Each **XRLoader** subclass defines the subsystems and their load order and is responsible for managing the set of subsystems they require. A user will add all the **XRLoaders** instances they created to the Loaders property on the **XRManager**, arranging them in the load order that they desire.

**_NOTE_**: _At this time there is no way for a provider to ship an instance of their loader in their package that the user can find. To get around this, you will need to provide a means of allowing the user to create the necessary instance of your loader. The recommendation for this is to add a CreateAssetMenu attribute to your loader class and set the menu location to "XR/Loaders/[your loader name]"._

When asked to initialize, **XRManager** will call each **XRLoader** instance it has a reference to in the order it has and attempt to initialize each one. The first loader that succeeds initialization becomes the active loader and all further attempts to initialize are stopped. From this point the user can ask for the static **XRManager.ActiveLoader** instance to get access to the active loader. If initialization fails for all loaders, **ActiveLoader** is set to null.

Automatic lifecycle management hooks into the following **MonoBehaviour** callback points:

|Callback|Lifecycle Step|
|---|---|
|OnEnable|Find the first loader that succeeds intiialization and set ActiveLoader.|
|Start|Start all subsystems|
|OnDisable|Stop all subsystems|
|OnDestroy|Deintialize all subsystems and remove the ActiveLoader instance.|


## Build and Runtime settings through *Unified Settings*

A provider may need optionl settings to help manage build issues or runtime configuration. They can do this by adding the **XRConfigurationData** attribute to a ScriptableObject and providing the set of properties they want to surface for users to control configuration. Configuration options will be surfaced in the **Unified Settings** window under the **XR** top level entry. We will manage the lifecycle for one instance of the class marked with the attribute through the EditorBuildSettings config object API. If no special UI is provided, the **Unified Settings** window will display the configuration settings using the standard **ScriptableObject** UI Inspector. A provider can extend the UI by creating a custom **Editor** for their configuration settings type and that will be used in the **Unified Settings** window instead.

# Installing *XR SDK Management*

To install this package, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest/index.html).

# Technical details

## Requirements

This version of **XR SDK Management** is compatible with the following versions of the Unity Editor:

* 2018.3 and later (recommended)

## Known limitations

* Still in preview.

## Package contents

This version of **XR SDK Management** includes:

* **XRManager** - This is a **MonoBehaviour** that can be added to a **GameObject** in a scene and provides for management of **XRLoader** instances and their lifecycle.
* **XRLoader** - This is the base class all loaders should derive from. It provides a basic the **XRManager** can use to manage lifecycle and a simple API to allow users to request specific subsystems from the loader as and when needed.
* **XRConfigurationData** - This is an attribute that allows for build and runtime settings to be hosted within the **Unified Settings** window. All instances will be hosted under the top level **XR** entry within the **Unified Settings** window under the name supplied as part of the attribute. The management package will maintain and manage the lifecycle for one instance of the build settings using **EditorBuildSettings** config object API, stored with the key provided in the attribute. At any time, the provider or the user is free access the configuration settings instance by asking **EditorBuildSettings** for the instance associated with the chosen key (as set in the attribute).
* **Samples** - There is a samples folder in the package that contains an implementation of all parts of XR Management. Copy that folder to a location in your project/package to get started with implementing XR Management for your needs.

## Document revision history

|Date|Reason|
|---|---|
|July 25, 2018|Update docs to reflect API changes.|
|June 22, 2018|Added updated information about the XRBuildData Attribute.|
|June 21, 2018|Document created.|
8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions Editor/TypeLoaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using UnityEditor;

using UnityEngine;
using UnityEngine.XR.Management;

namespace UnityEditor.XR.Management
{
internal static class TypeLoaderExtensions
{
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException("assembly");
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
}
}

public static IEnumerable<Type> GetTypesWithInterface<T>(this Assembly asm)
{
var it = typeof(T);
return from lt in asm.GetLoadableTypes()
where it.IsAssignableFrom(lt) && !lt.IsAbstract && !lt.IsInterface
select lt;
}

public static IEnumerable<Type> GetAllTypesWithInterface<T>()
{
IEnumerable<Type> ret = new List<Type>();

foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{
var vendorTypes = asm.GetTypesWithInterface<T>().ToList<Type>();
ret = ret.Concat(vendorTypes);
}

return ret;
}

public static IEnumerable<Type> GetTypesWithAttribute<T>(this Assembly asm)
{
var it = typeof(T);
return from lt in asm.GetLoadableTypes()
where (lt.GetCustomAttributes(it, true).Length > 0) && !lt.IsAbstract && !lt.IsInterface
select lt;
}

public static IEnumerable<Type> GetAllTypesWithAttribute<T>()
{
IEnumerable<Type> ret = new List<Type>();

foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{
var vendorTypes = asm.GetTypesWithAttribute<T>().ToList<Type>();
ret = ret.Concat(vendorTypes);
}

return ret;
}
}
}
11 changes: 11 additions & 0 deletions Editor/TypeLoaderExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Editor/Unity.XR.Management.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Unity.XR.Management.Editor",
"references": [
"Unity.XR.Management"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}
7 changes: 7 additions & 0 deletions Editor/Unity.XR.Management.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec68c87

Please sign in to comment.