/// <summary>
 /// Displays the preferences for a feature.
 /// </summary>
 /// <param name="product">Product.</param>
 private void DisplayPreferences(AssetStoreProduct product)
 {
     m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
     {
         foreach (MethodInfo method in s_ProductMenuItems[product])
         {
             EditorGUILayout.LabelField(
                 method.ReflectedType.IsGenericType ?
                 string.Format(
                     "{0} ({1})",
                     method.ReflectedType.Name.ToWords().Range(0, -2),
                     ", ".Join(from t in method.ReflectedType.GetGenericArguments() select t.Name.ToWords())
                     ) : method.ReflectedType.Name.ToWords(),
                 EditorStyles.boldLabel
                 );
             EditorGUIX.DisplayHorizontalLine();
             EditorGUI.indentLevel += 1;
             method.Invoke(null, null);
             EditorGUI.indentLevel -= 1;
         }
     }
     EditorGUILayout.EndScrollView();
     // bug report button
     DisplayBugReportButton(product);
     // forum link button
     if (
         s_ProductForumUrls.ContainsKey(product) &&
         !string.IsNullOrEmpty(s_ProductForumUrls[product]) &&
         EditorGUIX.DisplayButton(string.Format("Get Help with {0}", product.ToString().ToWords()))
         )
     {
         OpenUrl(s_ProductForumUrls[product]);
     }
     // asset store page
     if (
         s_ProductPageUrls.ContainsKey(product) &&
         !string.IsNullOrEmpty(s_ProductPageUrls[product]) &&
         EditorGUIX.DisplayButton(
             string.Format("Review {0} on the Unity Asset Store", product.ToString().ToWords())
             )
         )
     {
         OpenUrl(s_ProductPageUrls[product]);
     }
     // products page
     if (EditorGUIX.DisplayButton("More Products by Candlelight Interactive"))
     {
         OpenUrl(s_PublisherPage);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Executes any registered scene GUI callbacks.
        /// </summary>
        /// <param name="ctx">Object from whose context this method is called.</param>
        /// <param name="width">Desired width of scene GUI area. 281 is minimum width for sliders to appear.</param>
        /// <param name="anchor">Corner of the viewport to which the controls should be anchored.</param>
        public static void Display(ISceneGUIContext ctx, float width = 281f, GUIAnchor anchor = GUIAnchor.TopLeft)
        {
            // early out if scene gui is disabled or there are no valid registered contexts
            if (
                !IsEnabled ||
                s_RegisteredContexts.Count == 0 ||
                s_RegisteredContexts.Count(k => k.Target != null && k.Callback != null) == 0
                )
            {
                return;
            }
            // ensure only the first context invoking this method during a layout phase will display the GUI
            if (Event.current.type == EventType.Layout)
            {
                s_DisplayInvoker = ctx.SceneGUIContext.target;
            }
            if (s_DisplayInvoker != ctx.SceneGUIContext.target)
            {
                return;
            }
            if (Event.current.type != EventType.Layout)
            {
                s_DisplayInvoker = null;
            }
            // begin gui matrix
            Handles.BeginGUI();
            // begin the area
            width = Mathf.Min(width, Screen.width - 2f * s_ViewportPadding);
            float   height  = Screen.height - 2f * s_ViewportPadding - SceneGUI.SceneViewTabHeight;
            GUISkin oldSkin = GUI.skin;

            GUI.skin = Skin;
            GUILayout.BeginArea(
                new Rect(
                    (anchor == GUIAnchor.LowerLeft || anchor == GUIAnchor.TopLeft) ?
                    s_ViewportPadding : Screen.width - s_ViewportPadding - width,
                    (anchor == GUIAnchor.TopLeft || anchor == GUIAnchor.TopRight) ?
                    s_ViewportPadding : Screen.height - s_ViewportPadding - height,
                    width,
                    height
                    )
                );
            {
                Color oldColor = GUI.color;
                GUI.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a * 0.65f);
                EditorGUILayout.BeginVertical(EditorStylesX.SceneBox);
                {
                    GUI.color        = oldColor;
                    s_ScrollPosition = EditorGUILayout.BeginScrollView(s_ScrollPosition, GUILayout.ExpandHeight(false));
                    {
                        for (int i = 0; i < s_RegisteredContexts.Count; ++i)
                        {
                            if (s_RegisteredContexts[i].Target == null || s_RegisteredContexts[i].Callback == null)
                            {
                                continue;
                            }
                            FontStyle fontStyle = GUI.skin.label.fontStyle;
                            GUI.skin.label.fontStyle = FontStyle.Bold;
                            EditorGUILayout.LabelField(
                                s_RegisteredContexts[i].Target.GetType().Name.ToWords(), GUI.skin.label
                                );
                            GUI.skin.label.fontStyle = fontStyle;
                            EditorGUIX.DisplayHorizontalLine();
                            ++EditorGUI.indentLevel;
                            s_RegisteredContexts[i].Callback.Invoke();
                            --EditorGUI.indentLevel;
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
            GUILayout.EndArea();
            GUI.skin = oldSkin;
            Handles.EndGUI();
        }