Пример #1
0
    private void SetEngineMode()
    {
        XREngineConfiguration.SpecialExecutionMode engineMode =
            XREngineConfiguration.SpecialExecutionMode.NORMAL;
        if (remoteOnly)
        {
            engineMode = XREngineConfiguration.SpecialExecutionMode.REMOTE_ONLY;
        }
        else if (disableNativeAr)
        {
            engineMode = XREngineConfiguration.SpecialExecutionMode.DISABLE_NATIVE_AR_ENGINE;
        }
        var configMessageBuilder = new MessageBuilder();
        var config = configMessageBuilder.initRoot(XRConfiguration.factory);

        config.getEngineConfiguration()
        .setMode(engineMode);
        bridge.CommitConfiguration(configMessageBuilder);
        xrEnvironment = XRNativeBridge.GetXREnvironment();

        if (cam != null)
        {
            UpdateCameraProjectionMatrix(cam, origin, facing, scale);
        }
    }
        StreamingSupport CheckStreamingSupport()
        {
            if (!enableRemote_)
            {
                return(StreamingSupport.UNSUPPORTED);
            }

            string assetFilePath = Path.Combine(Application.dataPath, versionInfoPath);

            // In certain config, the auto-updater is unavailable
            if (File.Exists(assetFilePath))
            {
                // Loading the version info from our asset
                UnityEngine.Object[] assetInfos = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(
                    Path.Combine("Assets", versionInfoPath));
                if (assetInfos.Length > 0)
                {
                    string version = null;
                    foreach (var assetObj in assetInfos)
                    {
                        var versionField = assetObj.GetType().GetField("version");
                        if (versionField != null)
                        {
                            version = (string)versionField.GetValue(assetObj);
                            break;
                        }
                    }
                    if (version != null)
                    {
                        XREnvironment.Reader pluginEnv = GetXREnvironment();
                        if (pluginEnv.hasEngineInfo())
                        {
                            string pluginVersion = pluginEnv.getEngineInfo().getXrVersion().ToString();
                            // When the build system doesn't inject the version number, we get 0.0.0.0
                            if (!pluginVersion.Equals("0.0.0.0") && (version != pluginVersion))
                            {
                                // Version doesn't match up
                                Debug.LogWarning("Restart Unity to re-enable 8th Wall remote in the " +
                                                 "editor. XR version " + version + " doesn't match the version loaded by Unity " + pluginVersion);
                                return(StreamingSupport.UNSUPPORTED);
                            }
                        }
                    }
                }
            }

            var orientation = UnityEditor.PlayerSettings.defaultInterfaceOrientation;

            if (orientation == UnityEditor.UIOrientation.AutoRotation)
            {
                Debug.LogError(
                    "For 8thWall XR, interface orientation must be fixed to portrait or landscape.");
                return(StreamingSupport.UNSUPPORTED);
            }

            return(StreamingSupport.SUPPORTED);
        }
 // Awake is called first at app startup.
 void Awake()
 {
     running = false;
     bridge  = new XRNativeBridge(enableRemote);
     bridge.Create(GetRenderingSystem());
     if (EnableRemote())
     {
         editorBridge = new XREditorBridge();
     }
     xrEnvironment = XRNativeBridge.GetXREnvironment();
     Application.targetFrameRate = 60;
 }
    void Update()
    {
        if (!explicitlyPaused)
        {
            RunIfPaused();
        }

        updateNumber++;

        if (EnableRemote())
        {
            bridge.SetEditorAppInfo(editorBridge.EditorAppInfo());

            bool firstConnect = false;
            if (!remoteConnected)
            {
                remoteConnected = bridge.IsRemoteConnected();
                firstConnect    = remoteConnected;
            }
            if (remoteConnected)
            {
                var remoteData = bridge.GetXRRemote();
                if (firstConnect)
                {
                    editorBridge.SetPlayerAspect(remoteData);
                    xrEnvironment = XRNativeBridge.GetXREnvironment();
                }
                editorBridge.SendDeviceInfo(remoteData);
                editorBridge.Update();

                // Send camera aspect info to editor on every frame, in case the preview size changes.
                ConfigureXR();
            }
            else
            {
                editorBridge.CheckADB();
            }
        }

        var r = GetCurrentReality();

        if (lastRealityMicros >= r.getEventId().getEventTimeMicros())
        {
            return;
        }
        lastRealityMicros = r.getEventId().getEventTimeMicros();
    }