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 alpayoguz97 · Nov 25, 2020 at 12:23 PM · prefabstransform.positionprefab-instance

I can't drag prefab gameobject into other prefab gameobject

Hi guys,

I'm trying to make a path for enemy in my game. To do this I created a List variable named waypoints. Then I tried to drag waypoints into this. But I can't drag them into it.

 public class EnemyPath : MonoBehaviour
 {
     [SerializeField] List<Transform> waypoints;
 }




https://ibb.co/j38G3wL

Thanks advance for your interest

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
1

Answer by blaskojoz · Nov 25, 2020 at 01:04 PM

I think you are trying to add values directly into the PREFAB. Instead of that, click on the enemy gameobject in hierarchy window and add some values here.

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 alpayoguz97 · Nov 25, 2020 at 01:19 PM 0
Share

Yes I'm trying to do that. But Why doesn't it work ? For example when I serialize a gameobject, I can add values directly into prefab . So what is the problem with this list variable ?

And yes, As you said, I added values in the hiearchy, but I can't apply it to the prefab from "overrides" tab (When I click "Apply all" to save changes to prefab , nothing happens)

avatar image blaskojoz alpayoguz97 · Nov 25, 2020 at 02:09 PM 0
Share

I'm not sure why it's not possible but if List(Gameobject) works why you simply don't use List(Gameobject) instead of List(Transform) ? Gameobject it's just simple wrapper/container for other components that derives from $$anonymous$$onoBehavor...

So in your code you can just simply get your transform like:

  [SerializeField]
     List<GameObject> waypoints;
 
     public void Start()
     {
         waypoints.ForEach(gobj =>
         {
             var myTransform = gobj.GetComponent<Transform>();
             // or better
             var mySameTransform = gobj.transform;
 
         });
     }

my 2 cents : From my point of view, populating class fields should not be allowed from hierarchy window (when we talking about prefabs). Every gameobject in hierarchy window BELONGS to current scene...

So there is question: what would happen if you instantiate SA$$anonymous$$E prefab in different scene where waypoint gameobject does not exist?

avatar image
0

Answer by alpayoguz97 · Nov 25, 2020 at 02:28 PM

No, not list (gameobject). Just gameobject. Creating gameobject and set reference in hierarchy works.

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 blaskojoz · Nov 25, 2020 at 02:36 PM 0
Share

this might help

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

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

Related Questions

How to instantiate a prefab declared in one script, from another script 2 Answers

instantiated GameObject Prefab jumps in air after instantiate 1 Answer

Hiding gameobjects in hierarchy make it less expensive ? 0 Answers

prefab navagent doesnt work,prefab navmesh doesnt work 1 Answer

Prefab Instance changing when loading scene in editor 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