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 /
This question was closed Jun 13, 2016 at 02:04 AM by hardmode2236 for the following reason:

Too subjective and argumentative

avatar image
-2
Question by hardmode2236 · Jun 10, 2016 at 03:10 AM · objectinspectorruntimenullhighlight

object can't be null when highlighted in the inspector?

Long story short: I have an inventory system that works fine, until I highlight one of the slots in the inspector during run-time, thus, exposing the 'item' object in the inspector. My code checks for, and denies, any interaction with null items in empty slots, but it seems that when I'm looking at an object in the inspector its not null anymore, its just blank. suddenly that slot that I'm looking at in the inspector can infinitely spawn 'blank' objects, even though its supposed to be null.... is this really whats happening? I even put a Debug.Log in the constructor and it runs when i first look at the item in the inspector during run-time.

side note: I'm not looking to paste my code in and have someone go over it. I really just want to know if there's some funny business going on when an object is highlighted in the inspector.

Comment
Add comment · Show 4
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 HarshadK · Jun 10, 2016 at 05:50 AM 1
Share

Actually you should post your code otherwise it just becomes a guessing game for everyone.

avatar image hardmode2236 HarshadK · Jun 12, 2016 at 04:53 PM 0
Share

this question really has nothing to do with my code, at all. this question is completly based on the mechanics of unity itself. i just wanted to know why an object gets instantiated when it gets exposed in the inspector during run-time.

avatar image tanoshimi hardmode2236 · Jun 12, 2016 at 07:32 PM 1
Share

It really has got everything to do with your code. As far as I'm aware, nobody has ever reported Unity behaviour where highlighting an object in the inspector infinitely spawns "blank" objects. I'm not even sure what a blank object is. You're sure your code doesn't call Instantiate() at any point....?

Show more comments

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by hardmode2236 · Jun 13, 2016 at 02:02 AM

i'm just gonna go ahead and close this, i failed to explain my real question well enough and everyone is just gonna down-vote my ass into the dirt for trying to not involve my code, when all i wanted to know was if highlighting objects in the inspector could run some functions of the object for some reason.

It seems when my object was null, and i highlighted it in the inspector (in run-time) the constructor was called for some reason and the object became not null anymore. this is the root of my issue, and is the answer to my question.

Comment
Add comment · Show 3 · 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 Owen-Reynolds · Jun 13, 2016 at 02:59 AM 1
Share

The usual trick, when you have complicated/NDA'd/etc code, is to try to isolate the problem with a simplified example. (a serialized 1-item class, in an array (or not?)) If that acts funny, posting that code can often save a lot of typing.

But that sounds about right. Of course, Unity automatically new's anything visible in the Inspector. I'm a little surprised it happens while running, but I guess there's no real reason to click on a null item, anyway. So sort of a bug, but not a serious one.

avatar image hardmode2236 Owen-Reynolds · Jun 13, 2016 at 06:09 AM 0
Share

i see, thanks for the clarification.

avatar image oferei · Sep 12, 2016 at 12:36 PM 0
Share

Yup, happened to me too and drove me crazy for a while. I want to add that Unity doesn't necessarily call the constructor!

If, for example, the public variable (that is visible to the inspector) refers to a class that only has a constructor with parameters (no parameterless constructor) then Unity may allocate memory for you without calling any constructor. The public variable will refer to an instance that has not been initialized.

Follow this Question

Answers Answers and Comments

48 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

Related Questions

Custom Display for system.object Editor 1 Answer

Destroyed Object Error 2 Answers

MissingReferenceException Help 1 Answer

Object Pool object reference is null? 1 Answer

NullReferenceException: Object reference not set to an instance of an object 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