public ManifestEditor()
        {
            // A stylesheet can be added to a VisualElement.
            // The style will be applied to the VisualElement and all of its children.
            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(kAssetRoot + "/ManifestEditor.uss");

            styleSheets.Add(styleSheet);

            // Import UXML
            var tree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(kAssetRoot + "/ManifestEditor.uxml");

            tree.CloneTree(this);

            m_APILevel = this.Q <PlatformLevelSelector>("api-label");
            m_APILevel.RegisterValueChangedCallback(RefreshLists);

            TextField cmw = this.Q <TextField>("custom-manifest-warning");

            cmw.focusable = false;

            m_ManifestPoller = this.schedule.Execute(() =>
            {
                cmw.value = kCustomManifestWarning;
                cmw.EnableInClassList("warning--hidden", canEdit);
                this.Query <VisualElement>(null, "lockable").ForEach(ve => ve.SetEnabled(canEdit));
            }).Every(500L);

            cmw.value = kCustomManifestWarning;
            cmw.EnableInClassList("warning--hidden", canEdit);
            this.Query <VisualElement>(null, "lockable").ForEach(ve => ve.SetEnabled(canEdit));
        }
        private void UpdateSettings()
        {
            if (m_SettingsAsset == null)
            {
                this.Unbind();
                m_SerializedSettings = null;
                return;
            }
            else
            {
                m_SerializedSettings = m_SettingsAsset.ToSerializedObject();
            }
            {
                m_SerializedSettings.UpdateIfRequiredOrScript();
                // automatically bump the platform API the lowest possible version.
                var prop = m_SerializedSettings.FindProperty("m_MinimumAPILevel");
                prop.intValue = PlatformLevelSelector.EnsureValidValue(prop.intValue);
                m_SerializedSettings.ApplyModifiedProperties();
            }
            this.Bind(serializedSettings);

            this.Query <PrivilegeSection>().ForEach(ps => {
                ps.filterCallback = FilterPrivilege;
                ps.forceCallback  = ForcePrivilege;
                ps.settings       = m_SettingsAsset;
            });
        }
Beispiel #3
0
        public static void RenderManifest(MagicLeapManifestSettings settings)
        {
            var serializedObject = settings.ToSerializedObject();

            serializedObject.UpdateIfRequiredOrScript();
            var id         = GUIUtility.GetControlID(FocusType.Passive);
            var state      = (RenderState)GUIUtility.GetStateObject(typeof(RenderState), id);
            var missingSdk = !SDKUtility.sdkAvailable;

            if (missingSdk)
            {
                EditorGUILayout.HelpBox(Messages.kCannotLocateSDK, MessageType.Error, true);
            }
            using (new EditorGUI.DisabledScope(missingSdk))
            {
                var apiLevel = serializedObject.FindProperty("m_MinimumAPILevel");
                apiLevel.intValue = PlatformLevelSelector.SelectorGUI(apiLevel.intValue);
                EditorGUILayout.LabelField("Privileges", EditorStyles.boldLabel);
                var priv_groups = serializedObject.FindProperty("m_PrivilegeGroups");
                for (int i = 0; i < priv_groups.arraySize; i++)
                {
                    var group      = priv_groups.GetArrayElementAtIndex(i);
                    var group_name = group.FindPropertyRelative("m_Name").stringValue;
                    if (!state.GroupFoldoutExpanded.TryGetValue(group_name, out var _))
                    {
                        state.GroupFoldoutExpanded[group_name] = false;
                    }
                    state.GroupFoldoutExpanded[group_name] = EditorGUILayout.BeginFoldoutHeaderGroup(state.GroupFoldoutExpanded[group_name], group_name);
                    if (state.GroupFoldoutExpanded[group_name])
                    {
                        var privs = group.FindPropertyRelative("m_Privileges");
                        for (int j = 0; j < privs.arraySize; j++)
                        {
                            var priv    = privs.GetArrayElementAtIndex(j);
                            var enabled = priv.FindPropertyRelative("m_Enabled");
                            var name    = priv.FindPropertyRelative("m_Name").stringValue;

                            var disabled = ShouldDisable(apiLevel.intValue, priv);
                            var value    = UpdateValue(name, enabled.boolValue, disabled);
                            using (new EditorGUI.DisabledScope(disabled))
                                using (new EditorGUI.IndentLevelScope())
                                    enabled.boolValue = EditorGUILayout.ToggleLeft(name, value);
                        }
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();
                }
                serializedObject.ApplyModifiedProperties();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox(Messages.kShouldSynchronize, MessageType.Info, true);
                var sdkUpdateRequested = GUILayout.Button("Synchronize");
                if (sdkUpdateRequested)
                {
                    state.IsPerformingSDKUpdate  = true;
                    EditorApplication.delayCall += () => {
                        settings.RebuildPrivilegeGroups(PrivilegeParser.ParsePrivilegesFromHeader(Path.Combine(SDKUtility.sdkPath, PrivilegeParser.kPrivilegeHeaderPath)));
                        state.IsPerformingSDKUpdate = false;
                    };
                }
            }
        }