Removing transform from Inspector

Hi there, I’ve written a GUI script which positions elements based on their viewport positions. As such, I don’t want to (mistakenly) manipulate the transform of the object, so I wondered is there a way to make the objects transform non-editable or not appear at all in the inspector?

I wouldn’t recommend to completely lock the transform. I would do something like this:

void Reset()

[ContextMenu("lock transform")]
void LockTransform()
    transform.hideFlags = HideFlags.NotEditable;

[ContextMenu("unlock transform")]
void UnlockTransform()
    transform.hideFlags = 0;

This will automatically lock the Transform component in the inspector when this script is attached or resetted (the Reset function). Additionally you can right click your script to lock and unlock the transform if it’s necessary.

It is also possible to completely hide the transform component, but again, it’s never a good idea to hide things. If the user doesn’t know it’s there it’s just confusing.

To completely hide the Transform use those value:

HideFlags.NotEditable | HideFlags.HideInInspector | HideFlags.HideInHierarchy;