• 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
7
Question by MrDizzle26 · Feb 07, 2015 at 02:46 PM · prefabinspectorchildhierarchy

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

I want to access the child of a child of a prefab in the Project Folder Window, but Unity doesn't allow you to.

Here's what I mean...

This is what my prefab looks like in the Hierarchy Window. Notice how I can access "Marker" which is a child of a child of the parent prefab.

alt text

Now this is the same prefab in the Project Folder Window: For some reason Unity only lets me view the first tier of the prefab's children, and hence I can't access "Marker".

alt text

Is there a reason Unity does this? Because I need to access the lower tiered children to set up dependencies in the inspector window. I understand I could just make everything a tier 1 child, but this would make my objects very unorganized and hard to work with.

Any help with this would be really appreciated!

2.png (13.3 kB)
1.png (6.5 kB)
Comment
Add comment · Show 1
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 Opde · Jun 17, 2016 at 10:07 AM 2
Share

Did you find a way to solve this problem?

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Chris333 · Feb 07, 2015 at 09:48 PM

Hi,

i think the traversing level in the project window is limited by default and you cant change that.

Take a look into this forum post. Maybe someone has a solution for you. http://forum.unity3d.com/threads/showing-deeper-nested-levels-in-prefabs-project-view.8101/

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
3

Answer by alexjolig · Aug 09, 2016 at 09:02 AM

From this post

That is by design - from a scene, you can make references to game objects you can see in the project view; the ones nested down one level in a prefab.

We've limited that to one level for a few reasons: - A larger level made by an artist can have many, many game objects inside it. Letting people make references to game objects deep in the hierarchy seemed to be dangerous, as it would be too easy to introduce code dependencies on arbitrary art assets.

In code-based prefabs, its usually more flexible to have some accessor properties in the root game object that has pointers to what you need.

It seems to me that allowing deletion of gameobjects directly inside prefabs is actually a bad idea. Don't you want to see what you're doing? (If you are a programmer who has a complex manager setup, you can probably handle it - but prefabs are also used for graphics, and there you want to see what you do anyways)

And also a good offer to solve the issue

Double-clicking a prefab brings to you to a scene view with just that prefab instantiated in the scene hierarchy. So you can see the prefab in 3D, edit whatever you need to, and then when you close out of this view it goes back to whatever level you were previously editing...

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 jethrogillgren · Apr 22, 2018 at 03:26 PM 1
Share

"Double-clicking a prefab brings to you to a scene view with just that prefab instantiated in the scene hierarchy" I wonder how many hundreds of people have read your post and excitedly tried that in Unity. I was soo excited and then soo disappointed in such a rapid succession i need a $$anonymous$$ break. d:

avatar image KarlKarl2000 jethrogillgren · Jun 14, 2018 at 10:54 PM 0
Share

I too double clicked and felt great sadness.

C'mon Unity.. let us decide if its dangerous or not to our project. S$$anonymous$$H

avatar image
5

Answer by chronodm · Oct 07, 2016 at 10:03 PM

Note that you can work around this by selecting an instance of the prefab in the Hierarchy view and selecting "Select Prefab" in the context menu. It's a pain, but it does work.

Comment
Add comment · Show 4 · 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 Harinezumi · Jan 27, 2017 at 09:22 AM 0
Share

Not true, you cannot access 2nd level children of a prefab in the project view.

avatar image chronodm · Jan 30, 2017 at 08:20 PM 2
Share

@Harinezumi I didn't say you could access the children in the project view. I said you could work around the fact that you can't access them in the project view by accessing them through the hierarchy view context menu.

  1. create a prefab with three levels of children

  2. create two instances of the prefab

  3. in the hierarchy view, select the lowest-level child of one of the instances

  4. in the hierarchy view, right-click and select "select prefab"

  5. note that the inspector now shows the prefab grandchild, not the instance grandchild

  6. change a property, e.g. the material

  7. note in the scene view that both instances change

avatar image Harinezumi chronodm · Feb 18, 2017 at 05:31 PM 2
Share

Ah, that works? Didn't know that. Thanks for explaining and sorry for reacting too soon.

avatar image chronodm Harinezumi · Feb 21, 2017 at 06:43 PM 0
Share

No problem!

avatar image
0

Answer by winxalex · May 16, 2018 at 07:51 PM

  [MenuItem("Assets/Tools/WinxProduction/Expand Prefab")]
     public static void ExpandPrefab() {

         GameObject go = Selection.activeGameObject;

         Debug.Log(PrefabUtility.FindPrefabRoot(go));

         if (go != null && PrefabUtility.GetPrefabType(go) == PrefabType.Prefab) {


             //only first level are shown, so check deeper
             foreach (Transform child in go.transform) {
                 if (child != go.transform) {

                     child.gameObject.Traverse((gameObject) => gameObject.hideFlags &= (~(HideFlags.HideInHierarchy)));
                 }
             }

             AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(go), ImportAssetOptions.ForceUpdate);

         }

     }


     [MenuItem("Assets/Tools/WinxProduction/Collaps Prefab")]
     public static void CollapsPrefab() {

         GameObject go = Selection.activeGameObject;

         if (go != null && PrefabUtility.GetPrefabType(go) == PrefabType.Prefab) {


             //only first level are shown, so check deeper
             foreach (Transform child in go.transform) {
                 if (child != go.transform) {

                     child.gameObject.Traverse((gameObject) => gameObject.hideFlags |= HideFlags.HideInHierarchy);
                 }
             }

             AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(go), ImportAssetOptions.ForceUpdate);

         }


     }

 public static class GameObjectExtensions {
 
 
 
 
         public static void Traverse(this GameObject obj,Action<GameObject> action)
         {
 
             foreach (Transform child in obj.transform)
             {
                 if(child!=obj.transform){
 
                     action(child.gameObject);
 
                     Traverse(child.gameObject,action);
                 }
 
 
 
             }
 
         }
 
 
 
     }


Above will show you all levels but you wont see the hierarchy. So if you want that https://github.com/robotron2084/phinspector and don't want to create instances(I don't)

alt text

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

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

Make a simple tree 1 Answer

What is the best way to arrange prefabs in the hierarchy? 1 Answer

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

How can I access a Collider's GameObject in 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