- Home /
Problem with a circle GUI.
I set an circular image to GUI.skin.button.normal.background. then I Draw a small button ,size = 38.
GUI.Button(new Rect(100, 100, size, size), " ");
unity draw a little circle with small lines in 4 direction but I dont need them. I just want to draw a color selection button in circular shape like. When I try size = 100, it fixed but I want to keep it small --a;
![alt text][1] ![alt text][2]
If there is anything I dont know and should know please tell me. I'm quite new for both unity and GUI system so i'm sorry if this is a silly question. Thanks everyone^^! [1]: /storage/temp/19691-1.png [2]: /storage/temp/19693-2.png
Check that the texture import settings for that circular image has the Texture Type set to GUI, and that the image is actually a simple circle. Post a comment, or edit your question, with your results.
I would advice you to use GUITexture. It´s more efficient, and you can still use input and do lots of things with it.
Answer by zharik86 · Dec 24, 2013 at 08:10 AM
First, of course, it is necessary to check the size of a texture and if it is a circle, it has places where an alpha the channel is equal 0. Therefore it is better to do such texture in the psd format. Also it isn't necessary to convert an animaniye on texture dpi when importing, all the same everything will be reduced to 72. Further I advise to create new GuiSkin and by operation with Gui to be guided by it (will add in public beginning the public GUISkin mySkin variable = null, and the in OnGUI function at the beginning such line Gui.skin = mySkin. Further, I advise in new Skin, to create one more style, for example, btn1 (GUI.Button should apply (new Rec(0, 0, 100, 100), "myButton", "btn1"). It has same parameters, as well as at others. To us the border parameter is important, it gives an invariance of the size of a texture at the edges. And for invariable color of a texture it is necessary to add before GUI.Button the line GUI.color = Color.white. If to do a texture at which boundaries match with drawn, unity will expand it all the same on all rectangle. My decision following. The size 100 - all rectangle, the size 38 - a circle. It is possible to count a percentage ratio of a circle to all rectangle. Further to draw in psd, using this percentage ratio.
THAN$$anonymous$$ YOU VERY $$anonymous$$UCH AND $$anonymous$$ERRY CHRIST$$anonymous$$AS!!
the problem's fixed it's about border setting as you said. I've also tried gui texture and that work well also. But all my system is in OnGUI so I'd better use coding GUI.
I'm still confuse what does boarder and margin exactly do? can anyone explain about them please?
finally, this is what i'm doing a new board game. i've just finish placement system cause of you all :) http://bit.ly/1cA9n1P
@maxoja Border is a boundary of a texture (in our case of a texture of the button) which defines quantity not scalable pixels on the right, at the left, on top and from below. For example, we have a texture 100x100 and in border we specified all sizes 20. We do the button by a rectangle 150x150. Then from edges on 20 pixels the texture isn't expanded, and remained 60 (100-20-20) are scaled on 90(150-20-20). $$anonymous$$argin is an indent of the text from boundaries of rectangular area. I apologize for my English. Better to understand all parts of GUI, create new GUISkin in your project. Further add in a script where you have an OnGUI function (), public variable on created GUISkin (for example, mySkin). Further in the OnGUI function () at the beginning add GUI.skin = mySkin. Also create the button on the screen through GUI.Button (). Launch the project in the editor and open in the inspector created GUISkin. In it there will be button parameters. Changing them, you in real time will see that what parameter does. And $$anonymous$$erry Christmas. And please check this answer if it works.
Your answer
Follow this Question
Related Questions
unity make a skin/texture to a character like the robot from the fps tutorial 1 Answer
Unity 4 Problem - GUI Skin can not be founded 1 Answer
Rotate Texture 1 Answer
Problem With GUI Circle Thickness 1 Answer
GUI Skin Custom textures in C# 2 Answers