2
[CanEditMultipleObjects()]
[CustomEditor(typeof(UnityEngine.UI.Text), true)]
public class CameraExtension : UnityEditor.UI.TextEditor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        if (GUILayout.Button("New Button!"))
        {

        }
    }
}

I want to extend UI Text inspector in Unity3D. I tried it on the Camera component and it works fine, but it doesn't work on UI Text.

Tamás Deme
  • 2,194
  • 2
  • 13
  • 31
user2735005
  • 89
  • 2
  • 10
  • Try creating a class for the custom Text you want, then create another class for the editor extension. See accepted answer here: http://stackoverflow.com/questions/29052183/extending-unity-ui-components-with-custom-inspector – user3071284 Sep 24 '15 at 14:07
  • I know I can do it like this, but I need to add this script on each gameobject which I need to use. I want to modify the original component, then every exist component has my function. – user2735005 Sep 25 '15 at 01:29

1 Answers1

3

No, currently it's not possible to extend UnityEngine.UI.Text inspector (or any other inspector for components from UnityEngine.UI namespace).

The problem is due to assemblies getting loaded in this order:

  1. UnityEngine/UnityEditor
  2. User Assemblies
  3. Modules (UnityEngine.UI is here)

Assemblies that get loaded later take over custom editors defined in previous assemblies, that's why you won't see your custom editor working.

JoRouss
  • 2,864
  • 2
  • 22
  • 40