/// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="assetCache">The place for this MRE to cache its meshes, etc.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="engineConstants">Engine constants supplied by the host app.</param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            UnityEngine.Material defaultMaterial,
            IBehaviorFactory behaviorFactory       = null,
            ITextFactory textFactory               = null,
            IPrimitiveFactory primitiveFactory     = null,
            ILibraryResourceFactory libraryFactory = null,
            IAssetCache assetCache = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IUserInfoProvider userInfoProvider       = null,
            IEngineConstants engineConstants         = null,
            IMRELogger logger = null)
        {
            AppsAPI.DefaultMaterial        = defaultMaterial;
            AppsAPI.BehaviorFactory        = behaviorFactory;
            AppsAPI.TextFactory            = textFactory ?? throw new ArgumentException($"{nameof(textFactory)} cannot be null");
            AppsAPI.PrimitiveFactory       = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.LibraryResourceFactory = libraryFactory;
            AppsAPI.AssetCache             = assetCache ?? new AssetCache();
            AppsAPI.GLTFImporterFactory    = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher        = materialPatcher ?? new DefaultMaterialPatcher();
            AppsAPI.UserInfoProvider       = userInfoProvider ?? new NullUserInfoProvider();
            AppsAPI.EngineConstants        = engineConstants;

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger();
#else
            Logger = logger ?? new ConsoleLogger();
#endif
        }
        /// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="layerApplicator">The class used to apply MRE layers to Unity colliders.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="videoPlayerFactory"></param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="dialogFactory"></param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            UnityEngine.Material defaultMaterial,
            ILayerApplicator layerApplicator,
            IBehaviorFactory behaviorFactory         = null,
            ITextFactory textFactory                 = null,
            IPrimitiveFactory primitiveFactory       = null,
            ILibraryResourceFactory libraryFactory   = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IVideoPlayerFactory videoPlayerFactory   = null,
            IUserInfoProvider userInfoProvider       = null,
            IDialogFactory dialogFactory             = null,
            IMRELogger logger = null)
        {
            AppsAPI.DefaultMaterial        = defaultMaterial;
            AppsAPI.LayerApplicator        = layerApplicator;
            AppsAPI.BehaviorFactory        = behaviorFactory;
            AppsAPI.TextFactory            = textFactory ?? throw new ArgumentException($"{nameof(textFactory)} cannot be null");
            AppsAPI.PrimitiveFactory       = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.LibraryResourceFactory = libraryFactory;
            AppsAPI.VideoPlayerFactory     = videoPlayerFactory;
            AppsAPI.GLTFImporterFactory    = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher        = materialPatcher ?? new DefaultMaterialPatcher();
            AppsAPI.UserInfoProvider       = userInfoProvider ?? new NullUserInfoProvider();
            AppsAPI.DialogFactory          = dialogFactory;

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(null);
#else
            Logger = logger ?? new ConsoleLogger(null);
#endif
        }
        /// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="layerApplicator">The class used to apply MRE layers to Unity colliders.</param>
        /// <param name="assetCache">The class responsible for long-term asset caching.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="permissionManager">The instance responsible for presenting users with permission requests.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="dialogFactory"></param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="videoPlayerFactory"></param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            // required properties
            SpatialMaterial defaultMaterial,
            ILayerApplicator layerApplicator,
            IAssetCache assetCache,
            ITextFactory textFactory,
            IPermissionManager permissionManager,
            // missing features if omitted
            IBehaviorFactory behaviorFactory = null,
            //IDialogFactory dialogFactory = null,
            ILibraryResourceFactory libraryFactory = null,
            //IVideoPlayerFactory videoPlayerFactory = null,
            // reasonable defaults provided
            IPrimitiveFactory primitiveFactory       = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IMRELogger logger = null)
        {
            // required properties
            AppsAPI.DefaultMaterial   = defaultMaterial;
            AppsAPI.LayerApplicator   = layerApplicator;
            AppsAPI.AssetCache        = assetCache;
            AppsAPI.TextFactory       = textFactory;
            AppsAPI.PermissionManager = permissionManager;

            // missing features if omitted
            AppsAPI.BehaviorFactory = behaviorFactory;
            //AppsAPI.DialogFactory = dialogFactory;
            AppsAPI.LibraryResourceFactory = libraryFactory;
            //AppsAPI.VideoPlayerFactory = videoPlayerFactory;

            // reasonable defaults provided
            AppsAPI.PrimitiveFactory    = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.GLTFImporterFactory = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher     = materialPatcher ?? new DefaultMaterialPatcher();

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(null);
#else
            Logger = logger ?? new ConsoleLogger(null);
#endif
        }
        /// <summary>
        /// Initializes a new instance of the class <see cref="MixedRealityExtensionApp"/>
        /// </summary>
        /// <param name="globalAppId">The global id of the app.</param>
        /// <param name="ownerScript">The owner mono behaviour script for the app.</param>
        internal MixedRealityExtensionApp(string globalAppId, MonoBehaviour ownerScript, IMRELogger logger = null)
        {
            GlobalAppId     = globalAppId;
            _ownerScript    = ownerScript;
            EventManager    = new MWEventManager(this);
            _assetLoader    = new AssetLoader(ownerScript, this);
            _userManager    = new UserManager(this);
            _actorManager   = new ActorManager(this);
            SoundManager    = new SoundManager(this);
            _commandManager = new CommandManager(new Dictionary <Type, ICommandHandlerContext>()
            {
                { typeof(MixedRealityExtensionApp), this },
                { typeof(Actor), null },
                { typeof(AssetLoader), _assetLoader },
                { typeof(ActorManager), _actorManager }
            });

            RPC         = new RPCInterface(this);
            RPCChannels = new RPCChannelInterface();
            // RPC messages without a ChannelName will route to the "global" RPC handlers.
            RPCChannels.SetChannelHandler(null, RPC);
#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(this);
#else
            Logger = logger ?? new ConsoleLogger(this);
#endif
        }
        /// <summary>
        /// Initializes a new instance of the class <see cref="MixedRealityExtensionApp"/>
        /// </summary>
        /// <param name="globalAppId">A string uniquely identifying the MRE behind the server URL. Used for generating
        /// consistent user IDs when user tracking is enabled.</param>
        /// <param name="ephemeralAppId">A string uniquely identifying the MRE instance in the shared space across
        /// all clients. Used for generating user IDs when user tracking is disabled.</param>
        /// <param name="ownerScript">The owner mono behaviour script for the app.</param>
        internal MixedRealityExtensionApp(string globalAppId, string ephemeralAppId, Node ownerScript, IMRELogger logger = null)
        {
            GlobalAppId    = globalAppId;
            EphemeralAppId = ephemeralAppId;
            _ownerScript   = ownerScript;
            EventManager   = new MWEventManager(this);
            _assetLoader   = new AssetLoader(ownerScript, this);
            _userManager   = new UserManager(this);
            _actorManager  = new ActorManager(this);

            if (Constants.UsePhysicsBridge)
            {
                PhysicsBridge = new PhysicsBridge();
            }

            SoundManager     = new SoundManager(this);
            AnimationManager = new AnimationManager(this);
            _commandManager  = new CommandManager(new Dictionary <Type, ICommandHandlerContext>()
            {
                { typeof(MixedRealityExtensionApp), this },
                { typeof(Actor), null },
                { typeof(AssetLoader), _assetLoader },
                { typeof(ActorManager), _actorManager },
                { typeof(AnimationManager), AnimationManager }
            });

            var cacheRoot = new Node()
            {
                Name = "MRE Cache"
            };

            _ownerScript.AddChild(cacheRoot);
            cacheRoot.SetProcess(false);
            _assetManager = new AssetManager(this, cacheRoot);

            RPC         = new RPCInterface(this);
            RPCChannels = new RPCChannelInterface();
            // RPC messages without a ChannelName will route to the "global" RPC handlers.
            RPCChannels.SetChannelHandler(null, RPC);
#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(this);
#else
            Logger = logger ?? new ConsoleLogger(this);
#endif
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the class <see cref="MixedRealityExtensionApp"/>
        /// </summary>
        /// <param name="globalAppId">The global id of the app.</param>
        /// <param name="ownerScript">The owner mono behaviour script for the app.</param>
        internal MixedRealityExtensionApp(string globalAppId, MonoBehaviour ownerScript, IMRELogger logger = null)
        {
            GlobalAppId   = globalAppId;
            _ownerScript  = ownerScript;
            EventManager  = new MWEventManager(this);
            _assetLoader  = new AssetLoader(ownerScript, this);
            _userManager  = new UserManager(this);
            _actorManager = new ActorManager(this);

            UsePhysicsBridge = Constants.UsePhysicsBridge;

            if (UsePhysicsBridge)
            {
                _physicsBridge = new PhysicsBridge();
            }

            SoundManager     = new SoundManager(this);
            AnimationManager = new AnimationManager(this);
            _commandManager  = new CommandManager(new Dictionary <Type, ICommandHandlerContext>()
            {
                { typeof(MixedRealityExtensionApp), this },
                { typeof(Actor), null },
                { typeof(AssetLoader), _assetLoader },
                { typeof(ActorManager), _actorManager },
                { typeof(AnimationManager), AnimationManager }
            });

            var cacheRoot = new GameObject("MRE Cache");

            cacheRoot.transform.SetParent(_ownerScript.gameObject.transform);
            cacheRoot.SetActive(false);
            _assetManager = new AssetManager(this, cacheRoot);

            RPC         = new RPCInterface(this);
            RPCChannels = new RPCChannelInterface();
            // RPC messages without a ChannelName will route to the "global" RPC handlers.
            RPCChannels.SetChannelHandler(null, RPC);
#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(this);
#else
            Logger = logger ?? new ConsoleLogger(this);
#endif
        }