- Home /
drawing a line through a GUI label
hello,
i was trying to find out how i would go about drawing a line through a label from code. do i draw a line then place it in the right place and activate it when i need or can i do it in the GUI.label?
thanks
is this impossible or very simple and i am just missing something?
Do you mean producing something
like this
on your GUI labels?
Answer by fireDude67 · Jun 16, 2011 at 05:13 PM
I would just go into Photoshop/Paint.NET or another image-editor and make an image with a transperent background. Then, you should get the Text tool, and type your text and adjust font/size/color/etc. as you wish. Then, save this image.
Next, make a copy of the previous image, and draw a line through it in the image program. Save this as a different file.
You should now have 2 different text images, one with a line through it and one without a line through it.
Now, you can display the first image as a GUITexture. Then, make a new script:
var strikedImage : Texture2D; // Assign this variable wit the image with a line through it.
function Update() {
if (Input.GetKeyDown("space")) { // Or another trigger, it does not matter
this.texture = strikedImage;
}
}
Next, create a new GUITexture from GameObject -> Create Other... -> GUITexture
(is that right?) and for the Texture
variable, assign the first image (the one without the line through it) to it. Then, drag the above script onto it. Set the strikedImage
variable to the image WITH the line through it.
Finally, when you run the game, pressing space will change the image.
[1]: http://unity3d.com/support/documentation/Components/class-GuiTexture.html[GUITexture][1]
Your answer
![](https://koobas.hobune.stream/wayback/20220612110344im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting Scroll View Width GUILayout 1 Answer
What is frame, How OnGuI is called every frame? 2 Answers
'MouseLook.sensitivityX' is inaccessible due to its protection level. 2 Answers
Is this a problem of unity 3 or i am doing something wrong. 1 Answer