Unity restricts scripts not binding in Editor mode

In Unity, as long as the script that inherits MonoBehavior can be hung on the gameobject, but some scripts we do not want to be bound in Editor mode, or only want some pending gameobjects to be able to bind the script.

There are two ways to add scripts in edit mode:

1: Use the mouse to drag and drop directly to the gameobject

2: Make a MenuItem yourself and then gameobject.AddCompoment<T>

#if UNITY_EDITOR
        UnityEditor.EditorUtility.DisplayDialog("cuowu", "bunengshiyong", "quedign");
#endif

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325306945&siteId=291194637