dotBunny / VSCode

Unity Visual Studio Code Integration
MIT License
673 stars 180 forks source link

PlayModeStateChange not found in UnityEditor namespace #162

Open mavera3 opened 6 years ago

mavera3 commented 6 years ago

I get this error when I put the VSCode.cs File into Assets/Plugins/Editor folder

Assets/Plugins/Editor/VSCode.cs(970,56): error CS0234: The type or namespace name PlayModeStateChange' does not exist in the namespaceUnityEditor'. Are you missing an assembly reference?

Unity Editor 5.6.3xf1 Linux Personal on Ubuntu 16.04 and Visual Studio Code 1.20.1

y0n3t4n1 commented 6 years ago

I'm using the following modification locally for 2017.1.3

diff --git a/Assets/Editor/VSCode.cs b/Assets/Editor/VSCode.cs
index b516da6b64..68afdb6c2b 100644
--- a/Assets/Editor/VSCode.cs
+++ b/Assets/Editor/VSCode.cs
@@ -966,7 +966,11 @@ namespace dotBunny.Unity
         /// <summary>
         /// Executed when the Editor's playmode changes allowing for capture of required data
         /// </summary>
+#if UNITY_2017_2_OR_NEWER
         static void OnPlaymodeStateChanged(UnityEditor.PlayModeStateChange state)
+#else
+        static void OnPlaymodeStateChanged()
+#endif
         {
             if (UnityEngine.Application.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
             {
@@ -980,8 +984,13 @@ namespace dotBunny.Unity
         [UnityEditor.Callbacks.DidReloadScripts()]
         static void OnScriptReload()
         {
+#if UNITY_2017_2_OR_NEWER
             EditorApplication.playModeStateChanged -= OnPlaymodeStateChanged;
             EditorApplication.playModeStateChanged += OnPlaymodeStateChanged;
+#else
+            EditorApplication.playmodeStateChanged -= OnPlaymodeStateChanged;
+            EditorApplication.playmodeStateChanged += OnPlaymodeStateChanged;
+#endif
         }

         /// <summary>
almo2001 commented 6 years ago

In Unity 2017.4.2 I'm getting

Assets/VSCode/Plugins/Editor/VSCode.cs(983,31): warning CS0618: UnityEditor.EditorApplication.playmodeStateChanged' is obsolete:Use EditorApplication.playModeStateChanged and/or EditorApplication.pauseStateChanged'

y0n3t4n1 commented 6 years ago

It's been fixed on the master branch. Maybe we need a new release?

reapazor commented 6 years ago

On the asset store? shiver

almo2001 commented 6 years ago

I was getting my unitypackage from a Github download thing that's not maintained anymore. Getting it from the asset store worked.