Search Issue Tracker
Fixed in 2018.1.X
Votes
1
Found in
2017.1.0p4
Issue ID
946988
Regression
Yes
SceneManager.sceneUnloaded gets called when interacting with objects using materials in Editor
Steps to reproduce:
1.Open attached ‘sceneunloaded.zip' Unity project
2.Enter Play mode
3.Select ‘Cube’ object in Hierarchy
4.Select any different object in Hierarchy
Expected results:
Nothing unusual happens
Actual results:
SceneManager.sceneUnloaded function is called and a Debug message is displayed in Console
Reproduced in: 2017.3.0a6, , 2017.2.0b10, 2017.1.1f1, 2017.1.0f1, 2017.1.0b2
Didn’t reproduce in: 2017.1.0b1, 2017.1.0a1, 5.6.3p2, 5.5.4p4
Regression introduced in: 2017.1.0b2
Note: The function is called twice when MeshRenderer/SpriteRenderer/etc material is changed. Updating of materials might be the cause of this issue.
Comments (5)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Assigned font's bold/font-weight styles render using Default Font's assets when Default Font has corresponding style assets defined in TMP Settings
- "Modifying the parent of a VisualElement while it’s already being modified is not allowed" error is thrown when entering text and pressing tab in the Search window
- Mesh colliders are not updating their positions of bounds correctly
- Images are missing from the "Open the sprite editor" documentation for 6.0, 6.1 and 6.2
- The previous element in the array is modified when assigning an Asset to a new element of AssetReferenceT
Arkade
Jan 25, 2018 12:45
I'm seeing this in 2017.3.0f3. It isn't completely clear which version the "hotfix" went into. Also no link to the hotfix here or in the linked thread that I could find. (sorry if I'm being blind)
JimHL
Dec 13, 2017 03:17
Edit: It's not work!, select to particle and it's still fire the bug!
JimHL
Dec 13, 2017 03:04
Hot fix by @hatsuko work like a charm! Thanks!
Peter77
Dec 07, 2017 08:05
Related forum thread:
https://forum.unity.com/threads/scenemanager-sceneunloaded-gets-called-in-editor-when-selecting-materials.491999/
Hatsuko
Dec 02, 2017 14:14
In case somebody needs it
void OnSceneUnloaded (Scene scene) {
#if UNITY_EDITOR
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
System.Diagnostics.StackFrame sf = st.GetFrame(st.FrameCount-1);
if (sf.GetMethod().Name == "OnDisable") { // Or sf.GetMethod().DeclaringType == typeof(UnityEditor.MaterialEditor)
Debug.Log("Bug!");
return;
}
#endif
Debug.Log("Do something...");
}