|
|
|
|
|
|
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); |
|
|
|