Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
4
Question by Jean-Fabre · Nov 22, 2010 at 06:09 AM · inspectoreditor-scriptingreferencemissingnone

missing (transform) vs none: how to code this or query for it?

Hi,

In the inspector, the drop down field used to reference transform or game object knows the difference between "none" and "missing",

that is if I delete a reference that was hooked to a public var in a script, the inspector fields shows "missing (transform)". This is very good, but I need to catch this now within my code to act upon this. I have scripted something that works, but it's really, really hacky and involves scanning all transforms... not very nice, hopefully there is a better way.

I wonder how this is coded and if the api ( editor or general) expose a function or flag for this, I failed to find anything on that matter in the help.

Thanks for your help,

Bye,

Jean

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
1

Answer by TheDemiurge · Nov 23, 2010 at 10:27 PM

Probably a memory thing. A reference marked as "null" would cause a none, while a reference to an object that's either marked for garbage-collection, or been garbage-collected, or something to that effect, would cause a missing.

The question is, do you really care about the difference or do you just want to know when your object has, for example, lots its target, and take action? If it's the former then I'm afraid I'm of no help. If it's the latter, then there are at least two ways to handle it. The easy way is to check either periodically, or on access, whether the object is there or not. The smart way is to code events using C# that your script can subscribe to, such as, say "OnLostTarget", that you can then take action on (in this case, trying to reacquire a target). The MSDN has info on how to set up a basic event system. This could also be accomplished in a simplified form using Unity's SendMessage function, but that's got a few disadvantages compared to events.

Comment
Add comment · Show 1 · 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 Jean-Fabre · Nov 25, 2010 at 06:09 AM 0
Share

I do care about the difference indeed, I will look at that onlosttarget thing, and see how it goes. thanks.

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

No one has followed this question yet.

Related Questions

How to reference a script asset 3 Answers

Scriptable Objects, how to force Include in Compile / Build without referencing it in the scene? 1 Answer

How can I make one variable affect others in custom inspector? 2 Answers

Edit Static Class Config variables from editor 1 Answer

How Can I make Inspector Header, Container or GroupBox to hide and show at Unity Editor Inspector? 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