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
6
Question by joeltw · Sep 10, 2015 at 11:50 AM · nullreferenceexception

Upgrading to Unity 5.2 - All Image (Script) components now failing with NullReferenceException in GetStencilDepth?

I've just upgraded from 5.1 to 5.2 and now all Image (Script) components in one of my scenes are failing with a NullReferenceException in GetStencilDepth?

Anyone know how to fix this? I've tried deleting and reapplying the components, thinking the script behind might be an older version, but no joy. I've tried a few other things but can't get rid of the errors. Everything else seems to work fine but I can't get these images to display.

If anyone can shed any light on the cause or a possible fix that would be much appreciated!

alt text

capture.jpg (183.8 kB)
Comment
Add comment · Show 2
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
avatar image drolak · Sep 11, 2015 at 10:15 AM 0
Share

Same here :(

avatar image SirHamsteyr · Sep 12, 2015 at 02:28 AM 0
Share

I'm running into the same problems with my project. What used to work before is utterly broken, and this has caused me a lot of strife yesterday trying to figure it out. Good to know I'm not alone.

I hope that Unity comes out with a hotfix for this soon.

1 Reply

· Add your reply
  • Sort: 
avatar image
11
Best Answer

Answer by hacker64 · Sep 13, 2015 at 03:30 PM

We ran into the same problem with our project when upgrading to 5.2.

This error message appears to be caused by a Mask Component without a corresponding Image Component, as shown in the training video UI Mask.

As outlined in the video, while you do not have to have an actual Source Image selected, you do appear to need the Image Component, even if the Source Image is None. This isn't really clear in the text version of the docs.

Please note that the GameObject in the hierarchy that is linked to the Error message in the log may be a child of the GameObject that has the problem outlined above (as it was in our case), so you may have to look upwards in your hierarchy.

I would imagine there is some additional code now in 5.2 (in UnityEngine.UI.MaskUtilities.GetStencilDepth()) that is not checking for a null reference before using it, which can be fixed by Unity devs, but the root cause is actually our error (of not including the requisite Image Component).

Of course, adding a [RequireComponent(typeof(Image))] to the Mask Component would probably solve the issue altogether, since it seems now that one is required. ;-)

alt text


uimask.png (11.8 kB)
Comment
Add comment · Show 5 · 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
avatar image joeltw · Sep 14, 2015 at 08:40 AM 0
Share

Thanks for weighing in here. I did already experiment with adding a mask component to all gameobjects which had an Image (Script) component. It didn't seem to help anything. Are you saying that will be the cause only if there is no source image? Because all of $$anonymous$$e have source images assigned.

It does seem to me that this is a bug in the GetStencilDepth function, introduced in 5.2.

avatar image joeltw · Sep 14, 2015 at 08:43 AM 1
Share

Aha! No wait, you're quite right. I had a component further up the hierarchy that was using a mask but with no Image component. Added a blank Image component and everything fixed itself. That's a relief, I thought I'd have to reapply all of these images as sprites or something.

Nice one @hacker64. Problem solved.

avatar image Zynpo · Sep 25, 2015 at 02:20 PM 0
Share

I checked and none of my components use a mask but I get this error.

Whole project is broken as images throw this error at runtime.

Any one have any ideas how to fix it?

avatar image Griever_GF · Sep 28, 2015 at 11:11 AM 0
Share

Thanks for the help. I hope they will fix this bug in the future versions.

avatar image BCook99 · Nov 20, 2015 at 05:24 PM 0
Share

Thanks, this was exactly the problem!

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

34 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

Related Questions

Property Drawer Doesn't Show Property 1 Answer

Tanks Tutorial: Accessing TankHealth 1 Answer

Dijkstra shortest path algorithm but i am getting an error; Null reference exception: object reference not set to an instance of an object. 0 Answers

Car from Unity's standard assets giving me of null reference errors 0 Answers

Changing positions of all GameObjects in an array 0 Answers


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