Ejemplo n.º 1
0
    protected virtual XElement CreateCapabilityElement(PlayerSettings.WSACapability cap)
    {
        string str = cap.ToString();

        str = char.ToLowerInvariant(str[0]) + str.Substring(1);
        return(new XElement((XName)(this.GetNamespaceForCapability(cap) + "Capability"), new XAttribute("Name", str)));
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Given capability is required by the given component. Check if capability is enabled, if not auto-enable if possible and log to console
 /// </summary>
 /// <param name="capability">Desired capability needed</param>
 /// <param name="dependentComponent">Component type that requires the associated capability to perform operations</param>
 public static void RequireCapability(PlayerSettings.WSACapability capability, Type dependentComponent)
 {
     // Any changes made in editor while playing will not save
     if (!EditorApplication.isPlaying && !PlayerSettings.WSA.GetCapability(capability))
     {
         if (MixedRealityPreferences.AutoEnableUWPCapabilities)
         {
             Debug.Log($"<b>{dependentComponent.Name}</b> requires the UWP <b>{capability.ToString()}</b> capability. Auto-enabling this capability in Player Settings.\nDisable this automation tool via MRTK Preferences under <i>Project Settings</i>.");
             PlayerSettings.WSA.SetCapability(capability, true);
         }
         else
         {
             Debug.LogWarning($"<b>{dependentComponent.Name}</b> requires the UWP <b>{capability.ToString()}</b> capability which is currently not enabled. To utilize this component on device, enable the capability in <i>Player Settings</i> > <i>Publishing Settings</i>.");
         }
     }
 }
Ejemplo n.º 3
0
 void capabilityToggle(PlayerSettings.WSACapability mCap, string tooltip)
 {
     PlayerSettings.WSA.SetCapability(mCap, GUILayout.Toggle(PlayerSettings.WSA.GetCapability(mCap), new GUIContent(" " + mCap.ToString(), tooltip)));
 }
Ejemplo n.º 4
0
        public override void PublishSectionGUI(float h, float kLabelMinWidth, float kLabelMaxWidth)
        {
            GUIContent content;
            float      minHeight = h;
            float      maxHeight = h;

            GUILayout.Label(EditorGUIUtility.TextContent("Packaging"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroPackageName, EditorGUIUtility.TextContent("Package name|Specifies the unique name that identifies the package on the system."), new GUILayoutOption[0]);
            this.m_MetroPackageName.stringValue = Utility.TryValidatePackageName(this.m_MetroPackageName.stringValue);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Package display name|Specifies the app name that appears in the Store. Same as Product Name."), new GUIContent(this.m_ProductName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroPackageVersion, EditorGUIUtility.TextContent("Version|The version number of the package. A version string in quad notation \"Major.Minor.Build.Revision\"."), new GUILayoutOption[0]);
            this.m_MetroPackageVersion.stringValue = PlayerSettings.WSA.ValidatePackageVersion(this.m_MetroPackageVersion.stringValue);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Publisher display name|A friendly name for the publisher that can be displayed to users. Same as Company Name."), new GUIContent(this.m_CompanyName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.Space();
            GUILayout.Label(EditorGUIUtility.TextContent("Certificate"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Publisher"), new GUIContent(PlayerSettings.WSA.certificateSubject), new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Issued by"), new GUIContent(PlayerSettings.WSA.certificateIssuer), new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Expiration date"), new GUIContent(!PlayerSettings.WSA.certificateNotAfter.HasValue ? null : PlayerSettings.WSA.certificateNotAfter.Value.ToShortDateString()), new GUILayoutOption[0]);
            Rect   rect            = GUILayoutUtility.GetRect(kLabelMinWidth, kLabelMaxWidth, minHeight, maxHeight, EditorStyles.layerMaskField);
            Rect   position        = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y, rect.width - EditorGUIUtility.labelWidth, rect.height);
            string certificatePath = PlayerSettings.WSA.certificatePath;

            if (string.IsNullOrEmpty(certificatePath))
            {
                content = EditorGUIUtility.TextContent("Select...|Browse for certificate.");
            }
            else
            {
                content = new GUIContent(FileUtil.GetLastPathNameComponent(certificatePath), certificatePath);
            }
            if (GUI.Button(position, content))
            {
                certificatePath = EditorUtility.OpenFilePanel(null, Application.dataPath, "pfx").Replace('\\', '/');
                string projectRelativePath = FileUtil.GetProjectRelativePath(certificatePath);
                if (string.IsNullOrEmpty(projectRelativePath) && !string.IsNullOrEmpty(certificatePath))
                {
                    Debug.LogError("Certificate path '" + Path.GetFullPath(certificatePath) + "' has to be relative to " + Path.GetFullPath(Application.dataPath + @"\.."));
                }
                else
                {
                    try
                    {
                        if (!PlayerSettings.WSA.SetCertificate(projectRelativePath, null))
                        {
                            MetroCertificatePasswordWindow.Show(projectRelativePath);
                        }
                    }
                    catch (UnityException exception)
                    {
                        Debug.LogError(exception.Message);
                    }
                }
            }
            rect     = GUILayoutUtility.GetRect(kLabelMinWidth, kLabelMaxWidth, minHeight, maxHeight, EditorStyles.layerMaskField);
            position = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y, rect.width - EditorGUIUtility.labelWidth, rect.height);
            if (GUI.Button(position, EditorGUIUtility.TextContent("Create...|Create test certificate.")))
            {
                MetroCreateTestCertificateWindow.Show(this.m_CompanyName.stringValue);
            }
            EditorGUILayout.Space();
            GUILayout.Label(EditorGUIUtility.TextContent("Application UI"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Display name|Specifies the full name of the app."), new GUIContent(this.m_ProductName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroApplicationDescription, EditorGUIUtility.TextContent("Description|Specifies the text that describes the app on its tile in Windows."), new GUILayoutOption[0]);
            this.m_MetroApplicationDescription.stringValue = this.ValidateMetroApplicationDescription(this.m_MetroApplicationDescription.stringValue);
            EditorGUILayout.Space();
            GUILayout.Label("File Type Associations", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Name:", new GUILayoutOption[0]);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
            this.m_MetroFTAName.stringValue = GUILayout.TextField(this.m_MetroFTAName.stringValue, options);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("File Types", EditorStyles.boldLabel, new GUILayoutOption[0]);
            bool flag = !string.IsNullOrEmpty(this.m_MetroFTAName.stringValue);

            if (flag)
            {
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinHeight(100f) };
                this.metroFTAFileTypesScrollViewPosition = GUILayout.BeginScrollView(this.metroFTAFileTypesScrollViewPosition, EditorStyles.helpBox, optionArray2);
                int         index      = -1;
                int         num4       = 0;
                IEnumerator enumerator = this.m_MetroFTAFileTypes.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        SerializedProperty current = (SerializedProperty)enumerator.Current;
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.BeginVertical(new GUILayoutOption[0]);
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.Label("Content Type:", new GUILayoutOption[0]);
                        SerializedProperty property2 = current.FindPropertyRelative("contentType");
                        if (property2 != null)
                        {
                            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                            property2.stringValue = GUILayout.TextField(property2.stringValue, optionArray3);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.Label("File Type:", new GUILayoutOption[0]);
                        SerializedProperty property3 = current.FindPropertyRelative("fileType");
                        if (property3 != null)
                        {
                            GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                            property3.stringValue = GUILayout.TextField(property3.stringValue, optionArray4).ToLower();
                        }
                        GUILayout.EndHorizontal();
                        GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                        if (GUILayout.Button("Remove", optionArray5))
                        {
                            index = num4;
                        }
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                        num4++;
                        if (num4 < this.m_MetroFTAFileTypes.arraySize)
                        {
                            GUILayoutOption[] optionArray6 = new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1f) };
                            GUILayout.Box(GUIContent.none, EditorStyles.helpBox, optionArray6);
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                if ((index >= 0) && (index < this.m_MetroFTAFileTypes.arraySize))
                {
                    this.m_MetroFTAFileTypes.DeleteArrayElementAtIndex(index);
                }
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("Please specify Name first.", new GUILayoutOption[0]);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            using (new EditorGUI.DisabledScope(!flag))
            {
                if (GUILayout.Button("Add New", new GUILayoutOption[0]))
                {
                    this.m_MetroFTAFileTypes.InsertArrayElementAtIndex(this.m_MetroFTAFileTypes.arraySize);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("Protocol", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Name:", new GUILayoutOption[0]);
            GUILayoutOption[] optionArray7 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
            this.m_MetroProtocolName.stringValue = GUILayout.TextField(this.m_MetroProtocolName.stringValue, optionArray7).ToLower();
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("Compilation", EditorStyles.boldLabel, new GUILayoutOption[0]);
            PlayerSettings.WSA.compilationOverrides = (PlayerSettings.WSACompilationOverrides)EditorGUILayout.EnumPopup(EditorGUIUtility.TextContent("Compilation Overrides"), PlayerSettings.WSA.compilationOverrides, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            GUILayout.Label("Misc", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            PlayerSettings.WSA.inputSource = (PlayerSettings.WSAInputSource)EditorGUILayout.EnumPopup(EditorGUIUtility.TextContent("Input Source"), PlayerSettings.WSA.inputSource, new GUILayoutOption[0]);
            GUILayout.Label("Capabilities", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayoutOption[] optionArray8 = new GUILayoutOption[] { GUILayout.MinHeight(200f) };
            this.capScrollViewPosition = GUILayout.BeginScrollView(this.capScrollViewPosition, EditorStyles.helpBox, optionArray8);
            IEnumerator enumerator2 = Enum.GetValues(typeof(PlayerSettings.WSACapability)).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    PlayerSettings.WSACapability capability = (PlayerSettings.WSACapability)enumerator2.Current;
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    bool introduced33 = PlayerSettings.WSA.GetCapability(capability);
                    GUILayoutOption[] optionArray9 = new GUILayoutOption[] { GUILayout.MinWidth(150f) };
                    bool flag2 = GUILayout.Toggle(introduced33, capability.ToString(), optionArray9);
                    PlayerSettings.WSA.SetCapability(capability, flag2);
                    GUILayout.EndHorizontal();
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 != null)
                {
                    disposable2.Dispose();
                }
            }
            GUILayout.EndScrollView();
        }