Please add a renamer feature to components!

I’d really like a feature to give nickname/short comments to things like collision boxes. I have many in my scene due to fighting game hitboxes and name wise, they are all identical.

EDIT: What I am meaning is a “tag” that helps with organization in the viewport. Like if one sprite has many things of the same (not scripts) like collision boxes. It would be nice to call it “Hitbox_01” or “Hurtbox_03” instead of “CollisionBox2D” and “CollisionBox2D”. I don’t care much for the names inside scripts. Just want it for the viewport.

If you’re referencing scene view, you can add component with logic on those collision boxes of yours like so:

[SerializeField]
private string _comment = "CommentText";

#if UNITY_EDITOR
private void OnDrawGizmos()
{
     UnityEditor.Handles.Label(transform.position, _comment);
}
#endif
2 Likes

…why don’t you just name the gameobject? Or use the tag system?

4 Likes

There’s also this:
5148767--509900--upload_2019-11-7_11-57-5.png

Name the object accordingly, and select an icon, it will display a name in the scene view.

Yeah, I’ve completely overthinked this.

Well a component is just a monobehaviour script, which you can rename. As for naming the object, you can use an icon like @VergilUa mentions or use tag and gameobject name as @Murgilod mentions. This isnt a problem as much as it is a case of you not understanding how to use the hierarchy and inspector tools

As artist who has dealt with this issue, an inbuilt solution would be ideal. Something simple like f2 to rename component, lime anything else.

Color code tag is nice too.

In my case, it was long chains of triggers. We eventually made another trigger component with text and color display, but this is only like a folder divider, not the best solution.

Point is, I believe using trigger components is very common way to build things happening in game, no? Therefore user friendliness on the components we use to make triggers seems a good order.

Im confused, why couldnt you use the icon tag method shown above? That makes the object display with a text name in the scene, or is that not what your talking about?

edit: @BIGTIMEMASTER https://docs.unity3d.com/Manual/AssigningIcons.html

Not gameobjects, components on a single game object.

So you have empty game object in scene with a trigger collider. On it, you’ll have.like twenty scripts:
On player enter,
On enemy enter,
Delay next trigger
Reward gold,
Damage player,
Etc etc

The issue is each of these script components has same generic monoscript behavior title. So if you essentially have a robust scripted event, it becomes tedious to edit them. Any workflow solution involves a programmer making tools, as far as I know. If unity allowed standard renaming, it would read clean like above.

Why not have one script with an array of named modules/behaviours?
I hate spamming MBs like this.

1 Like

@SparrowsNest

I dunno I am artist. This is how tools were set up on a project before, and what I mentioned above is my idea on what I expect would solve problem and make engine more accessible to non-coders.

It is a lot more work to do it this way. To make process smooth, I think you need to also do a ton of editor scripting in order to set up all the parameters for a given sequence.

At a certain point it makes sense to make it more elaborate, and I think that @BIGTIMEMASTER 's example might have hit that point late in production, but I donno man.

Setting up a modular trigger sequence so that level designer can create complex sequences without spending weeks on it, I tend to think monobehaviour spam is probably the best option.

A trigger sequence would be like:

On Player Enter

  • Show Dialog (name)
  • Add player gold (amount)
  • Spawn enemy (unit type)
  • Focus camera on enemy
  • Delay (2 seconds)
  • Focus camera back on player

How would you set up something like this without spending huge amounts of time in editor scripting without monobehaviour spam?

Adding on to what everyone else has said you can change the appearance of Unity’s collision boxes too by writing a script that overrides the OnDrawGizmo() and OnDrawGizmoSelected() methods.

https://docs.unity3d.com/ScriptReference/Gizmos.html
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmos.html
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmosSelected.html

1 Like

OnDrawGizmoSelected is awesome, it lets you do a ton of stuff without having to add separate editor components. Really really useful.

What might be really useful is a certain type of object that houses a string of scripts. Like a box that you can put scripts inside of and they run as normal, but difference is if you double click and open this special box, you get a node graph where you can easily view and rearrange your scripts.

Basically a node graph for scripts that can be contained as a single component. Would be easy mode for level designers but also aid programmers in allowing them to visually map out things as well.

Then if you can unique name each box you got powerful system for visual organization. A component named (enemy explodes on contact) and inside you got graph with supporting scripts in whatever order you need.

I believe the common ways programmer is organizing scripts is like this already. You have a manager script that many smaller scripts get referenced from. This is same idea, just condensed into a visual tool, and like OP is saying if you can unique name it that makes really.tidy and readable project.

What i meant was like, renaming this “Box Collider 2D”. Cause i have a lot on my character and its hard to keep track.
5160335--511520--upload_2019-11-11_1-54-2.png

Place them on a separate objects as a children. Name them however you like and add an icon to it.
You’ll get a scene view gizmo with that name if you need one.

2 Likes

Unless something has changed, you would also have to add a script to make the child object detect the trigger event and then possibly send that to the parent. It is really not a great solution, more like a workaround as I see it. It works fine if you simply need multiple rigidbody colliders on a single object, as those colliders should work with the physics engine, but once you need code to directly respond, like with a fighting game where different things happen depending on the trigger that is hit, it isn’t as shiny anymore.

There are a billion better ways to handle that than renaming components themselves, which would lead to just as many, if not more, tracking issues.

1 Like

Try making a script inherting from the collider and add a string to it so you can name it.

Does that work? Never tried it but i’m planning on doing something like this only for rigidbodies.

I believe both Collider and Rigidbody are sealed, which means you can’t inherit from them.

You could simply put an additional component next to the collider which has the name. Or as people have previously suggested, just name the GameObject the collider is on.