internal void Create(GameObject[] gameObjects)
        {
            if (!CanCreate())
            {
                return;
            }

            CreateScript();

            foreach (var go in gameObjects)
            {
                var script = AssetDatabase.LoadAssetAtPath(TargetPath(), typeof(MonoScript)) as MonoScript;
                script.SetScriptTypeWasJustCreatedFromComponentMenu();
                InternalEditorUtility.AddScriptComponentUncheckedUndoable(go, script);
            }

            AddComponentWindow.SendUsabilityAnalyticsEvent(new AddComponentWindow.AnalyticsEventData
            {
                name        = m_ClassName,
                filter      = AddComponentWindow.s_AddComponentWindow.searchString,
                isNewScript = true
            });

            AddComponentWindow.s_AddComponentWindow.Close();
        }
Exemplo n.º 2
0
        public override bool OnAction()
        {
            AddComponentWindow.SendUsabilityAnalyticsEvent(new AddComponentWindow.AnalyticsEventData
            {
                name        = name,
                filter      = AddComponentWindow.s_AddComponentWindow.searchString,
                isNewScript = false
            });

            var gos = AddComponentWindow.s_AddComponentWindow.m_GameObjects;

            EditorApplication.ExecuteMenuItemOnGameObjects(m_MenuPath, gos);
            return(true);
        }