コード例 #1
0
        void OnGUI()
        {
            GUILayout.Space(5);
            GUIStyle titleStyle = new GUIStyle(GUI.skin.label);

            titleStyle.wordWrap = true;
            EditorGUILayout.LabelField("Select an existing ARKitSettings object or create a new one.", titleStyle);

            EditorGUI.BeginChangeCheck();
            ARKitSettings.CurrentSettings =
                EditorGUILayout.ObjectField("ARKitSettings", ARKitSettings.CurrentSettings, typeof(ARKitSettings), false) as ARKitSettings;
            if (EditorGUI.EndChangeCheck())
            {
                ARKitSettings.TrySelect();
            }

            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Create New"))
            {
                Create();
            }

            if (GUILayout.Button("Close"))
            {
                Close();
            }

            EditorGUILayout.EndHorizontal();
        }
コード例 #2
0
        static void HandleARKitRequiredFlag(string pathToBuiltProject)
        {
            var           arkitSettings = ARKitSettings.GetOrCreateSettings();
            string        plistPath     = Path.Combine(pathToBuiltProject, "Info.plist");
            PlistDocument plist         = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            // Get or create array to manage device capabilities
            const string      capsKey = "UIRequiredDeviceCapabilities";
            PlistElementArray capsArray;
            PlistElement      pel;

            if (rootDict.values.TryGetValue(capsKey, out pel))
            {
                capsArray = pel.AsArray();
            }
            else
            {
                capsArray = rootDict.CreateArray(capsKey);
            }
            // Remove any existing "arkit" plist entries
            const string arkitStr = "arkit";

            capsArray.values.RemoveAll(x => arkitStr.Equals(x.AsString()));
            if (arkitSettings.ARKitRequirement == ARKitSettings.Requirement.Required)
            {
                // Add "arkit" plist entry
                capsArray.AddString(arkitStr);
            }

            File.WriteAllText(plistPath, plist.WriteToString());
        }
コード例 #3
0
            public void OnPreprocessBuild(BuildReport report)
            {
                if (report.summary.platform != BuildTarget.iOS)
                {
                    return;
                }

                if (string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription))
                {
                    throw new BuildFailedException("ARKit requires a Camera Usage Description (Player Settings > iOS > Other Settings > Camera Usage Description)");
                }

                EnsureOnlyMetalIsUsed();
                EnsureTargetArchitecturesAreSupported(report.summary.platformGroup);

                if (LinkerUtility.AssemblyStrippingEnabled(report.summary.platformGroup))
                {
                    LinkerUtility.EnsureLinkXmlExistsFor("ARKit");
                    var arkitSettings = ARKitSettings.GetOrCreateSettings();
                    if (arkitSettings.ARKitFaceTrackingEnabled)
                    {
                        LinkerUtility.EnsureLinkXmlExistsFor("ARKit.FaceTracking");
                    }
                }
            }
コード例 #4
0
            public void OnPreprocessBuild(BuildReport report)
            {
                if (report.summary.platform != BuildTarget.iOS)
                {
                    return;
                }

                if (string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription))
                {
                    throw new BuildFailedException("ARKit requires a Camera Usage Description (Player Settings > iOS > Other Settings > Camera Usage Description)");
                }

                SelectStaticLib();

                EnsureMetalIsFirstApi();

                if (ARKitSettings.GetOrCreateSettings().requirement == ARKitSettings.Requirement.Required)
                {
                    EnsureMinimumBuildTarget();
                    EnsureTargetArchitecturesAreSupported(report.summary.platformGroup);
                }
                else if (PlayerSettings.GetArchitecture(report.summary.platformGroup) == k_TargetArchitectureUniversal)
                {
                    EnsureOpenGLIsUsed();
                }

                BuildHelper.AddBackgroundShaderToProject(ARKitCameraSubsystem.backgroundShaderName);
            }
コード例 #5
0
        static LoaderEnabledCheck()
        {
            s_ARKitSettings = ARKitSettings.GetOrCreateSettings();
            ARKitBuildProcessor.s_LoaderEnabled = s_ARKitSettings.faceTracking;

            UpdateARKitDefines();
            EditorCoroutineUtility.StartCoroutineOwnerless(UpdateARKitDefinesCoroutine());
        }
コード例 #6
0
        static void ShowSelectionWindow()
        {
            ARKitSettings.TrySelect();
            Rect rect   = new Rect(500, 300, 400, 150);
            var  window = GetWindowWithRect <SettingsSelectionWindow>(rect);

            window.titleContent = new GUIContent("ARKit XR Plugin");
            window.Show();
        }
コード例 #7
0
        static SettingsProvider CreateSettingsProvider()
        {
            GUIContent s_WarningToCreateSettings = EditorGUIUtility.TrTextContent(
                "You must create a serialized instance of the settings data in order to modify the settings in this UI. Until then only default settings set by the provider will be available.");

            // First parameter is the path in the Settings window.
            // Second parameter is the scope of this setting: it only appears in the Project Settings window.
            var provider = new SettingsProvider("Project/XR/ARKit", SettingsScope.Project)
            {
                // By default the last token of the path is used as display name if no label is provided.
                label = "ARKit",

                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = (searchContext) =>
                {
                    if (ARKitSettings.currentSettings == null)
                    {
                        EditorGUILayout.HelpBox(s_WarningToCreateSettings);
                        if (GUILayout.Button(EditorGUIUtility.TrTextContent("Create")))
                        {
                            Create();
                        }
                        else
                        {
                            return;
                        }
                    }

                    var serializedSettings = ARKitSettings.GetSerializedSettings();

                    EditorGUILayout.PropertyField(serializedSettings.FindProperty("m_Requirement"), new GUIContent(
                                                      "Requirement",
                                                      "Toggles whether ARKit is required for this app. This will make the app only downloadable by devices with ARKit support if set to 'Required'."));

                    serializedSettings.ApplyModifiedProperties();
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = new HashSet <string>(new[] { "ARKit", "optional", "required" })
            };

            return(provider);
        }
コード例 #8
0
            public void OnPreprocessBuild(BuildReport report)
            {
                if (report.summary.platform != BuildTarget.iOS)
                {
                    return;
                }

                if (string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription))
                {
                    throw new BuildFailedException("ARKit requires a Camera Usage Description (Player Settings > iOS > Other Settings > Camera Usage Description)");
                }

                EnsureOnlyMetalIsUsed();
                EnsureTargetArchitecturesAreSupported(report.summary.platformGroup);

                var arkitSettings = ARKitSettings.GetOrCreateSettings();

                if (LinkerUtility.AssemblyStrippingEnabled(report.summary.platformGroup))
                {
                    LinkerUtility.EnsureLinkXmlExistsFor("ARKit");
                    if (arkitSettings.ARKitFaceTrackingEnabled)
                    {
                        LinkerUtility.EnsureLinkXmlExistsFor("ARKit.FaceTracking");
                    }
                }

                if (!arkitSettings.ARKitFaceTrackingEnabled)
                {
                    EnsureLinkXmlDoesNotContainFaceTracking();
                }

                var pluginImporter = AssetImporter.GetAtPath("Packages/com.unity.xr.arkit/Runtime/iOS/libUnityARKitFaceTracking.a") as PluginImporter;

                if (pluginImporter)
                {
                    pluginImporter.SetCompatibleWithPlatform(BuildTarget.iOS, arkitSettings.ARKitFaceTrackingEnabled);
                }
            }