浏览代码

Merge pull request #762 from Unity-Technologies/volume-trygetchildof

Added more utility methods to VolumeProfile
/main
GitHub 7 年前
当前提交
d79cde81
共有 1 个文件被更改,包括 50 次插入0 次删除
  1. 50
      ScriptableRenderPipeline/Core/CoreRP/Volume/VolumeProfile.cs

50
ScriptableRenderPipeline/Core/CoreRP/Volume/VolumeProfile.cs


using System;
using System.Collections.Generic;
using UnityEngine.Assertions;
namespace UnityEngine.Experimental.Rendering
{

return false;
}
public bool HasSubclassOf(Type type)
{
foreach (var component in components)
{
if (component.GetType().IsSubclassOf(type))
return true;
}
return false;
}
return TryGet(type, out component);
}
public bool TryGet<T>(Type type, out T component)
where T : VolumeComponent
{
component = null;
foreach (var comp in components)

}
return false;
}
public bool TryGetSubclassOf<T>(Type type, out T component)
where T : VolumeComponent
{
component = null;
foreach (var comp in components)
{
if (comp.GetType().IsSubclassOf(type))
{
component = (T)comp;
return true;
}
}
return false;
}
public bool TryGetAllSubclassOf<T>(Type type, List<T> result)
where T : VolumeComponent
{
Assert.IsNotNull(components);
int count = result.Count;
foreach (var comp in components)
{
if (comp.GetType().IsSubclassOf(type))
result.Add((T)comp);
}
return count != result.Count;
}
}
}
正在加载...
取消
保存