static void DisableVRSettings()
        {
            bool          didTransitionVRDevice    = false;
            string        storedGroupsTransitioned = "";
            List <string> groupsTransitioned       = new List <string>();

            if (XRProjectSettings.HasSetting(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups))
            {
                XRProjectSettings.GetString(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups, storedGroupsTransitioned);
                groupsTransitioned.AddRange(storedGroupsTransitioned.Split(new char[] { ',' }));
            }

            foreach (BuildTargetGroup targetGroup in (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup)))
            {
                string targetGroupString = targetGroup.ToString();
                if (VREditor.GetVREnabledOnTargetGroup(targetGroup))
                {
                    Debug.LogFormat("XR SDK Provider detected in project. Disabling VR Device settings for {0}", targetGroup);
                    VREditor.SetVREnabledOnTargetGroup(targetGroup, false);
                    didTransitionVRDevice = true;
                    if (!groupsTransitioned.Contains(targetGroupString))
                    {
                        groupsTransitioned.Add(targetGroupString);
                    }
                }
            }

            if (didTransitionVRDevice)
            {
                storedGroupsTransitioned = String.Join(",", groupsTransitioned.ToArray());
                XRProjectSettings.SetString(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups, storedGroupsTransitioned);
            }

            XRProjectSettings.SetBool(XRProjectSettings.KnownSettings.k_VRDeviceDisabled, true);
        }
Ejemplo n.º 2
0
        public void EnableSettings()
        {
            var remotingEnabled = XRProjectSettings.GetBool(k_WsaRemoting);

            if (remotingEnabled)
            {
                PlayerSettings.SetWsaHolographicRemotingEnabled(remotingEnabled);
                XRProjectSettings.RemoveSetting(k_WsaRemoting);
            }
        }
Ejemplo n.º 3
0
        public void DisableSettings()
        {
            var remotingEnabled = PlayerSettings.GetWsaHolographicRemotingEnabled();

            if (remotingEnabled)
            {
                PlayerSettings.SetWsaHolographicRemotingEnabled(false);
                XRProjectSettings.SetBool(k_WsaRemoting, true);
            }
        }
Ejemplo n.º 4
0
    private void CreateAppKeyScript()
    {
        var temppath = FileUtil.GetUniqueTempPathInProject();

        string key = XRProjectSettings.MobileAppKey();

        if (key == null)
        {
            key = "";
        }

        string text =
            "// AUTOGENERATED, DO NOT EDIT\n"
            + "\n"
            + "namespace XRInternal {\n"
            + "namespace XRAutoGenerated {\n"
            + "public class XRMobileAppKey {\n";

        var isAppKeyValid = !String.IsNullOrEmpty(key) && XRProjectSettings.CheckAppKey();

        if (isAppKeyValid)
        {
            text = text
                   + "  // %key% will be replaced with the editor-supplied value on build.\n"
                   + "  public const string KEY = \"" + key + "\";\n";
        }

        text = text
               + "}\n"
               + "}\n"
               + "}\n";

        using (StreamWriter outputFile = new StreamWriter(temppath, true)) {
            outputFile.WriteLine(text);
        }

        FileUtil.ReplaceFile(temppath, "Assets/XR/Scripts/XRMobileAppKey.cs");

        if (!isAppKeyValid)
        {
            // Throw exception after replacing the app key file to ensure that a previously generated
            // file is not used.
            throw new BuildFailedException("XR app key is not valid for this app's bundle identifier. " +
                                           "Change it in XR > App Key Settings");
        }
    }
        static void EnableVRSettings()
        {
            string        storedGroupsTransitioned = "";
            List <string> groupsTransitioned       = new List <string>();

            XRProjectSettings.SetBool(XRProjectSettings.KnownSettings.k_VRDeviceDisabled, false);
            XRProjectSettings.SetBool(XRProjectSettings.KnownSettings.k_VRDeviceDidAlertUser, false);

            if (XRProjectSettings.HasSetting(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups))
            {
                storedGroupsTransitioned = XRProjectSettings.GetString(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups);
                groupsTransitioned.AddRange(storedGroupsTransitioned.Split(new char[] { ',' }));

                foreach (var tg in groupsTransitioned)
                {
                    BuildTargetGroup targetGroup;

                    try
                    {
                        targetGroup = (BuildTargetGroup)Enum.Parse(typeof(BuildTargetGroup), tg);
                    }
                    catch (Exception ex)
                    {
                        String logMsg = String.Format("Error converting build target group names {0}.\n", tg);
                        logMsg += ex.Message;

                        Debug.LogError(logMsg);
                        continue;
                    }

                    Debug.LogFormat("No XR SDK Provider detected in project. Re-enabling VR Device settings for {0}", targetGroup);
                    VREditor.SetVREnabledOnTargetGroup(targetGroup, true);
                    IVRDeviceSettingsTransition settingsTransition = GetTypeWithBuildTargetGroupAttribute(targetGroup);
                    if (settingsTransition != null)
                    {
                        settingsTransition.EnableSettings();
                    }
                }

                XRProjectSettings.RemoveSetting(XRProjectSettings.KnownSettings.k_VRDeviceTransitionGroups);
            }
        }