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 thrmotta · Jun 05, 2014 at 02:42 PM · guieditorhierarchyidehideflags

Cant hide anything in Hierarchy IDE

Hello!

Im currently trying to hide a few objects at Hierarchy IDE and after searching in the documentation, I found this link (http://docs.unity3d.com/ScriptReference/HideFlags.HideInHierarchy.html) which should solve my problem, but after a couple of tries, I still cant manage to hide anything!

This is the code im using to attempt to hide a predetermined object:

 public static void HideObjects( bool isTheSameObject )
     {
         ColorPicker[] getObjects = GameObject.FindObjectsOfType(typeof(ColorPicker)) as ColorPicker[];
         for (int i = 0; i < getObjects.Length; i++) 
         {
             Debug.Log ("Object Name: "+getObjects[i].name+". HideFlags: "+getObjects[i].hideFlags);
             if (isTheSameObject)
             {
                 getObjects [i].hideFlags = HideFlags.HideInHierarchy;
             }
         }
     }

The Log tells me that the list is in fact getting the right objects. This method is being called at OnGUI by a script extended by EditorWindow.

What am I doing wrong?

Thank you so much for your help!

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 Graham-Dunnett · Jun 05, 2014 at 03:55 PM

In a completely new project, with a game object in the hierarchy called "fred" this code works for me:

 // c# example
 using UnityEditor;
 using UnityEngine;
 
 public class Hider : MonoBehaviour {
     [MenuItem ("MyMenu/Do Something")]
     static void DoSomething () {
         foreach (GameObject go in Selection.gameObjects) {
             Debug.Log(go.name);
             
             if (go.name == "fred") {
                 go.hideFlags = HideFlags.HideInHierarchy;
             }
         }
         
     }
 
     [MenuItem ("MyMenu/Do Something2")]
     static void DoSomething2 () {
         GameObject fred = GameObject.Find("fred");
         
         if (fred) {
             Debug.Log("found fred");
             fred.hideFlags = HideFlags.None;
         }
     }
 
 }

The first menu item looks at the selection and if it finds fred hides it. The second just makes sure it's visible.

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 thrmotta · Jun 05, 2014 at 04:23 PM 0
Share

This is really weird.. Im still not able to hide it from the ID$$anonymous$$ I manually select a component at the Hierarchy $$anonymous$$enu, click on $$anonymous$$y$$anonymous$$enu, then on Do Something and it still wont hide it even though the Log tells me that the " if (go.name == "fred")" line is getting a hit.

Just for the record, I didnt paste it onto a new project, but on the one im using atm.

Im using Unity 4.3.1f1 and Windows 7.

Any idea what this could be?

avatar image thrmotta · Jun 05, 2014 at 06:07 PM 0
Share

I finally managed to do it! In order to make your code work, I had to do the following modification:

 if (go.name == "fred") 
 {
     Debug.Log ("Hiding fred");
     go.hideFlags = HideFlags.HideInHierarchy;
 
     go.SetActive (false);
     go.SetActive (true);
 }

Without that, the HideInHierarchy flag wont work at all. Ill still make this as correct answer tho! Thank you!

avatar image
0

Answer by sarusian · Jun 05, 2014 at 03:37 PM

You could use visual studio(which I use), it has a lot more features, and allows you to hide entire methods, there is a free version on the website. http://www.visualstudio.com/

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 Graham-Dunnett ♦♦ · Jun 05, 2014 at 03:38 PM 0
Share

Not sure this is any kind of answer for the question. The OP is trying to use a Unity API to hide assets in the hierarchy.

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

23 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

Related Questions

How to hide parent in Hierarchy and maintain child? 0 Answers

Unity hideflags - hide in hierarchy but still render in scene 1 Answer

Hierarchy in editor 2 Answers

Objects in hearachy change order for no reason 7 Answers

Create Multiple Foldouts. 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