public override void _Ready()
    {
        if (!_apiInitialized)
        {
            var assetCacheGo = new Node {
                Name = "MRE Asset Cache"
            };
            var assetCache = new AssetCache();
            assetCacheGo.AddChild(assetCache);

            assetCache.CacheRootGO = new Node {
                Name = "Assets"
            };
            assetCacheGo.AddChild(assetCache.CacheRootGO);
            assetCache.CacheRootGO.SetProcess(false);

            MREAPI.InitializeAPI(
                defaultMaterial: DefaultPrimMaterial,
                layerApplicator: new SimpleLayerApplicator(0, 9, 10, 5),
                assetCache: assetCache,
                textFactory: new SimpleTextFactory(),
                permissionManager: new SimplePermissionManager(GrantedPermissions),
                behaviorFactory: new BehaviorFactory(),
                //dialogFactory: DialogFactory,
                libraryFactory: new ResourceFactory(),
                //gltfImporterFactory: new VertexShadedGltfImporterFactory(),
                //materialPatcher: new VertexMaterialPatcher(),
                logger: new MRELogger()
                );
            _apiInitialized = true;
        }

        //FIXME temp
        MREAPI.AppsAPI.PermissionManager = new MixedRealityExtension.Factories.SimplePermissionManager(GrantedPermissions);

        MREApp = MREAPI.AppsAPI.CreateMixedRealityExtensionApp(this, EphemeralAppID, AppID);

        if (SceneRoot == null)
        {
            SceneRoot = this;
        }

        MREApp.SceneRoot = SceneRoot;

        if (AutoStart)
        {
            EnableApp();
        }

        MREApp.RPC.OnReceive("log", new RPCHandler <TestLogMessage>(
                                 (logMessage) => GD.Print($"Log RPC of type {logMessage.GetType()} called with args [ {logMessage.Message}, {logMessage.TestBoolean} ]")
                                 ));

        // Functional test commands
        MREApp.RPC.OnReceive("functional-test:test-started", new RPCHandler <string>((testName) =>
        {
            GD.Print($"Test started: {testName}.");
        }));

        MREApp.RPC.OnReceive("functional-test:test-complete", new RPCHandler <string, bool>((testName, success) =>
        {
            GD.Print($"Test complete: {testName}. Success: {success}.");
        }));

        MREApp.RPC.OnReceive("functional-test:close-connection", new RPCHandler(() =>
        {
            MREApp.Shutdown();
        }));

        MREApp.RPC.OnReceive("functional-test:trace-message", new RPCHandler <string, string>((testName, message) =>
        {
            GD.Print($"{testName}: {message}");
        }));
    }
Exemplo n.º 2
0
    void Start()
    {
        if (!_apiInitialized)
        {
            MREAPI.InitializeAPI(
                defaultMaterial: DefaultPrimMaterial,
                layerApplicator: new SimpleLayerApplicator(0, 9, 10, 5),
                behaviorFactory: new BehaviorFactory(),
                textFactory: new TmpTextFactory()
            {
                DefaultFont   = DefaultFont,
                SerifFont     = SerifFont,
                SansSerifFont = SansSerifFont,
                MonospaceFont = MonospaceFont,
                CursiveFont   = CursiveFont
            },
                libraryFactory: new ResourceFactory(),
                userInfoProvider: new UserInfoProvider(),
                dialogFactory: DialogFactory,
                logger: new MRELogger(),
                materialPatcher: new VertexMaterialPatcher(),
                gltfImporterFactory: new VertexShadedGltfImporterFactory()
                );
            _apiInitialized = true;
        }

        MREApp = MREAPI.AppsAPI.CreateMixedRealityExtensionApp(AppID, this);

        if (SceneRoot == null)
        {
            SceneRoot = transform;
        }

        MREApp.SceneRoot = SceneRoot.gameObject;

        MREApp.OnConnecting    += MREApp_OnConnecting;
        MREApp.OnConnectFailed += MREApp_OnConnectFailed;
        MREApp.OnConnected     += MREApp_OnConnected;
        MREApp.OnDisconnected  += MREApp_OnDisconnected;
        MREApp.OnAppStarted    += MREApp_OnAppStarted;
        MREApp.OnAppShutdown   += MREApp_OnAppShutdown;

        if (AutoStart)
        {
            EnableApp();
        }

        MREApp.RPC.OnReceive("log", new RPCHandler <TestLogMessage>(
                                 (logMessage) => Debug.Log($"Log RPC of type {logMessage.GetType()} called with args [ {logMessage.Message}, {logMessage.TestBoolean} ]")
                                 ));

        // Functional test commands
        MREApp.RPC.OnReceive("functional-test:test-started", new RPCHandler <string>((testName) =>
        {
            Debug.Log($"Test started: {testName}.");
        }));

        MREApp.RPC.OnReceive("functional-test:test-complete", new RPCHandler <string, bool>((testName, success) =>
        {
            Debug.Log($"Test complete: {testName}. Success: {success}.");
        }));

        MREApp.RPC.OnReceive("functional-test:close-connection", new RPCHandler(() =>
        {
            MREApp.Shutdown();
        }));

        MREApp.RPC.OnReceive("functional-test:trace-message", new RPCHandler <string, string>((testName, message) =>
        {
            Debug.Log($"{testName}: {message}");
        }));
    }
