Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Assets/RuntimeDebugDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ private void Awake()
{
CheckInitialized();

#if UNITY_EDITOR && UNITY_2017_4_OR_NEWER
UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
#endif
return;
}

Expand Down Expand Up @@ -422,6 +425,9 @@ private void OnDestroy()
_AlwaysBatch.Dispose();
_ZTestBatch.Dispose();

#if UNITY_EDITOR && UNITY_2017_4_OR_NEWER
UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
#endif
return;
}

Expand All @@ -433,6 +439,17 @@ private void Clear()

return;
}

#if UNITY_EDITOR && UNITY_2017_4_OR_NEWER
private void OnPlayModeStateChanged(UnityEditor.PlayModeStateChange playMode)
{
if (playMode == UnityEditor.PlayModeStateChange.ExitingPlayMode)
{
// hack to avoid 'Can't destroy Transform component' error due to parent hide flags.
transform.parent = null;
}
}
#endif
#endregion

#region Draw Lines
Expand Down