Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by terrivellmann · Mar 23, 2017 at 02:03 PM · image effectsmirrorreflection

MirrorReflection script, adding image effects

Hi! I'm using the MirrorReflection4 script from the wiki in my game. ( http://wiki.unity3d.com/index.php/MirrorReflection4 )

It works great by default. I'm using the Edge Detection image effect on my game and wanted to add it to the reflection so it properly matches what you see in the world.

The way I did it was by adding this:

 using UnityStandardAssets.ImageEffects;

and then on the script where I found this line:

 reflectionCamera.gameObject.AddComponent<FlareLayer>();

I added this right below it:

 reflectionCamera.gameObject.AddComponent<EdgeDetection>();

Now here is the part I'm stuck on: this works great in editor, but in builds I get an error and the edge detection doesn't happen:

 NullReferenceException: Object reference not set to an instance of an object

This is the full error on the log:

 Missing shader in Mirror Refl Camera id24260 for 16178 (UnityStandardAssets.ImageEffects.EdgeDetection)
 UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
 UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
 UnityEngine.Logger:Log(LogType, Object)
 UnityEngine.Debug:Log(Object)
 UnityStandardAssets.ImageEffects.PostEffectsBase:CheckShaderAndCreateMaterial(Shader, Material) (at D:\Unity\GAME\Assets\Standard Assets\Effects\ImageEffects\Scripts\PostEffectsBase.cs:21)
 UnityStandardAssets.ImageEffects.EdgeDetection:CheckResources() (at D:\Unity\GAME\Assets\Standard Assets\Effects\ImageEffects\Scripts\EdgeDetection.cs:39)
 UnityStandardAssets.ImageEffects.EdgeDetection:OnRenderImage(RenderTexture, RenderTexture) (at D:\Unity\GAME\Assets\Standard Assets\Effects\ImageEffects\Scripts\EdgeDetection.cs:72)
 UnityEngine.Camera:Render()
 MirrorReflection:OnWillRenderObject() (at D:\Unity\GAME\Assets\_ASSETS\mirror\MirrorReflection.cs:86)
  
 (Filename: D:/Unity/GAME/Assets/Standard Assets/Effects/ImageEffects/Scripts/PostEffectsBase.cs Line: 21)
 
 NullReferenceException: Object reference not set to an instance of an object
   at UnityStandardAssets.ImageEffects.EdgeDetection.OnRenderImage (UnityEngine.RenderTexture source, UnityEngine.RenderTexture destination) [0x00056] in D:\Unity\GAME\Assets\Standard Assets\Effects\ImageEffects\Scripts\EdgeDetection.cs:79 
 UnityEngine.Camera:Render()
 MirrorReflection:OnWillRenderObject() (at D:\Unity\GAME\Assets\_ASSETS\mirror\MirrorReflection.cs:86)
  
 (Filename: D:/Unity/GAME/Assets/Standard Assets/Effects/ImageEffects/Scripts/EdgeDetection.cs Line: 79)

Any ideas how to fix it, and why it works in editor but not in build? Thanks in advance!

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
Best Answer

Answer by terrivellmann · Mar 23, 2017 at 03:07 PM

So I figured it out, thanks to help I got on twitter, this is what fixed it: instead of just

 reflectionCamera.gameObject.AddComponent<EdgeDetection>();

I added

 reflectionCamera.gameObject.AddComponent<EdgeDetection>();
 EdgeDetection edgedetection = reflectionCamera.gameObject.GetComponent(typeof(EdgeDetection) ) as EdgeDetection;
 edgedetection.edgeDetectShader = Shader.Find("Hidden/EdgeDetect");

So I guess the effect was being added without a shader attached.

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.

Follow this Question

Answers Answers and Comments

96 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

Related Questions

Image Effects keep on rendering 0 Answers

system time image effects 0 Answers

Shiny surface shows wrong side reflection of non static character 0 Answers

CRT Shader how optimize?! 1 Answer

Fairly new to programming; Need ideas on how to do this script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges