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
3
Question by Misterbenn · Apr 15, 2011 at 09:16 AM · objectid

GetInstanceId range of possible values

Hi,

I'm creating a script to export out scene data and I have a couple of questions regarding object ids.

  1. What is the maximum/minimum possible values for object ids accessed via Object#GetInstanceId?

  2. I've seen that the id value can be positive or negative - is there a practical difference?

  3. Also the values sometimes don't seem to be sequential (i.e. three cubes created at the same time have ids of -558, -11726 and -12668) - I was wondering why this was.

Cheers,

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

Answer by zeropoint · Apr 19, 2011 at 06:21 AM

1 - What is the maximum/minimum possible values for object ids accessed via Object#GetInstanceId?

Since Object.GetInstanceId returns in int which is System.Int32 in .NET perspective (CTS to be more specific), it's range is -2,147,483,648 to 2,147,483,647 or in other words -2^31 to (2^31 - 1).

2 - I've seen that the id value can be positive or negative - is there a practical difference?

Considering above fact, it probably makes no difference; also consider the following.

3 - Also the values sometimes don't seem to be sequential (i.e. three cubes created at the same time have ids of -558, -11726 and -12668) - I was wondering why this was.

The id kind of things are generally generated using hash values algorithms; so you can't guarantee what the next number might be!

Hope this is helpful enough :)

Comment
Add comment · Show 2 · 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 yoyo · Jan 14, 2014 at 11:58 PM 0
Share

If you really need these constants you can refer to int.$$anonymous$$inValue and int.$$anonymous$$axValue.

avatar image Cambesa · May 31, 2017 at 08:58 AM 1
Share

Wouldn't that cause problems when the hashing algorithm returns a value that is already used? If Unity checks the ID after generating the value, it seems to me that it computes more than necessary, starting with the $$anonymous$$imum int(perhaps unsigned for aesthetical reasons) value and counting up sounds less computational invasive. Aside from that, why computing the hashing algorithm at all if counting up is way more efficient?

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

2 People are following this question.

avatar image avatar image

Related Questions

InstanceIDtoObject namespace? 1 Answer

How push the object? 2 Answers

Attaching a Camera to the Player 3 Answers

Slicing Objects 1 Answer

How to activate a object with GUI button? (java script) 2 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