1
\$\begingroup\$

I want to hide the "editor Script" in the Unity Inspector, so it doesnt show up with all the other components (transform/other scripts etc.) It works with every other "normal" component like this:

component.hideFlags = HideFlags.HideInInspector;

but when it comes to the Editor Script- it just doesnt hide.

EDIT: My Custom Editor Script:

using UnityEngine;
using System.Collections;
using UnityEditor;

[ExecuteInEditMode]
[CustomEditor(typeof(DetailCamContScript))]


public class CamEditor : Editor
{

    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        DetailCamContScript myScript = (DetailCamContScript)target;
        if (GUILayout.Button("Set Camera Active"))
        {

            myScript.setCamActive();

        }


    }

}

EDIT: Problem solved.

the problem was: The editor-script was attached to a Gameobject. It doesnt needs to be attached.

\$\endgroup\$
6
  • \$\begingroup\$ Pretty sure you cannot hide components in the inspector. \$\endgroup\$
    – jgallant
    Jul 26 '16 at 10:41
  • \$\begingroup\$ well... you can. With: component.hideFlags = HideFlags.HideInInspector; \$\endgroup\$
    – OC_RaizW
    Jul 26 '16 at 10:49
  • \$\begingroup\$ OK Sorry I misread at first -- so basically editor scripts are not hiding -- i will try. \$\endgroup\$
    – jgallant
    Jul 26 '16 at 10:51
  • \$\begingroup\$ I think I'm missing something here. The whole function of a custom editor script with an OnInspectorGUI method is to draw inspector controls. If you don't want to see inspector controls (including this "Set Camera Active" button, then what is this editor script accomplishing for you? I can't see any actions in the script you've shown that don't depend on seeing a visible control. \$\endgroup\$
    – DMGregory
    Jul 26 '16 at 11:56
  • \$\begingroup\$ bilder-upload.eu/upload/b48025-1469534761.png \$\endgroup\$
    – OC_RaizW
    Jul 26 '16 at 12:02
2
\$\begingroup\$

I may be misunderstanding, but an editor script doesn't need to be attached to anything. If it's not attached, there's no place for it to show up. If the editor script is in an Editor folder, it places itself in the UI without being part of a game object.

\$\endgroup\$
1
\$\begingroup\$

You don't need to attach the custom editors as components. You can leave them in assets folder without attaching them to a gameobject.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Downvoter leave a comment please. \$\endgroup\$ Jul 26 '16 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.