• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by swanijam · Dec 04, 2018 at 06:56 PM · cameragraphicsimage effects

Image Effect Scripts on a separate object from Camera

So I have a situation where for several reason I would like to move one camera around between scenes, rather than activating and deactivating different cameras for each scene. The main challenge with this is that each scene needs to have its own Post processing effects and image effects.

In order for image effects to work, the scripts that run code in OnRenderImage and OnPostRenderImage and other rendering events must be attached to the camera.

In order to apply the effects to the camera when it enters each new scene, I need a way for each effect scripts' render methods to coincide with the Camera's render methods. Copying each monobehaviour onto the camera is unideal, and difficult to do without writing copying code for each script, or using reflection during runtime.

BroadcastMessage would almost work, but it is only able to pass 1 argument in a message, while OnRenderImage needs 2.

Post processing volumes solve this issue for unity's post processing effect, but other image effects i do myself will need to me turned into volumetric versions and I'd prefer not to have to do that.

Is there a tidy way to apply image effect scripts to a camera on a different object?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rjuanjp98 · Jun 04, 2020 at 11:48 AM

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CustomPostProcess : MonoBehaviour
 {
     public static CustomPostProcess instance;
     void Awake()
     {
         if (instance == null)
             instance = this;
         else if (instance != this)
             Destroy(gameObject);
     }
 
 
     public delegate void RenderImageDelegate(RenderTexture src, RenderTexture dest);
     public static event RenderImageDelegate RenderImageEvent;
     public void OnRenderImage(RenderTexture src, RenderTexture dest)
     {
 
         if (RenderImageEvent != null)
             RenderImageEvent(src, dest);
 
     }
 }

@swanijam I don't know if this could fit what you need but I attached this singleton to the camera and subscribed any external post-process effect to the custom event. This way camera calls once your script and from there you call anyone out of your camera.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

169 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

having render texture problems... uncertain whether it's my system or unity 1 Answer

How does Unity handle alpha sorting? 2 Answers

Screen explodes into colors bug, "screen position outside of view frustum" 0 Answers

Trigger Camera Effect 0 Answers

Use information from two cameras in one image effect shader? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges