コード例 #1
0
        /// <summary>
        /// Displays a button for setting all axes of motion on an array of targets.
        /// </summary>
        /// <param name="preference">Preference storing the motion type value.</param>
        /// <param name="label">Label for the control.</param>
        /// <param name="targets">An array of configurable joints.</param>
        /// <param name="applyMethod">Method to invoke if preference value is to be applied to all targets.</param>
        private void DisplayMultiJointMotionButton(
            EditorPreference <ConfigurableJointMotion, JointEditor> preference,
            GUIContent label,
            System.Action <ConfigurableJoint, ConfigurableJointMotion> applyMethod
            )
        {
            Rect controlPosition, buttonPosition;

            EditorGUIX.GetRectsForControlWithInlineButton(
                EditorGUILayout.GetControlRect(), out controlPosition, out buttonPosition, 40f, 80f
                );
            preference.CurrentValue =
                (ConfigurableJointMotion)EditorGUIX.DisplayField <System.Enum>(
                    controlPosition, label, preference.CurrentValue, EditorGUI.EnumPopup
                    );
            if (EditorGUIX.DisplayButton(buttonPosition, "Set All"))
            {
                Undo.RecordObjects(m_CachedTargets, string.Format("Set All {0} Motion", label.text));
                foreach (ConfigurableJoint j in m_CachedTargets)
                {
                    if (j == null)
                    {
                        continue;
                    }
                    applyMethod(j, preference.CurrentValue);
                }
                EditorUtilityX.SetDirty(m_CachedTargets);
            }
        }
コード例 #2
0
        /// <summary>
        /// Raises the draw custom style entry event.
        /// </summary>
        /// <param name="position">Position of the entry.</param>
        /// <param name="list">List to which the entry belongs.</param>
        /// <param name="index">Index of the entry being drawn.</param>
        /// <param name="guiContentsTable">Table of GUI contents used by the element being drawn.</param>
        /// <param name="inheritedStyles">Table of inherited styles of the element's type.</param>
        /// <param name="getStyles">Method to get styles of the element's type from a HyperTextStyles.</param>
        /// <param name="setStyles">Method to set styles of the element's type on a HyperTextStyles.</param>
        /// <typeparam name="T">A custom style type.</typeparam>
        private void OnDrawCustomStyleEntry <T>(
            Rect position,
            ReorderableList list,
            int index,
            Dictionary <int, CustomStyleGUIContent> guiContentsTable,
            Dictionary <T, HyperTextStyles> inheritedStyles,
            StylesGetter <T> getStyles,
            StylesSetter <T> setStyles
            ) where T : IIdentifiable <string>
        {
            index = Mathf.Clamp(index, 0, list.serializedProperty.arraySize);
            if (!guiContentsTable.ContainsKey(index))
            {
                return;
            }
            SerializedProperty element =             // NOTE: undoing list increase can cause GetArrayElementAtIndex() to fail
                                         list.serializedProperty.FindPropertyRelative(string.Format("Array.data[{0}]", index));

            if (element == null)
            {
                return;
            }
            if (position.height < (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 2f)
            {
                EditorGUI.LabelField(position, guiContentsTable[index].Label);
            }
            else
            {
                EditorGUI.PropertyField(position, element, guiContentsTable[index].Label);
                if (guiContentsTable[index].Status == ValidationStatus.Warning)
                {
                    Rect buttonPosition = position;
                    buttonPosition.height = EditorGUIUtility.singleLineHeight;
                    buttonPosition.y     += buttonPosition.height + EditorGUIUtility.standardVerticalSpacing;
                    buttonPosition.width  = EditorGUIUtility.labelWidth;
                    if (EditorGUIX.DisplayButton(buttonPosition, "Paste Inherited"))
                    {
                        string identifier     = element.GetValue <T>().Identifier;
                        T      inheritedStyle = inheritedStyles.Keys.Where(s => s.Identifier == identifier).FirstOrDefault();
                        Undo.RecordObjects(this.targets, "Paste HyperText Style");
                        foreach (HyperTextStyles styleSheet in this.targets)
                        {
                            List <T> styles = new List <T>();
                            getStyles(styleSheet, styles);
                            styles[index] = inheritedStyle;
                            setStyles(styleSheet, styles);
                        }
                    }
                }
            }
            DisplayStyleIdentifierValidationIcon(position, guiContentsTable[index]);
        }
コード例 #3
0
 /// <summary>
 /// Displays the bug report button.
 /// </summary>
 /// <param name='featureLabel'>Feature label.</param>
 private static void DisplayBugReportButton(GUIContent featureLabel)
 {
     if (EditorGUIX.DisplayButton(string.Format("Report a Problem with {0}", featureLabel.text)))
     {
         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, featureLabel.text
                 ),
             "Error Creating Bug Report",
             "Please ensure an application is associated with email links."
             );
     }
 }
