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
2
Question by schwertfisch · Dec 31, 2010 at 09:58 AM · prefabinspectorhierarchydrag-and-drop

Why cannot I drag and drop a gameObject from Hierarchy to a prefab's slot in the Inspector?

I have a game object prefab, say myPrefab.

On myPrefab, I have a script attached, which contains this line (I want myPrefab to follow ObjectToFollow, but that is irrelevant):

var ObjectToFollow: GameObject;

So now in the inspector, when I have myPrefab selected, under the aforementioned script theres: Object To Follow _______None (Game Object)

In the None (Game Object) field, I can drag and drop any other prefab.

I cannot however, drag and drop any game object from the Hierarchy into the None (Game Object) field. What should I do to put my gameObject to the Object To Follow slot in the Inspector?

The problem is that the ObjectToFollow is the main object of the game and it is already in the Hierarchy when the level begins.

I suppose theres something really basic that Im missing here.

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

3 Replies

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

Answer by Ejlersen · Dec 31, 2010 at 10:00 AM

Well, a prefab is a standard representation of a game object. If you dragged an object in from the scene, then it wouldn't be standard if you changed to a new scene.

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 schwertfisch · Dec 31, 2010 at 10:04 AM 0
Share

Now that I come to think about it, what you say totally makes sense... I'll try to figure out another way of making things work. Thanks Ejlersen :-)

avatar image Ejlersen · Dec 31, 2010 at 10:06 AM 0
Share

No problem. I think you could just apply the changes to your prefab, then it might follow your game object in the scene, since there is only one of them :)

avatar image schwertfisch · Dec 31, 2010 at 10:23 AM 0
Share

I made a prefab of the ObjectToFollow and I dragged'n'dropped that prefab in the None(GameObject) slot. Unfortunately, even if it's the only ObjectToFollow prefab instance in the scene, myPrefab doesn't follow it (I know the script that does the following is correct, I have used it with simple game object versions of the prefabs). I'll try to resolve the problem by making myPrefab a child of ObjectToFollow.

avatar image
3

Answer by pavlito · Oct 13, 2014 at 07:02 AM

Running a bit late with the answer, but, from what I gather you are trying to drag an object from the scene to myPrefab which is selected in the project view. This cannot be done. What you can do is make a prefab of the object that's in the scene and then drag that prefab to a myPrefab (now you can drag from project view to project view).

Hope this makes sense.

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 civilerhamza · Feb 01, 2018 at 04:31 PM 0
Share

I specially logged in to upvote this answer. This worked for me. Thanks!

avatar image
1

Answer by Chris 22 · Jan 02, 2011 at 09:26 PM

Can't you change

var ObjectToFollow: GameObject;

to

var ObjectToFollow:Transform;

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

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

How can I access the 2nd tier of children on a prefab in the Project Folder Window? 4 Answers

A method for locking a prefabs instance from being modified? 1 Answer

How To Sort Prefabs In Hierarchy? 1 Answer

Placing Prefabs in Prefabs. 9 Answers

What is the name of/How do I use the box in the Script Inspector that allows you to assign values to Public data? 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