|
|
|
|
|
|
bool animateMaterials = true; |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
animateMaterials = false; |
|
|
|
animateMaterials = Application.isPlaying; |
|
|
|
if (camera.cameraType == CameraType.Game) |
|
|
|
if (camera.cameraType == CameraType.SceneView) |
|
|
|
animateMaterials = Application.isPlaying; |
|
|
|
} |
|
|
|
else if (camera.cameraType == CameraType.Preview) |
|
|
|
{ |
|
|
|
animateMaterials = false; |
|
|
|
|
|
|
|
foreach (UnityEditor.MaterialEditor med in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.MaterialEditor))) |
|
|
|
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView))) |
|
|
|
// Warning: currently, there's no way to determine whether a given camera corresponds to this MaterialEditor.
|
|
|
|
// Therefore, if at least one of the visible MaterialEditors is in Play Mode, all of them will play.
|
|
|
|
if (med.isVisible && med.RequiresConstantRepaint()) |
|
|
|
if (sv.camera == camera && sv.sceneViewState.showMaterialUpdate) |
|
|
|
{ |
|
|
|
animateMaterials = true; |
|
|
|
break; |
|
|
|
|
|
|
else |
|
|
|
else if (camera.cameraType == CameraType.Preview) |
|
|
|
animateMaterials = false; |
|
|
|
|
|
|
|
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView))) |
|
|
|
foreach (UnityEditor.MaterialEditor med in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.MaterialEditor))) |
|
|
|
if (sv.camera == camera && sv.sceneViewState.showMaterialUpdate) |
|
|
|
// Warning: currently, there's no way to determine whether a given camera corresponds to this MaterialEditor.
|
|
|
|
// Therefore, if at least one of the visible MaterialEditors is in Play Mode, all of them will play.
|
|
|
|
if (med.isVisible && med.RequiresConstantRepaint()) |
|
|
|
{ |
|
|
|
animateMaterials = true; |
|
|
|
break; |
|
|
|