Cant hide anything in Hierarchy IDE


Im currently trying to hide a few objects at Hierarchy IDE and after searching in the documentation, I found this link (Unity - Scripting API: HideFlags.HideInHierarchy) 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: "". HideFlags: "+getObjects*.hideFlags);*_

* if (isTheSameObject)*
* {*
_ getObjects .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!_

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.

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) {
			if ( == "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.