Quantcast
Channel: Answers by "Graham-Dunnett"
Viewing all articles
Browse latest Browse all 959

Answer by Graham Dunnett

$
0
0
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.

Viewing all articles
Browse latest Browse all 959

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>