public void AddPostProcess <T>(Camera camera, string matPath) where T : AbsPostProcessBase { if (string.IsNullOrWhiteSpace(matPath) || !camera) { return; } PostProcessCamera postProcessCamera = null; for (int i = 0; i < _postProcessCameraList.Count; i++) { var target = _postProcessCameraList[i]; if (target.Camera == camera) { postProcessCamera = target; break; } } if (!postProcessCamera) { postProcessCamera = camera.gameObject.AddComponent <PostProcessCamera>(); _postProcessCameraList.Add(postProcessCamera); } if (!postProcessCamera.IsContains(matPath)) { var target = Activator.CreateInstance(typeof(T), matPath) as AbsPostProcessBase; if (target != null) { postProcessCamera.AddPostProcess(target); } } }
public void InitializePostProcess(PostProcessCamera postProcessCamera) { Deprecated = false; IsActive = false; _postProcessCamera = postProcessCamera; if (!postProcessCamera.Camera || !PostProcessMgr.singleton.PostProcessResource || string.IsNullOrWhiteSpace(MatPath)) { Deprecated = true; return; } _properties = new MaterialPropertyBlock(); _commandBuffer = new CommandBuffer { name = MatPath }; _mat = PostProcessMgr.singleton.PostProcessResource.GetMaterial(MatPath); AddCommandBuffer(); BuildCommandBuffer(); }
public void InitializePostProcess(PostProcessCamera postProcessCamera) { Deprecated = false; IsActive = false; _postProcessCamera = postProcessCamera; if (!postProcessCamera.Camera || string.IsNullOrWhiteSpace(MatPath)) { Deprecated = true; return; } _materialPropertyBlock = new MaterialPropertyBlock(); _commandBuffer = new CommandBuffer { name = MatPath }; AddCommandBuffer(); var request = Resources.LoadAsync <Material>(MatPath); request.completed += (async) => { _mat = request.asset as Material; BuildCommandBuffer(); }; }