- Home /
Get the scripts name
Is there some way to get the name of the script without enter it by yourself?
Comment
Best Answer
Answer by Bampf · Apr 26, 2011 at 06:14 PM
Try either
this.name
or
this.GetType()
Note: that this won't be exactly the script's name if the name had spaces in it. Spaces will be removed. What you will get instead is the type-name of the component that the script got compiled to.
this.GetType().Name will give you the name of the class (only in C#?)
Answer by Uzquiano · Apr 26, 2011 at 06:02 PM
One solution can be using tags GameObject.FindWithTag You must consider that scrips are components of gameobjects
Your answer
![](https://koobas.hobune.stream/wayback/20220613125444im_/https://answers.unity.com/themes/thub/images/avi.jpg)