- Home /
Creating a 'Screen Rect' with two Vector3s
Hi everyone, I have done quite a bit of searching, however, I was wondering if someone could give me a direct explanation. I am creating a C# script for an RTS game that draws a rectangle using screen coordinates from two stored Vectors (acquired from the expression Input.mousePosition). I want to create a selector script. Can anybody help?
Thanks heaps in advance,
TheDeveloper.
Answer by harschell · Nov 28, 2012 at 11:32 AM
Hi,
Create a new folder in your Assets and name it "Resources", put a white texture of any size (32x32 for example) inside and name it WhiteTexture (It can be BMP, TGA, PNG, JPEG...) and do something like this in OnGUI function:
Texture2D MyTexture = Resources.Load("WhiteTexture") as Texture2D;
GUI.color = new Color(1.0f , 0, 0);//Set color to red
GUI.DrawTexture(new Rect(positionX, positionY, sizeX, sizeY), MyTexture); //positionX, positionY, sizeX, sizeY shuld be your stored vectors
GUI.color = Color.white;//Reset color to white
This will draw Red Rectangle. Its just a pseudo code... @TheDeveloper Do accept the Answer if its Helpful :) =)
Thanks harschell, however, it needs a little bit of work. Not complaining though!
Your answer
Follow this Question
Related Questions
rts developement 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Procedual Wall Generation 1 Answer
Problem with inheritance and access between scripts. 1 Answer