浏览代码

Factor out CoreUtils.AreAnimatedMaterialsEnabled()

/main
Evgenii Golubev 7 年前
当前提交
2bffbe72
共有 2 个文件被更改,包括 44 次插入22 次删除
  1. 43
      ScriptableRenderPipeline/Core/CoreRP/Utilities/CoreUtils.cs
  2. 23
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

43
ScriptableRenderPipeline/Core/CoreRP/Utilities/CoreUtils.cs


mesh.triangles = triangles;
return mesh;
}
// Returns 'true' if "Animated Materials" are enabled for the view associated with the given camera.
public static bool AreAnimatedMaterialsEnabled(Camera camera)
{
bool animateMaterials = true;
#if UNITY_EDITOR
animateMaterials = false;
if (camera.cameraType == CameraType.Game)
{
animateMaterials = Application.isPlaying;
}
else if (camera.cameraType == CameraType.Preview)
{
// Determine whether the "Animated Materials" checkbox is checked for the current view.
foreach (UnityEditor.MaterialEditor med in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.MaterialEditor)))
{
// 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;
}
}
}
else
{
// Determine whether the "Animated Materials" checkbox is checked for the current view.
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView)))
{
if (sv.camera == camera && sv.sceneViewState.showMaterialUpdate)
{
animateMaterials = true;
break;
}
}
}
#endif
return animateMaterials;
}
}
}

23
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


{
using (new ProfilingSample(cmd, "Push Global Parameters", CustomSamplerId.PushGlobalParameters.GetSampler()))
{
bool animateMaterials = true;
#if UNITY_EDITOR
if (hdCamera.camera.cameraType == CameraType.Game)
{
animateMaterials = Application.isPlaying;
}
else
{
animateMaterials = false;
// Determine whether the "Animated Materials" checkbox of the current view is checked.
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView)))
{
if (sv.camera == hdCamera.camera && sv.sceneViewState.showMaterialUpdate)
{
animateMaterials = true;
break;
}
}
}
#endif
bool animateMaterials = CoreUtils.AreAnimatedMaterialsEnabled(hdCamera.camera);
// Do not use 'Time.timeSinceLevelLoad' - it ticks in the Scene View for a fraction of a second
// after you select an object even if the "Animated Materials" option is disabled.

正在加载...
取消
保存