Exemple #1
0
        static void CheckForAutoOpen()
        {
            double timeInSeconds            = (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
            int    unityLaunchTimeInSeconds = (int)(timeInSeconds - EditorApplication.timeSinceStartup);
            int    prevUnityLaunchTime      = EditorPrefs.GetInt("VSCode_UnityLaunchTime", 0);

            if (unityLaunchTimeInSeconds > prevUnityLaunchTime)
            {
                VSCode.MenuOpenProject();
                EditorPrefs.SetInt("VSCode_UnityLaunchTime", unityLaunchTimeInSeconds);
            }
        }
Exemple #2
0
        /// <summary>
        /// Checks whether it should auto-open VSCode
        /// </summary>
        /// <remarks>
        /// VSCode() gets called on Launch and Run, through IntializeOnLoad
        /// https://docs.unity3d.com/ScriptReference/InitializeOnLoadAttribute.html
        /// To make sure it only opens VSCode when Unity (re)launches (i.e. opens a project),
        /// we compare the launch time, which we calculate using EditorApplication.timeSinceStartup.
        /// </remarks>
        static void CheckForAutoOpen()
        {
            double timeInSeconds            = (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
            int    unityLaunchTimeInSeconds = (int)(timeInSeconds - EditorApplication.timeSinceStartup);
            int    prevUnityLaunchTime      = EditorPrefs.GetInt("VSCode_UnityLaunchTime", 0);

            // If launch time has changed, then Unity was re-opened
            if (unityLaunchTimeInSeconds > prevUnityLaunchTime)
            {
                // Launch VSCode
                VSCode.MenuOpenProject();
                // Save new launch time
                EditorPrefs.SetInt("VSCode_UnityLaunchTime", unityLaunchTimeInSeconds);
            }
        }
Exemple #3
0
        /// <summary>
        /// Integration Constructor
        /// </summary>
        static VSCode()
        {
            if (Enabled)
            {
                UpdateUnityPreferences(true);
                UpdateLaunchFile();

                // Add Update Check
                DateTime targetDate = LastUpdate.AddDays(UpdateTime);
                if (DateTime.Now >= targetDate && AutomaticUpdates)
                {
                    CheckForUpdate();
                }

                // Open VS Code automatically when project is loaded
                if (AutoOpenEnabled)
                {
                    VSCode.MenuOpenProject();
                }
            }

            // Event for when script is reloaded
            System.AppDomain.CurrentDomain.DomainUnload += System_AppDomain_CurrentDomain_DomainUnload;
        }
Exemple #4
0
 /// <summary>
 /// On documented, project generation event callback
 /// </summary>
 private static void OnGeneratedCSProjectFiles()
 {
     // Force execution of VSCode update
     VSCode.UpdateSolution();
 }
Exemple #5
0
 private static void OnGeneratedCSProjectFiles()
 {
     VSCode.UpdateSolution();
 }