コード例 #1
0
 /// <summary>
 /// Raises the GUI event.
 /// </summary>
 /// <param name="position">Position.</param>
 /// <param name="property">Property.</param>
 /// <param name="label">Label.</param>
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     EditorGUI.BeginProperty(position, label, property);
     {
         if (label != null && label != GUIContent.none)
         {
             EditorGUI.PrefixLabel(position, label);
             position.x = position.x + EditorGUIUtility.labelWidth;
         }
         FontStyle fontStyle = (FontStyle)property.intValue;
         position.width   = EditorGUIUtility.singleLineHeight * 1.25f;
         position.height -= 1f;
         EditorGUI.BeginChangeCheck();
         bool bold = fontStyle == FontStyle.Bold || fontStyle == FontStyle.BoldAndItalic;
         if (EditorGUIX.DisplayButton(position, "b", BoldButtonStyle, bold))
         {
             bold = !bold;
         }
         position.x += position.width;
         bool italic = fontStyle == FontStyle.Italic || fontStyle == FontStyle.BoldAndItalic;
         if (EditorGUIX.DisplayButton(position, "i", ItalicButtonStyle, italic))
         {
             italic = !italic;
         }
         if (EditorGUI.EndChangeCheck())
         {
             property.intValue = (int)(
                 bold && italic ? FontStyle.BoldAndItalic :
                 bold ? FontStyle.Bold : italic ? FontStyle.Italic : FontStyle.Normal
                 );
         }
     }
     EditorGUI.EndProperty();
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
ファイル: BaseEditor.cs プロジェクト: desmond0412/LegacyWTOS
        /// <summary>
        /// Displays an error message with optional buttons to fix errors.
        /// </summary>
        /// <returns>
        /// <see langword="true"/> if the fix button was pressed; otherwise, <see langword="false"/>.
        /// </returns>
        /// <param name="errorMessage">Error message to display.</param>
        /// <param name="buttonTexts">Button texts. If null or empty then no buttons will be displayed.</param>
        /// <param name="messageType">Message type.</param>
        /// <param name="controlIds">
        /// Control identifiers. If left unspecified, then the text of each label will be used to generate them.
        /// </param>
        protected static int DisplayErrorMessageWithFixButtons(
            string errorMessage,
            GUIContent[] buttonTexts,
            MessageType messageType = MessageType.Error,
            int[] controlIds        = null
            )
        {
            int   result   = -1;
            Color oldColor = GUI.color;

            switch (messageType)
            {
            case MessageType.Error:
                GUI.color = Color.red;
                break;

            case MessageType.Warning:
                GUI.color = Color.yellow;
                break;
            }
            if (controlIds != null && controlIds.Length != buttonTexts.Length)
            {
                Debug.LogError(
                    "Different number of button labels and control identifiers specified. " +
                    "Specified control identifiers will be ignored."
                    );
                controlIds = null;
            }
            EditorGUILayout.BeginVertical(EditorStylesX.Box);
            {
                GUI.color = oldColor;
                EditorGUILayout.HelpBox(errorMessage, messageType);
                if (buttonTexts != null)
                {
                    for (int i = 0; i < buttonTexts.Length; ++i)
                    {
                        if (
                            buttonTexts[i] != null &&
                            EditorGUIX.DisplayButton(buttonTexts[i], controlId: controlIds == null ? 0 : controlIds[i])
                            )
                        {
                            result = i;
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();
            return(result);
        }
コード例 #4
0
 /// <summary>
 /// Displays the bug report button.
 /// </summary>
 /// <param name="product">Product.</param>
 private static void DisplayBugReportButton(AssetStoreProduct product)
 {
     if (EditorGUIX.DisplayButton(string.Format("Report a Problem with {0}", product.ToString().ToWords())))
     {
         OpenUrl(
             string.Format(
                 "mailto:{0}?subject={1} Bug Report&body=1) What happened?\n\n2) How often does it happen?\n\n" +
                 "3) How can I reproduce it using the example you attached?",
                 s_BugReportEmailAddress, product.ToString().ToWords()
                 ),
             "Error Creating Bug Report",
             "Please ensure an application is associated with email links."
             );
     }
 }
コード例 #5
0
 /// <summary>
 /// Raises the inspector GUI event.
 /// </summary>
 public override void OnInspectorGUI()
 {
     this.serializedObject.Update();
     DrawDefaultInspector();
     EditorGUI.BeginChangeCheck();
     {
         EditorGUI.BeginDisabledGroup(Selection.objects.Length > 1);
         {
             if (EditorGUIX.DisplayButton("Sort Alphabetically"))
             {
                 Undo.RecordObjects(this.targets, "Sort Alphabetically");
                 List <KeywordsGlossary.Entry> entries =
                     this.target.GetFieldValue <List <KeywordsGlossary.Entry> >("m_Entries");
                 foreach (KeywordsGlossary.Entry entry in entries)
                 {
                     (
                         entry.GetFieldValue <List <KeywordsGlossary.InflectedForm> >("m_OtherForms")
                     ).Sort((f1, f2) => f1.Word.CompareTo(f2.Word));
                 }
                 entries.Sort((e1, e2) => e1.MainForm.Word.CompareTo(e2.MainForm.Word));
                 m_Entries.list = entries;
                 EditorUtility.SetDirty(this.target);
                 this.serializedObject.Update();
             }
         }
         EditorGUI.EndDisabledGroup();
         m_Entries.DoLayoutList();
         if (m_Entries.count > 0)
         {
             EditorGUILayout.BeginVertical(EditorStylesX.Box);
             {
                 m_CurrentEntry = m_Entries.serializedProperty.GetArrayElementAtIndex(m_Entries.index);
                 m_CurrentWord  = m_CurrentEntry.FindPropertyRelative(
                     "m_MainForm"
                     ).FindPropertyRelative("m_Word").stringValue;
                 EditorGUILayout.LabelField(m_CurrentWord, EditorStylesX.BoldTitleBar);
                 EditorGUILayout.PropertyField(m_CurrentEntry.FindPropertyRelative("m_Definition"));
                 if (!m_InflectedForms.ContainsKey(m_CurrentEntry.propertyPath))
                 {
                     ReorderableList newList = new ReorderableList(
                         this.serializedObject, m_CurrentEntry.FindPropertyRelative("m_OtherForms")
                         );
                     newList.drawHeaderCallback  = (rect) => EditorGUI.LabelField(rect, "Inflected Forms");
                     newList.drawElementCallback = OnDrawInflectedForm;
                     newList.onAddCallback       = OnAddNewInflectedForm;
                     m_InflectedForms.Add(m_CurrentEntry.propertyPath, newList);
                 }
                 m_InflectedForms[m_CurrentEntry.propertyPath].DoLayoutList();
             }
             EditorGUILayout.EndVertical();
         }
     }
     if (EditorGUI.EndChangeCheck())
     {
         this.serializedObject.ApplyModifiedProperties();
         this.serializedObject.Update();
         UpdateGUIContents();
         s_RebuildKeywordsMethod.Invoke(this.target, null);
     }
     DisplayKeywordList();
 }