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
0
Question by Reafexus · Dec 07, 2012 at 07:01 PM · c#prefabinspectorsettings

What is the name of/How do I use the box in the Script Inspector that allows you to assign values to Public data?

The box in question is the one in the picture that contains Room Prefab, Item Prefab, etc. A Script's public variables appear there. I can assign whatever values I want to just the script. This way when I assign the script to an object or prefab those values for that instance are automatically populated. But this only works when I assign the script in using the editor itself (not at run-time).

When I use AddComponent it does not automatically populate those values though. All of the values remain null and then I have to load all of the prefabs in code and it creates a nightmare of loading prefabs and passing them around unnecessarily. Can I use the information in this box dynamically?

I only ever need to assign these variables once so I have no reason to touch them at all in code.

I have no idea what it is called so I can't google how to use it dynamically (Since I am hoping to use AddComponent). The Unity Manual doesn't describe this box specifically as it only discusses Objects and not scripts.

While typing this I came up with a solution that I don't like.

I could just use some conditionals in the script to prevent it from initializing anything until I am ready, then I will be free to avoid using AddComponent altogether eliminating my problem. But knowing the name of the box is still something I would like to know for future use in case I am required to use AddComponent elsewhere in a similar situation.

The box containing RoomPrefab,Itemprefab etc.

whatisthis.png (46.7 kB)
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

2 Replies

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

Answer by Bunny83 · Dec 07, 2012 at 10:31 PM

The "Default References" ( that's their name ;) ) are an editor only feature as far as i remember. This information isn't available at runtime. It's actually the same for prefab connections. At runtime you can't determine from which object another object has been cloned.

If you need to store prefab references, Just attach the script to a GameObject in the scene. There it will be serialized and you have your references available at runtime.

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
avatar image
0

Answer by shane.rachel · Dec 07, 2012 at 09:56 PM

the circle next to (NewRoom, Item, Chest, etc.) click on it and you can assign prefabs to those variables. Of course you need to create the prefabs first.

The box has no specific name, it's just a part of the inspector that stores public variables. Unity considers this to be pretty straightforward which may be why you can't find info on it

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 Reafexus · Dec 07, 2012 at 10:55 PM 0
Share

Sorry I wasn't specific enough. I wanted to know if I could use it dynamically. I know how to use it directly in the editor.

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

11 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

Related Questions

Accessing a game object from a script? 1 Answer

Accessing Script on instated prefab 1 Answer

Inspector vs Script: Component best practice? 1 Answer

How to create GameObject without adding it to scene? 1 Answer

Insert a prefab into scene in a 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