Now if the studio is open, and in Unity3d we create a file ( Create -> C# Script ), then the studio wants to choose one of the actions: Reload/ReloadAll/Ignore/IgnoreAll

enter image description here

Is it possible to somehow tweak something somewhere, so that the file is connected to the project automatically, without confirmation, without being confirmed, like ReloadAll , for example, and did not get its window into which you have to constantly poke?

Similarly, when deleting a file from Unity.

    1 answer 1

    At the moment, the developer from VS Tools for Unity admitted that this is the most requested request from developers. But it turned out to be surprisingly not trivial for them and they are working on it.

    However, at the moment, there is a script that you can use. It was taken from here and from the Russian community thanks to the user DbIMok

    FileModDialogCloser.cs should be created in the Editor folder and the code below should be FileModDialogCloser.cs into it.

     using System; using System.Runtime.InteropServices; using UnityEditor; [InitializeOnLoad] public class FileModDialogCloser { [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo); const string search = "File Modification Detected"; static IntPtr hwnd; static void Check() { hwnd = FindWindowByCaption(IntPtr.Zero, search); if ((int)hwnd != 0) { ShowWindow(hwnd, 5); keybd_event(0x0D, 0, 0, 0); } } static FileModDialogCloser() { EditorApplication.update += Check; } } 

    We are surprised! It works both when creating a C # script and when deleting it.

    As you can see, the code has the string keybd_event(0x0D, 0, 0, 0); . This is an imitation of pressing the Enter key, which means at the moment it is a Reload implementation. For ReloadAll you need to do this:

     keybd_event(0x09, 0, 0, 0); keybd_event(0x0D, 0, 0, 0); 

    This is pressing Tab and then Enter.

    A small drawback: The window appears and fulfills the event. The window is hiding. It all the same happens quickly and you don’t need to press anything yourself. But in another way, this problem cannot be solved yet.


    ADDITIONALLY:

    You can create files for a Unity project directly from Visual Studio . Unity will automatically pick them up and no windows will appear.

    1 way (simple) :

    When using Visual Studio Tools for Unity , this tool (as I understand it) already integrates two templates into the studio for creating a C # script. Therefore, by clicking on Solution PKM and selecting Add -> NewItem , then you can already see two ready-made templates:

    enter image description here

    enter image description here

    However, the template may contain unnecessary information for you, for example, comments // Use this for initialization , // Update is called once per frame , etc., so you can create any template for yourself:

    2 way :

    • Create a file from anywhere.

    enter image description here

    • Add what you want and delete the excess, like this:

    enter image description here

    • Click File -> ExportTemplate

      enter image description here

    • Select ItemTemlate

    enter image description here

    • In the list we mark our template.

    enter image description here

    • Click Next again
    • Choose a name for the Template and its description and click Finish

    enter image description here

    • The template will appear in the c:\Users\YOUR_PROFILE\Documents\Visual Studio 2015\My Exported Templates\ folder, as well as in c:\Users\YOUR_PROFILE\Documents\Visual Studio 2015\Templates\ItemTemplates\ . After rebooting the studio, you will see this template in the list as well as templates from VS Tools for Unity :

    enter image description here

    Here is a link to the video for more understanding.


    Happy End!