Exemplo n.º 3
0
    void Start()
    {
        if (!_apiInitialized)
        {
            MREAPI.InitializeAPI(
                DefaultPrimMaterial,
                behaviorFactory: new BehaviorFactory(),
                textFactory: new MWTextFactory(SerifFont, SansSerifFont),
                libraryFactory: new ResourceFactory(),
                assetCache: new AssetCache(new GameObject("MRE Asset Cache")),
                userInfoProvider: new UserInfoProvider(),
                logger: new MRELogger());
            _apiInitialized = true;
        }

        MREApp = MREAPI.AppsAPI.CreateMixedRealityExtensionApp(AppID, this);

        if (SceneRoot == null)
        {
            SceneRoot = transform;
        }

        MREApp.SceneRoot = SceneRoot.gameObject;

        MREApp.OnConnecting    += MREApp_OnConnecting;
        MREApp.OnConnectFailed += MREApp_OnConnectFailed;
        MREApp.OnConnected     += MREApp_OnConnected;
        MREApp.OnDisconnected  += MREApp_OnDisconnected;
        MREApp.OnAppStarted    += MREApp_OnAppStarted;
        MREApp.OnAppShutdown   += MREApp_OnAppShutdown;

        if (AutoStart)
        {
            EnableApp();
        }

        MREApp.RPC.OnReceive("log", new RPCHandler <TestLogMessage>(
                                 (logMessage) => Debug.Log($"Log RPC of type {logMessage.GetType()} called with args [ {logMessage.Message}, {logMessage.TestBoolean} ]")
                                 ));

        // Functional test commands
        MREApp.RPC.OnReceive("functional-test:test-started", new RPCHandler <string>((testName) =>
        {
            Debug.Log($"Test started: {testName}.");
        }));

        MREApp.RPC.OnReceive("functional-test:test-complete", new RPCHandler <string, bool>((testName, success) =>
        {
            Debug.Log($"Test complete: {testName}. Success: {success}.");
        }));

        MREApp.RPC.OnReceive("functional-test:close-connection", new RPCHandler(() =>
        {
            MREApp.Shutdown();
        }));

        MREApp.RPC.OnReceive("functional-test:trace-message", new RPCHandler <string, string>((testName, message) =>
        {
            Debug.Log($"{testName}: {message}");
        }));
    }
Exemplo n.º 4
0
    void Start()
    {
        if (!_apiInitialized)
        {
            var assetCacheGo = new GameObject("MRE Asset Cache");
            var assetCache   = assetCacheGo.AddComponent <AssetCache>();
            assetCache.CacheRootGO = new GameObject("Assets");
            assetCache.CacheRootGO.transform.SetParent(assetCacheGo.transform, false);
            assetCache.CacheRootGO.SetActive(false);

            MREAPI.InitializeAPI(
                defaultMaterial: DefaultPrimMaterial,
                layerApplicator: new SimpleLayerApplicator(0, 9, 10, 5),
                assetCache: assetCache,
                textFactory: new TmpTextFactory()
            {
                DefaultFont   = DefaultFont,
                SerifFont     = SerifFont,
                SansSerifFont = SansSerifFont,
                MonospaceFont = MonospaceFont,
                CursiveFont   = CursiveFont
            },
                permissionManager: new SimplePermissionManager(GrantedPermissions),
                behaviorFactory: new MRTKBehaviorFactory(),
                dialogFactory: DialogFactory,
                libraryFactory: new ResourceFactory(),
                gltfImporterFactory: new VertexShadedGltfImporterFactory(),
                materialPatcher: new VertexMaterialPatcher(),
                logger: new MRELogger()
                );
            _apiInitialized = true;
        }

        MREApp = MREAPI.AppsAPI.CreateMixedRealityExtensionApp(this, AppID);

        if (SceneRoot == null)
        {
            SceneRoot = transform;
        }

        MREApp.SceneRoot = SceneRoot.gameObject;

        if (AutoStart)
        {
            EnableApp();
        }

        MREApp.RPC.OnReceive("log", new RPCHandler <TestLogMessage>(
                                 (logMessage) => Debug.Log($"Log RPC of type {logMessage.GetType()} called with args [ {logMessage.Message}, {logMessage.TestBoolean} ]")
                                 ));

        // Functional test commands
        MREApp.RPC.OnReceive("functional-test:test-started", new RPCHandler <string>((testName) =>
        {
            Debug.Log($"Test started: {testName}.");
        }));

        MREApp.RPC.OnReceive("functional-test:test-complete", new RPCHandler <string, bool>((testName, success) =>
        {
            Debug.Log($"Test complete: {testName}. Success: {success}.");
        }));

        MREApp.RPC.OnReceive("functional-test:close-connection", new RPCHandler(() =>
        {
            MREApp.Shutdown();
        }));

        MREApp.RPC.OnReceive("functional-test:trace-message", new RPCHandler <string, string>((testName, message) =>
        {
            Debug.Log($"{testName}: {message}");
        }));
    }