您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

51 行
1.3 KiB

using System;
using System.Collections.Generic;
namespace UnityEngine.Experimental.Rendering
{
public sealed class VolumeStack : IDisposable
{
// Holds the state of _all_ component types you can possibly add on volumes
public Dictionary<Type, VolumeComponent> components;
internal VolumeStack()
{
}
internal void Reload(IEnumerable<Type> baseTypes)
{
if (components == null)
components = new Dictionary<Type, VolumeComponent>();
else
components.Clear();
foreach (var type in baseTypes)
{
var inst = (VolumeComponent)ScriptableObject.CreateInstance(type);
components.Add(type, inst);
}
}
public T GetComponent<T>()
where T : VolumeComponent
{
var comp = GetComponent(typeof(T));
return (T)comp;
}
public VolumeComponent GetComponent(Type type)
{
VolumeComponent comp;
components.TryGetValue(type, out comp);
return comp;
}
public void Dispose()
{
foreach (var component in components)
CoreUtils.Destroy(component.Value);
components.Clear();
}
}
}