Heya, I am currently decorating my scene with various objects in Unity, but the Hierarchy is getting extremely cluttered, is there a way to create folders there to put environment objects in to keep it all tidy?
I am making a TDG so when the game is played the towers that get created clutter up the Hierarchy as well. So if there is any way to make a group, folder or anything that will not spam the Hierarchy, so do not have to scroll for 2 minutes to find 1 particular object
Any help is appreciated thank you.
You should still be able to mark oliver-jones's answer as Accepted (the checkbox under the thumbs), which will help others find this answer if they have the same question. BTW, from the [Transform][1] reference: "When parenting Transforms, set the parent's location to <0,0,0> before adding the child. This will save you many headaches later. " [1]: http://docs.unity3d.com/Documentation/Components/class-Transform.html
Yes, that is true, but I guess what is bothering me is the combination of GetTouch and GetButton/GetButtonDown. The reason I'm confused is probably that in my perception, the GetTouch is for touch devices like phones or tablets while the GetButtonDown I only ever used for things that has actual buttons ... like mouse/keyboard and such. What type of device is your project gonna run on?
Hereâs a little Unity editor script I use to group selected objects. Just save this as Assets/Editor/GroupCommand.cs. Use âCtrl-Gâ or âGameObject Menu > Group Selectedâ. It also supports Undo:
using UnityEditor;
using UnityEngine;
public static class GroupCommand
{
[MenuItem("GameObject/Group Selected %g")]
private static void GroupSelected()
{
if (!Selection.activeTransform) return;
var go = new GameObject(Selection.activeTransform.name + " Group");
Undo.RegisterCreatedObjectUndo(go, "Group Selected");
go.transform.SetParent(Selection.activeTransform.parent, false);
foreach (var transform in Selection.transforms) Undo.SetTransformParent(transform, go.transform, "Group Selected");
Selection.activeGameObject = go;
}
}
Thank you for the share. Can't believe this isn't part of the Editor by default! For info, if you use an asset like Gaia that has Cntrl G already reserved, you might want to change the keyboard shortcut. That's the '%g' part of the MenuItem.
Is there a way to change this script so that the objects are inserted into the group in the same order they were outside the group? Like if I have Enemy (1), Enemy (2), Enemy (3) in order I would like them to stay in order after they are moved inside the group.
Yes there is, but they arenât really folders. If you go to GameObject > Create Empty this will place an empty object on your scene as well as your Hierarchy, you can then drag particular objects into that without affecting your game at all.
Example:
You have a butt load of lights in your scene. You can then create a Game Empty and call it âLightsâ and then drag in all your lights into the object.
Think of it more like a ânullâ object.
Hope that helps.
Actually a "empty" gameobject still has a transform (cant be removed), which means that any normal logic that works via "transform.root" will break. Given the complex child/component relation unity uses, i would not advice to use this "hack" to simulate folders/grouping. Often its to complicated to sort out what child may or may not have a certain component, so its common practice to search from the transform.root, which in the case of those "folder" objects will result in wrong or unpredictable behavior.
Maybe that is my problem. I am new to all this. It is going to run on Android but I am testing it inside Unity because I can't get UnityRemote to work. Maybe that is my problem.
Actually a âemptyâ gameobject still has a transform (cant be removed), which means that any normal logic that works via âtransform.rootâ will break. Given the complex child/component relation unity uses, i would not advice to use this âhackâ to simulate folders/grouping.
Often its to complicated to sort out what child may or may not have a certain component, so its common practice to search from the transform.root, which in the case of those âfolderâ objects will result in wrong or unpredictable behavior.
Ah! I kinda had the same issue a few years back. IIRC I had to do something along these lines: if ( (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetKeyDown( KeyCode.Space ) ) {} so that it check for touch-input or editor input.
Create an empty gameobject and reset itâs position to (0,0,0). Drag this the project folder to create a prefab. Whenever you need to group objects, drag this prefab into the scene and itâs position will remain at the origin. Just make sure not to press apply on any of the groups.
Make a little empty script called (for instance and understanding) âWorkScriptTagâ, that functions as, sort of, a Tag.
Find all your item that you want to âGroupâ in your (most likely/up-to wast structured) hierarchy, and mark them.
Now, while all marked blue, press âAdd componentâ, and add the âWorkScriptTagâ to all the items/gameobjects you want to group.
Go to âProjectâ and right click the script and press the menu object; âFind References in Sceneâ.
This will result in you being able to handle + being-able-to-select all the given hierarchy GameObjects with the pseudo-âTagâ above (aka the âWorkScriptTagâ script attached).
You should still be able to mark oliver-jones's answer as Accepted (the checkbox under the thumbs), which will help others find this answer if they have the same question. BTW, from the [Transform][1] reference: "When parenting Transforms, set the parent's location to <0,0,0> before adding the child. This will save you many headaches later. " [1]: http://docs.unity3d.com/Documentation/Components/class-Transform.html
â TonyLiThere is also a search bar in the hierarchy window. If you know what you're searching for, you never have to scroll.
â JamoraYes, that is true, but I guess what is bothering me is the combination of GetTouch and GetButton/GetButtonDown. The reason I'm confused is probably that in my perception, the GetTouch is for touch devices like phones or tablets while the GetButtonDown I only ever used for things that has actual buttons ... like mouse/keyboard and such. What type of device is your project gonna run on?
â NerdClown