I have a class that I use to do different things.
I would like to know if there is any way to name it and differentiate it at a glance.
This is my code:
//-------------------------------------------------------
using TransformExtensionMethods;
using UnityEngine;
//-------------------------------------------------------
public class HorizontalDetector : MonoBehaviour
{
//-------------------------------------------------------
[SerializeField] float rayCastDistance = 5f;
[SerializeField] LayerMask layerToDetect;
[SerializeField] private float offsetX = 0f;
[SerializeField] private float offsetY = 0f;
RaycastHandler ray;
//-------------------------------------------------------
void Awake() => ray = new RaycastHandler();
//--------------------------------------------------------
public bool IsDetected()
{
if (ray == null) return false;
Transform transform1;
Vector3 direction = (transform1 = transform).GetDirection();
var position = transform1.position;
Vector2 origin = new Vector2(position.x + offsetX, position.y + offsetY);
return ray.IsHitting(origin, direction, rayCastDistance, layerToDetect);
}
//-------------------------------------------------
public Vector3 GetPoint()
{
return ray.HitPoint();
}
//-------------------------------------------------
}
I am looking for something like this:
public class HorizontalDetector : MonoBehaviour
{
[SetNameFromEditor(" ")]
//or
[SetLabel(" ")]
//or
[SetCaption(" ")]
}
Iāve thought of just putting a string at the beginning and serializing it. Something like this.
public class HorizontalDetector : MonoBehaviour
{
[SerializeField] string ComponentName;
}
But that would be a variable that I would not use in the computation and would occupy memory.
And maybe there is something to do what Iām looking for, I still donāt know.
Is there a way to custom name a component?
Thank you so much!!