GUI Textures C# !?

I’m looking to do some GUI elements, but the scripts are already written in C# and instead of converting everything that already IS working into JavaScript… I want to figure out how to use 2d textures in C#.

I’ve managed to figure out the difference in scripting for the most part of the GUI except for implementing images into the it.

I’ve searched through the forums and Documentation, but EVERYTHING is in JavaScript!!??

Anyone know how to do this??

Can you be a little more specific than “I want to figure out how to use 2d textures in C#.”

I script exclusively in C# (by preference) and I understand the frustration of all the documentation being in JavaScript. I’ve done all types of work with C# and Unity, including GUI for 3 different prototypes, so I’ll be more than happy to help.

Tempest Thanks for the quick reply.

I think what I’m going for is something like this

I have a GUI group. Within the group I have a box drawn and within it a label with some text. Within that same “menu” type box I want to place an image or images of a map that is about 256x256.

Although this is for a background for a start page, something along these lines in JavaScript but would like it C#.

Here’s the GUI I’m working with…

	void OnGUI() 
   {
	   if( shouldDisplay ){
	   // Welcome screen group
	   GUI.BeginGroup (new Rect (50, 50, 700, 400));
	   // Make a box so you can see where the group is on-screen.
	   GUI.Box (new Rect (0,0,700,400), "");
       GUI.Label (new Rect (10,0,650,300), "whatever text goes here");

		   
		
		   
	   // End Welcome group
	   GUI.EndGroup ();
	   }
   }

i’m just looking to place a 2D texture image within that group.

wouldn it be like this:

Texture2D image;
void OnGUI()
{
GUI.Label (new Rect (x,y,image.width,image.height),image);
}

Thats kind of what I thought. And I have tried that but. Your never declaring “which” image to use. So I get no errors back. Just no Image displayed… :smile:

whoa…my bad mate

it is supposed to be:

public Texture2D image;

being like this, you can just link an image in the inspector:smile:

that’s funny I just figured out to put the public in front of it. I was starting to wonder why JavaScript variables allowed the image to be selected through the inspector but the C# was not. It is doing what I need now… It’s always the little things… lol

Thanks Animaleante!!!
Caught it just as you did…

Great, good to see you figured it out. :slight_smile:

Thanks tempest

I just wish they had some good Doc’s on C# as they do JavaScript…