Ejemplo n.º 1
0
        /// <summary>Create a default pipeline container.</summary>
        private Transform CreatePipeline(CinemachineVirtualCamera copyFrom)
        {
            CinemachineComponentBase[] components = null;
            if (copyFrom != null)
            {
                copyFrom.InvalidateComponentPipeline(); // make sure it's up to date
                components = copyFrom.GetComponentPipeline();
            }

            Transform newPipeline = null;

            if (CreatePipelineOverride != null)
            {
                newPipeline = CreatePipelineOverride(this, PipelineName, components);
            }
            else
            {
                GameObject go = new GameObject(PipelineName);
                go.transform.parent = transform;
                go.AddComponent <CinemachinePipeline>();
                newPipeline = go.transform;

                // If copying, transfer the components
                if (components != null)
                {
                    foreach (Component c in components)
                    {
                        ReflectionHelpers.CopyFields(c, go.AddComponent(c.GetType()));
                    }
                }
            }
            PreviousStateIsValid = false;
            return(newPipeline);
        }