Esempio n. 1
0
        public sealed override void OnInspectorGUI()
        {
            if (Utils.KeyHandler.HandleDetectKeyOnGUI(this.targets, Event.current))
            {
                return;
            }

            if (IsMainEditor && !typeof(ScriptableObject).IsAssignableFrom(target.GetType()))
            {
                var controlRect = EditorGUILayout.GetControlRect(false, 0.0f);
                if (m_icon == null)
                {
                    m_icon = IconManager.GetIcon("algoryx_white_shadow_icon");
                }

                if (m_icon != null)
                {
                    if (m_hideTexture == null)
                    {
#if UNITY_2019_3_OR_NEWER
                        var hideColor = Color.Lerp(InspectorGUI.BackgroundColor, Color.white, 0.03f);
#else
                        var hideColor = InspectorGUI.BackgroundColor;
#endif

                        m_hideTexture = GUI.CreateColoredTexture(1, 1, hideColor);
                    }

                    var hideRect = new Rect(controlRect.x,
#if UNITY_2019_3_OR_NEWER
                                            controlRect.y - 1.25f * EditorGUIUtility.singleLineHeight - 2,
#else
                                            controlRect.y - 1.00f * EditorGUIUtility.singleLineHeight - 1,
#endif
                                            18,
                                            EditorGUIUtility.singleLineHeight + 2);
                    UnityEngine.GUI.DrawTexture(hideRect, m_hideTexture);

                    var iconRect = new Rect(hideRect);
                    iconRect.height = 14.0f;
                    iconRect.width  = 14.0f;
#if UNITY_2019_3_OR_NEWER
                    iconRect.y += 2.5f;
#else
                    iconRect.y += 1.5f;
#endif
                    iconRect.x += 3.0f;
                    UnityEngine.GUI.DrawTexture(iconRect, m_icon);
                }

                InspectorGUI.BrandSeparator();
            }

            GUILayout.BeginVertical();

            ToolManager.OnPreTargetMembers(this.targets);

            DrawMembersGUI(this.targets, null, serializedObject);

            ToolManager.OnPostTargetMembers(this.targets);

            GUILayout.EndVertical();
        }
Esempio n. 2
0
        private void LicenseDataGUI(LicenseData data)
        {
            var highlight = m_licenseData.Count > 1 &&
                            !IsUpdatingLicenseInformation &&
                            !AGXUnity.LicenseManager.IsBusy &&
                            data.LicenseInfo.UniqueId == AGXUnity.LicenseManager.LicenseInfo.UniqueId;

            if (highlight && m_activeLicenseStyle == null)
            {
                m_activeLicenseStyle = new GUIStyle(InspectorEditor.Skin.Label);
            }
            // The texture is deleted when hitting stop in the editor while
            // m_activeLicenseStyle != null.
            if (m_activeLicenseStyle != null && m_activeLicenseStyle.normal.background == null)
            {
                m_activeLicenseStyle.normal.background = GUI.CreateColoredTexture(1,
                                                                                  1,
                                                                                  Color.Lerp(InspectorGUI.BackgroundColor,
                                                                                             Color.green,
                                                                                             0.025f));
            }

            var licenseFileButtons = new InspectorGUI.MiscButtonData[]
            {
                InspectorGUI.MiscButtonData.Create(MiscIcon.Update,
                                                   () =>
                {
                    RefreshLicense(data);
                },
                                                   UnityEngine.GUI.enabled &&
                                                   data.LicenseInfo.Type == AGXUnity.LicenseInfo.LicenseType.Service,
                                                   "Refresh license from server."),
                InspectorGUI.MiscButtonData.Create(MiscIcon.EntryRemove,
                                                   () =>
                {
                    var deactivateDelete = EditorUtility.DisplayDialog("Deactivate and erase license.",
                                                                       "Would you like to deactivate the current license " +
                                                                       "and remove the license file from this project?\n\n" +
                                                                       "It's possible to activate the license again in this " +
                                                                       "License Manager and/or download the license file again " +
                                                                       "from the license portal.",
                                                                       "Yes",
                                                                       "Cancel");
                    if (deactivateDelete)
                    {
                        AGXUnity.LicenseManager.DeactivateAndDelete(data.Filename);
                        StartUpdateLicenseInformation();
                    }
                },
                                                   UnityEngine.GUI.enabled,
                                                   "Deactivate and erase license file from project.")
            };

            var highlightScope = highlight ? new EditorGUILayout.VerticalScope(m_activeLicenseStyle) : null;

            InspectorGUI.SelectableTextField(GUI.MakeLabel("License file"),
                                             data.Filename,
                                             licenseFileButtons);
            InspectorGUI.SelectableTextField(GUI.MakeLabel("License type"), data.LicenseInfo.TypeDescription);

            InspectorGUI.Separator(1, 6);

            InspectorGUI.LicenseEndDateField(data.LicenseInfo);

            EditorGUILayout.EnumFlagsField(GUI.MakeLabel("Enabled modules",
                                                         false,
                                                         data.LicenseInfo.EnabledModules.ToString()),
                                           data.LicenseInfo.AllModulesEnabled ?
                                           AGXUnity.LicenseInfo.Module.All :
                                           data.LicenseInfo.EnabledModules,
                                           false,
                                           InspectorEditor.Skin.Popup);

            InspectorGUI.SelectableTextField(GUI.MakeLabel("User"), data.LicenseInfo.User);

            InspectorGUI.SelectableTextField(GUI.MakeLabel("Contact"), data.LicenseInfo.Contact);
            highlightScope?.Dispose();
        }