浏览代码

Fixed more serialization & domain reload issues

/feature-ReflectionProbeFit
Thomas 7 年前
当前提交
5d3c6472
共有 2 个文件被更改,包括 45 次插入8 次删除
  1. 40
      ScriptableRenderPipeline/Core/Volume/VolumeManager.cs
  2. 13
      ScriptableRenderPipeline/Core/Volume/VolumeStack.cs

40
ScriptableRenderPipeline/Core/Volume/VolumeManager.cs


stack = CreateStack();
}
public VolumeStack CreateStack()
{
var stack = new VolumeStack();
stack.Reload(baseComponentTypes);
return stack;
}
m_ComponentsDefaultState.Clear();
// Grab all the component types we can find
baseComponentTypes = CoreUtils.GetAllAssemblyTypes()
.Where(t => t.IsSubclassOf(typeof(VolumeComponent)) && !t.IsAbstract);

var inst = (VolumeComponent)ScriptableObject.CreateInstance(type);
m_ComponentsDefaultState.Add(inst);
}
}
public VolumeStack CreateStack()
{
return new VolumeStack(baseComponentTypes);
}
public void Register(Volume volume, int layer)

ReloadBaseTypes();
}
[Conditional("UNITY_EDITOR")]
public void CheckStack(VolumeStack stack)
{
// The editor doesn't reload the domain when exiting play mode but still kills every
// object created while in play mode, like stacks' component states
var components = stack.components;
if (components == null)
{
stack.Reload(baseComponentTypes);
return;
}
foreach (var kvp in components)
{
if (kvp.Key == null || kvp.Value == null)
{
stack.Reload(baseComponentTypes);
return;
}
}
}
// Update the global state - should be called once per frame per transform/layer mask combo
// in the update loop before rendering
public void Update(Transform trigger, LayerMask layerMask)

// Update a specific stack - can be used to manage your own stack and store it for later use
public void Update(VolumeStack stack, Transform trigger, LayerMask layerMask)
{
Assert.IsNotNull(stack);
CheckStack(stack);
// Start by resetting the global state to default values
ReplaceData(stack, m_ComponentsDefaultState);

13
ScriptableRenderPipeline/Core/Volume/VolumeStack.cs


public sealed class VolumeStack : IDisposable
{
// Holds the state of _all_ component types you can possibly add on volumes
public readonly Dictionary<Type, VolumeComponent> components;
public Dictionary<Type, VolumeComponent> components;
internal VolumeStack()
{
}
internal VolumeStack(IEnumerable<Type> baseTypes)
internal void Reload(IEnumerable<Type> baseTypes)
components = new Dictionary<Type, VolumeComponent>();
if (components == null)
components = new Dictionary<Type, VolumeComponent>();
else
components.Clear();
foreach (var type in baseTypes)
{

正在加载...
取消
保存