コード例 #4
0
 /// <summary>
 /// Displays the preferences for a feature.
 /// </summary>
 /// <param name="featureLabel">Feature label.</param>
 private void DisplayPreferences(GUIContent featureLabel)
 {
     m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
     {
         foreach (MethodInfo method in s_MenuItems[featureLabel.text])
         {
             EditorGUILayout.LabelField(
                 method.DeclaringType.IsGenericType ?
                 string.Format(
                     "{0} ({1})",
                     method.DeclaringType.Name.ToWords().Range(0, -2),
                     ", ".Join(from t in method.DeclaringType.GetGenericArguments() select t.Name.ToWords())
                     ) : method.DeclaringType.Name.ToWords(),
                 EditorStyles.boldLabel
                 );
             EditorGUIX.DisplayHorizontalLine();
             EditorGUI.indentLevel += 1;
             method.Invoke(null, null);
             EditorGUI.indentLevel -= 1;
         }
     }
     EditorGUILayout.EndScrollView();
     // bug report button
     DisplayBugReportButton(featureLabel);
     // forum link button
     if (
         s_SupportForumUrls.ContainsKey(featureLabel.text) &&
         !string.IsNullOrEmpty(s_SupportForumUrls[featureLabel.text]) &&
         EditorGUIX.DisplayButton(string.Format("Get Help with {0}", featureLabel.text))
         )
     {
         OpenUrl(s_SupportForumUrls[featureLabel.text]);
     }
     // asset store page
     if (
         s_AssetStoreUrls.ContainsKey(featureLabel.text) &&
         !string.IsNullOrEmpty(s_AssetStoreUrls[featureLabel.text]) &&
         EditorGUIX.DisplayButton(string.Format("Review {0} on the Unity Asset Store", featureLabel.text))
         )
     {
         OpenUrl(s_AssetStoreUrls[featureLabel.text]);
     }
     // products page
     if (EditorGUIX.DisplayButton("More Products by Candlelight Interactive"))
     {
         OpenUrl(s_PublisherPage);
     }
 }
コード例 #5
0
        /// <summary>
        /// Raises the inspector GUI event.
        /// </summary>
        public override void OnInspectorGUI()
        {
            bool needsUpdate = false;

            this.serializedObject.Update();
            EditorGUILayout.PropertyField(m_Script);
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(m_CurrentLocale);
                EditorGUILayout.PropertyField(m_DefaultText);
            }
            if (EditorGUI.EndChangeCheck())
            {
                needsUpdate = true;
            }
            if (EditorGUIX.DisplayButton("Add 10 Most Common Languages"))
            {
                Undo.RecordObjects(this.targets, "Add 10 Most Common Languages");
                foreach (LocalizableText text in this.targets)
                {
                    text.GetLocaleOverrides(m_LocaleOverrideEntries);
                    foreach (string locale in LocalizableText.TenMostCommonLanguages)
                    {
                        if (!m_LocaleOverrideEntries.ContainsKey(locale))
                        {
                            m_LocaleOverrideEntries.Add(locale, "");
                        }
                    }
                    text.SetLocaleOverrides(m_LocaleOverrideEntries);
                }
                EditorUtilityX.SetDirty(this.targets);
                UpdateGUIContents();
            }
            if (EditorGUIX.DisplayButton("Alphabetize"))
            {
                Undo.RecordObjects(this.targets, "Alphabetize");
                foreach (LocalizableText text in this.targets)
                {
                    System.Collections.IList backingFieldValue =
                        (System.Collections.IList)s_LocaleOverridesField.GetValue(text);
                    List <IIdentifiable <string> > sortingList = backingFieldValue.Cast <IIdentifiable <string> >().ToList();
                    sortingList.Sort((x, y) => x.Identifier.ToLower().CompareTo(y.Identifier.ToLower()));
                    for (int i = 0; i < sortingList.Count; ++i)
                    {
                        backingFieldValue[i] = sortingList[i];
                    }
                    s_LocaleOverridesField.SetValue(text, backingFieldValue);
                }
                EditorUtilityX.SetDirty(this.targets);
            }
            EditorGUI.BeginChangeCheck();
            {
                EditorGUIX.DisplayListWithElementEditor(m_LocaleOverrides);
            }
            if (EditorGUI.EndChangeCheck())
            {
                needsUpdate = true;
            }
            this.serializedObject.ApplyModifiedProperties();
            if (needsUpdate)
            {
                UpdateGUIContents();
            }
        }