![]() Note: If the selected element is a line, the line will no longer be visible on the chart. ![]() To use a texture fill, click Texture, and then click the texture that you want to use. To use a gradient effect for the selected fill color, click Gradient, and then under Variations, click the gradient style that you want to use.įor additional gradient styles, click More Gradients, and then in the Fill category, click the gradient options that you want to use. ![]() In the Insert Picture dialog box, click the picture that you want to use, and then click Insert. To fill the shape with a picture, click Picture. In the Colors dialog box, specify the color that you want to use on the Standard or Custom tab, and then click OK.Ĭustom fill colors that you create are added under Recent Colors so that you can use them again. To use a fill color that is not available under Theme Colors or Standard Colors, click More Fill Colors. To remove the color from the selected chart element, click No Fill. When you point to colors that you may want to use, the selected chart element will be displayed in that color on the chart. Note that I used renderer as my reference for size, but obviously you can use any rectangle, as long as x,y is the top left corner.įrom what I can tell this works really well, looks great in game because I can easily move my bordered object around in all 3 axis (Even rotate it, and since line renderers always face the camera it doesn't look weird), and is not hard to implement.Tip: Before you apply a different color, you can quickly preview how that color affects the chart. ![]() In my case I needed to constantly resize the border to keep it around my object (A text mesh for a custom text field) so every update I did this:įloat width = Mathf.Max( + paddingX * 2, minWidth) įloat x = - width / 2 įloat height = + paddingY * 2 įloat y = - height / 2 ĪlterBorder(0, new Vector3(x - thickness / 2, y, 0), new Vector3(x + width + thickness / 2, y, 0)) //Bottom edge going left to rightĪlterBorder(1, new Vector3(x + width, y + thickness / 2, 0), new Vector3(x + width, y + height - thickness / 2, 0)) //Right edge going bottom to topĪlterBorder(2, new Vector3(x + width + thickness / 2, y + height, 0), new Vector3(x - thickness / 2, y + height, 0)) //Top edge going right to leftĪlterBorder(3, new Vector3(x, y + height - thickness / 2, 0), new Vector3(x, y + thickness / 2, 0)) //Left edge going top to bottomĪlterBorder() simply accesses the appropriate line renderer (specified by first parameter) and set its start and end to the first and second vector respectively. I am currently facing the same problem, and my solution is exactly what DuckMaestro and Raven Dreamer suggested - Have a script that creates 4 child objects at runtime each of which representing a side of the border and attach line renderers to each one. Though I believe you're asking for 2-d only, note that this same idea can be applied to 3d boxes if needed, where the BoxBuilder now must create and manage 12 child edges, but again only scaling each edge in one local dimension. It will be a lot of pos.x=w/2, pos.y=h/2. With a width and height defined BoxBuilder level, you can calculate the necessary positioning and non-uniform scale of the four child edges. Each child game object is one of your box edges, and can simply be a 3d cube that is stretched in only one dimension. With that in mind, you can devise a Component, say BoxBuilder, which when attached to a GameObject, creates and manages four child GameObjects. This is much like if you were to construct a box in real-life, where you are piecing together variable lengths of wood that all have the same cross-section size. Think of your 2d box as nothing more than four lines, where each line is stretched in only one dimension (the other two dimensions are the cross-section of the edge). GUI.Box(new Rect(boxPosHiLeftCamera.x, Screen.Height - boxPosHiLeftCamera.y, width, height),"", highlightBox) Vector3 boxPosLowRightCamera = (boxPosLowRightWorld) įloat width = boxPosHiLeftCamera.x - boxPosLowRightCamera.x įloat height = boxPosHiLeftCamera.y - boxPosLowRightCamera.y Vector3 boxPosHiLeftCamera = (boxPosHiLeftWorld) Vector3 boxPosLowRightWorld = new Vector3(1.5f, 0, 0) Vector3 boxPosHiLeftWorld = new Vector3(0.5f, 12, 0) 3D), just remember that in Unity's world coordinates y goes from bottom to top, and in GUI y goes from top to bottom. ![]() You can use Camera.WorldToScreenPoint method if you want to outline something in world coordinates (i.e. Create a new GUIStyle using a simple rectangle as a texture (the inside of the rectangle should be transparent, of course), set up its Border value so that it is not stretched, and call GUI.Box(new Rect(.),"",myGuiStyle). If you only need a 2D rectangle, GUI is the way to go. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |