Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

it says no suitable method found to override in the compile errors. how do i fix this?

Discussion in 'Documentation' started by heyhowareudoing, Jul 24, 2020.

  1. heyhowareudoing

    heyhowareudoing

    Joined:
    Jul 21, 2020
    Posts:
    1
    help me fix this! this is the code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEditor;
    4. using UnityEditor.UI;
    5. using UnityEditor.AnimatedValues;
    6.  
    7.  
    8. namespace TMPro.EditorUtilities
    9. {
    10.     [CanEditMultipleObjects]
    11.     [CustomEditor(typeof(TMP_InputField), true)]
    12.     public class TMP_InputFieldEditor : SelectableEditor
    13.     {
    14.         private struct m_foldout
    15.         { // Track Inspector foldout panel states, globally.
    16.             public static bool textInput = true;
    17.             public static bool fontSettings = true;
    18.             public static bool extraSettings = true;
    19.             //public static bool shadowSetting = false;
    20.             //public static bool materialEditor = true;
    21.         }
    22.  
    23.         SerializedProperty m_TextViewport;
    24.         SerializedProperty m_TextComponent;
    25.         SerializedProperty m_Text;
    26.         SerializedProperty m_ContentType;
    27.         SerializedProperty m_LineType;
    28.         SerializedProperty m_LineLimit;
    29.         SerializedProperty m_InputType;
    30.         SerializedProperty m_CharacterValidation;
    31.         SerializedProperty m_InputValidator;
    32.         SerializedProperty m_RegexValue;
    33.         SerializedProperty m_KeyboardType;
    34.         SerializedProperty m_CharacterLimit;
    35.         SerializedProperty m_CaretBlinkRate;
    36.         SerializedProperty m_CaretWidth;
    37.         SerializedProperty m_CaretColor;
    38.         SerializedProperty m_CustomCaretColor;
    39.         SerializedProperty m_SelectionColor;
    40.         SerializedProperty m_HideMobileKeyboard;
    41.         SerializedProperty m_HideMobileInput;
    42.         SerializedProperty m_Placeholder;
    43.         SerializedProperty m_VerticalScrollbar;
    44.         SerializedProperty m_ScrollbarScrollSensitivity;
    45.         SerializedProperty m_OnValueChanged;
    46.         SerializedProperty m_OnEndEdit;
    47.         SerializedProperty m_OnSelect;
    48.         SerializedProperty m_OnDeselect;
    49.         SerializedProperty m_ReadOnly;
    50.         SerializedProperty m_RichText;
    51.         SerializedProperty m_RichTextEditingAllowed;
    52.         SerializedProperty m_ResetOnDeActivation;
    53.         SerializedProperty m_RestoreOriginalTextOnEscape;
    54.  
    55.         SerializedProperty m_OnFocusSelectAll;
    56.         SerializedProperty m_GlobalPointSize;
    57.         SerializedProperty m_GlobalFontAsset;
    58.  
    59.         AnimBool m_CustomColor;
    60.  
    61.         //TMP_InputValidator m_ValidationScript;
    62.  
    63.         protected override void OnEnable()
    64.         {
    65.             base.OnEnable();
    66.  
    67.             m_TextViewport = serializedObject.FindProperty("m_TextViewport");
    68.             m_TextComponent = serializedObject.FindProperty("m_TextComponent");
    69.             m_Text = serializedObject.FindProperty("m_Text");
    70.             m_ContentType = serializedObject.FindProperty("m_ContentType");
    71.             m_LineType = serializedObject.FindProperty("m_LineType");
    72.             m_LineLimit = serializedObject.FindProperty("m_LineLimit");
    73.             m_InputType = serializedObject.FindProperty("m_InputType");
    74.             m_CharacterValidation = serializedObject.FindProperty("m_CharacterValidation");
    75.             m_InputValidator = serializedObject.FindProperty("m_InputValidator");
    76.             m_RegexValue = serializedObject.FindProperty("m_RegexValue");
    77.             m_KeyboardType = serializedObject.FindProperty("m_KeyboardType");
    78.             m_CharacterLimit = serializedObject.FindProperty("m_CharacterLimit");
    79.             m_CaretBlinkRate = serializedObject.FindProperty("m_CaretBlinkRate");
    80.             m_CaretWidth = serializedObject.FindProperty("m_CaretWidth");
    81.             m_CaretColor = serializedObject.FindProperty("m_CaretColor");
    82.             m_CustomCaretColor = serializedObject.FindProperty("m_CustomCaretColor");
    83.             m_SelectionColor = serializedObject.FindProperty("m_SelectionColor");
    84.  
    85.             m_HideMobileKeyboard = serializedObject.FindProperty("m_HideSoftKeyboard");
    86.             m_HideMobileInput = serializedObject.FindProperty("m_HideMobileInput");
    87.  
    88.             m_Placeholder = serializedObject.FindProperty("m_Placeholder");
    89.             m_VerticalScrollbar = serializedObject.FindProperty("m_VerticalScrollbar");
    90.             m_ScrollbarScrollSensitivity = serializedObject.FindProperty("m_ScrollSensitivity");
    91.  
    92.             m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
    93.             m_OnEndEdit = serializedObject.FindProperty("m_OnEndEdit");
    94.             m_OnSelect = serializedObject.FindProperty("m_OnSelect");
    95.             m_OnDeselect = serializedObject.FindProperty("m_OnDeselect");
    96.             m_ReadOnly = serializedObject.FindProperty("m_ReadOnly");
    97.             m_RichText = serializedObject.FindProperty("m_RichText");
    98.             m_RichTextEditingAllowed = serializedObject.FindProperty("m_isRichTextEditingAllowed");
    99.             m_ResetOnDeActivation = serializedObject.FindProperty("m_ResetOnDeActivation");
    100.             m_RestoreOriginalTextOnEscape = serializedObject.FindProperty("m_RestoreOriginalTextOnEscape");
    101.  
    102.             m_OnFocusSelectAll = serializedObject.FindProperty("m_OnFocusSelectAll");
    103.             m_GlobalPointSize = serializedObject.FindProperty("m_GlobalPointSize");
    104.             m_GlobalFontAsset = serializedObject.FindProperty("m_GlobalFontAsset");
    105.  
    106.             m_CustomColor = new AnimBool(m_CustomCaretColor.boolValue);
    107.             m_CustomColor.valueChanged.AddListener(Repaint);
    108.         }
    109.  
    110.         protected override void OnDisable()
    111.         {
    112.             base.OnDisable();
    113.             m_CustomColor.valueChanged.RemoveListener(Repaint);
    114.         }
    115.  
    116.         public override void OnInspectorGUI()
    117.         {
    118.             serializedObject.Update();
    119.  
    120.             base.OnInspectorGUI();
    121.  
    122.             EditorGUILayout.Space();
    123.  
    124.             EditorGUILayout.PropertyField(m_TextViewport);
    125.  
    126.             EditorGUILayout.PropertyField(m_TextComponent);
    127.  
    128.             TextMeshProUGUI text = null;
    129.             if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null)
    130.             {
    131.                 text = m_TextComponent.objectReferenceValue as TextMeshProUGUI;
    132.                 //if (text.supportRichText)
    133.                 //{
    134.                 //    EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning);
    135.                 //}
    136.             }
    137.  
    138.             EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null);
    139.  
    140.             // TEXT INPUT BOX
    141.             EditorGUILayout.PropertyField(m_Text);
    142.  
    143.             // INPUT FIELD SETTINGS
    144.             #region INPUT FIELD SETTINGS
    145.  
    146.             m_foldout.fontSettings = EditorGUILayout.Foldout(m_foldout.fontSettings, "Input Field Settings", true, TMP_UIStyleManager.boldFoldout);
    147.  
    148.             if (m_foldout.fontSettings)
    149.             {
    150.                 EditorGUI.indentLevel++;
    151.                 EditorGUI.BeginChangeCheck();
    152.                 EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object."));
    153.                 if (EditorGUI.EndChangeCheck())
    154.                 {
    155.                     TMP_InputField inputField = target as TMP_InputField;
    156.                     inputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as TMP_FontAsset);
    157.                 }
    158.  
    159.  
    160.                 EditorGUI.BeginChangeCheck();
    161.                 EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object."));
    162.                 if (EditorGUI.EndChangeCheck())
    163.                 {
    164.                     TMP_InputField inputField = target as TMP_InputField;
    165.                     inputField.SetGlobalPointSize(m_GlobalPointSize.floatValue);
    166.                 }
    167.  
    168.                 EditorGUI.BeginChangeCheck();
    169.                 EditorGUILayout.PropertyField(m_CharacterLimit);
    170.  
    171.                 EditorGUILayout.Space();
    172.  
    173.                 EditorGUILayout.PropertyField(m_ContentType);
    174.                 if (!m_ContentType.hasMultipleDifferentValues)
    175.                 {
    176.                     EditorGUI.indentLevel++;
    177.  
    178.                     if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard ||
    179.                         m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected ||
    180.                         m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom)
    181.                     {
    182.                         EditorGUI.BeginChangeCheck();
    183.                         EditorGUILayout.PropertyField(m_LineType);
    184.                         if (EditorGUI.EndChangeCheck())
    185.                         {
    186.                             if (text != null)
    187.                             {
    188.                                 if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine)
    189.                                     text.enableWordWrapping = false;
    190.                                 else
    191.                                 {
    192.                                     text.enableWordWrapping = true;
    193.                                 }
    194.                             }
    195.                         }
    196.  
    197.                         if (m_LineType.enumValueIndex != (int)TMP_InputField.LineType.SingleLine)
    198.                         {
    199.                             EditorGUILayout.PropertyField(m_LineLimit);
    200.                         }
    201.                     }
    202.  
    203.                     if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom)
    204.                     {
    205.                         EditorGUILayout.PropertyField(m_InputType);
    206.                         EditorGUILayout.PropertyField(m_KeyboardType);
    207.                         EditorGUILayout.PropertyField(m_CharacterValidation);
    208.                         if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.Regex)
    209.                         {
    210.                             EditorGUILayout.PropertyField(m_RegexValue);
    211.                         }
    212.                         else if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.CustomValidator)
    213.                         {
    214.                             EditorGUILayout.PropertyField(m_InputValidator);
    215.                         }
    216.                     }
    217.  
    218.                     EditorGUI.indentLevel--;
    219.                 }
    220.  
    221.                 EditorGUILayout.Space();
    222.  
    223.                 EditorGUILayout.PropertyField(m_Placeholder);
    224.                 EditorGUILayout.PropertyField(m_VerticalScrollbar);
    225.  
    226.                 if (m_VerticalScrollbar.objectReferenceValue != null)
    227.                     EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity);
    228.  
    229.                 EditorGUILayout.PropertyField(m_CaretBlinkRate);
    230.                 EditorGUILayout.PropertyField(m_CaretWidth);
    231.  
    232.                 EditorGUILayout.PropertyField(m_CustomCaretColor);
    233.  
    234.                 m_CustomColor.target = m_CustomCaretColor.boolValue;
    235.  
    236.                 if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded))
    237.                 {
    238.                     EditorGUILayout.PropertyField(m_CaretColor);
    239.                 }
    240.                 EditorGUILayout.EndFadeGroup();
    241.  
    242.                 EditorGUILayout.PropertyField(m_SelectionColor);
    243.                
    244.                 EditorGUI.indentLevel--;
    245.             }
    246.             #endregion
    247.  
    248.  
    249.             // CONTROL SETTINGS
    250.             #region CONTROL SETTINGS
    251.             m_foldout.extraSettings = EditorGUILayout.Foldout(m_foldout.extraSettings, "Control Settings", true, TMP_UIStyleManager.boldFoldout);
    252.  
    253.             if (m_foldout.extraSettings)
    254.             {
    255.                 EditorGUI.indentLevel++;
    256.  
    257.                 EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected."));
    258.                 EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On DeActivation", "Should the Text and Caret position be reset when Input Field is DeActivated."));
    259.                 EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC."));
    260.                 EditorGUILayout.PropertyField(m_HideMobileKeyboard, new GUIContent("Hide Soft Keyboard", "Controls the visibility of the mobile virtual keyboard."));
    261.                 EditorGUILayout.PropertyField(m_HideMobileInput, new GUIContent("Hide Mobile Input", "Controls the visibility of the editable text field above the mobile virtual keyboard. Not supported on all mobile platforms."));
    262.                 EditorGUILayout.PropertyField(m_ReadOnly);
    263.                 EditorGUILayout.PropertyField(m_RichText);
    264.                 EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing"));
    265.                
    266.                 EditorGUI.indentLevel--;
    267.             }
    268.             #endregion
    269.  
    270.  
    271.             EditorGUILayout.Space();
    272.  
    273.             EditorGUILayout.PropertyField(m_OnValueChanged);
    274.             EditorGUILayout.PropertyField(m_OnEndEdit);
    275.             EditorGUILayout.PropertyField(m_OnSelect);
    276.             EditorGUILayout.PropertyField(m_OnDeselect);
    277.  
    278.             EditorGUI.EndDisabledGroup();
    279.  
    280.             serializedObject.ApplyModifiedProperties();
    281.         }
    282.     }
    283. }
    284.  
     
unityunity