Skip to main content
Support
Search our knowledge base

How to stop automatic assembly compilation from script

Comments

2 comments

  • dirk

    This worked perfectly. Much appreciated.

    0
  • Morte

    FYI, since Unity 2017.2, these warnings for lines 21, 33 make the above editor script ineffective as-is:

    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): warning CS0618: `UnityEditor.EditorApplication.playmodeStateChanged' is obsolete: `Use EditorApplication.playModeStateChanged and/or EditorApplication.pauseStateChanged'

    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): warning CS0618: `UnityEditor.EditorApplication.playmodeStateChanged' is obsolete: `Use EditorApplication.playModeStateChanged and/or EditorApplication.pauseStateChanged'


    Per suggestion, fixing the capitalisation from

    playmodeStateChanged

    to

    playModeStateChanged

    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/EditorApplication-playModeStateChanged.html

     
    gets a different new error:
    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): error CS0123: A method or delegate `CompilerOptionsEditorScript.PlaymodeChanged()' parameters do not match delegate `System.Action<UnityEditor.PlayModeStateChange>(UnityEditor.PlayModeStateChange)' parameters

    which appears related to the issue noted here:

    https://github.com/dotBunny/VSCode/issues/162

    and as some current doc illustrates,

    https://docs.unity3d.com/ScriptReference/EditorApplication-playModeStateChanged.html

    The new function takes one parameter, so the delegate method in the above editor script needs to be updated with a valid matching parameter, e.g.
        static void PlaymodeChanged(PlayModeStateChange state)

    however the delegate method does not currently do anything with that state variable, and in some circumstances the following line:
    if( EditorApplication.isPlaying )
    can be replaced with something like:
    if (state==PlayModeStateChange.EnteredPlayMode)
    but it will probably work as-is.

    Refer to the doc on the exact meaning of those state enumerations:
    https://docs.unity3d.com/ScriptReference/PlayModeStateChange.html

    The old function name will work up to and including 2017.1
    https://docs.unity3d.com/2017.1/Documentation/ScriptReference/EditorApplication-playmodeStateChanged.html

    0

Please sign in to leave a comment.