Questions about the Inspectors fields.

Yesterday I ran this tutorial. http://www.youtube.com/watch?v=cIcCl4Ds9bI to make a login script. It uses JS.

I was learning the previous so I could modify this script which is in c#. http://wiki.unity3d.com/index.php/BOX1_-_gui_Login.cs_script

My goal was to be able to have options in the inspector to to position, size the gui input fields. The first tutorial (JS) does this, it has variables that give you positioning in size that can be tweaked in the inspector. I understood that very easily.

However, the second script which is the one I need is in c#, has none of the inspector options like the JS. I am trying to figure out how to add the function from that JS script to the c# login script. If that is possible.

If I could see some example code, I would be able to get a better starting point as it relates to what I need to happen.

This section below controls the input fields. Thanks.

		// Show login fields if connected and reconnect button if disconnect
		if (smartFox.IsConnected()) {
			GUI.Label(new Rect(10, 116, 100, 100), "Username: ");
			username = GUI.TextField(new Rect(100, 116, 200, 20), username, 25);
			if ( GUI.Button(new Rect(100, 166, 100, 24), "Login")  || (Event.current.type == EventType.keyDown  Event.current.character == '\n')) {
				smartFox.Login(zone, username, "");
			}
		} else {
			if ( GUI.Button(new Rect(100, 166, 100, 24), "Reconnect")  || (Event.current.type == EventType.keyDown  Event.current.character == '\n')) {
			Application.LoadLevel("sc_City");
			}
		}
 
		// Draw box for status messages, if one is given
		// Contains some logic to parse message of multiple lines if necessary
		if (statusMessage.Length > 0)
		{
			int boxLength = 61;							// define length of status box
			int messageLength = statusMessage.Length;	// get length of status message
			string originalMessage = statusMessage;		// copy message in to work string
			string formattedMessage = "";				// define output message string
			int i = 0;
			while (i + boxLength < messageLength)		// iterate and add newline until over length
			{
				formattedMessage = formattedMessage + originalMessage.Substring(i,boxLength) + "\n";
				i = i + boxLength;
			}
			// add last piece of original message
			formattedMessage = formattedMessage + originalMessage.Substring(i,  boxLength - (i + boxLength - messageLength));
			// draw status box with message
			GUI.Box (new Rect (Screen.width - 420,10,400,48), formattedMessage);
		}
 
	}

The way you move code from one language to another is you translate it. C# and JS are similar so it should be straightforward. If you’re having problems then you are either lacking C# skills or JS skills and need to learn about those languages. If you specify what specific part you got stuck on I can tell you what’s the general name for it so you can learn about it.

As to examples, you said you are trying to move code from one example code to another. How many more examples do you need?

It’s the positioning and sizing part. Unfortunately I’m at work and didn’t have the JS code on hand to show. But in that JS, it created extra fields in the inspector, that were from variables allowing either to type in a size or to use a slide in the inspector to tweak the size and position.

I was looking for the equivalent for C# and add it to the above code.

And yes, been working on learning more, but I ran that JS tutorial with success only to realize the script I needed to edit is in c#. But I could find no tutorial with a similar example in c#.

Here’s a doc specifically on topic of inspector fields:

Generally I would suggest to learn and work with C# and not JS. It seams newcomers are advised to start with JS supposedly because C# is more complex and confusing. It’s true that it’s more complex, it’s also far more power full in general and in context of Unity.
JS and C# have similar syntax but are slightly different fundamentally. C# is object oriented and that’s pretty much standard for entire software industry. For this two reasons you want to work with C#. JS on other hand has prototypes instead of classes. C# might be confusing for beginner but it will be more confusing when coming from JS. I would suggest to skip JS all together.
Here are official tutorials in C# (JS translations included):

Plenty more around the web.

Thanks, and definitely, I noticed JS was not the ideal way to go. I’ve been reading these tutorials, but I just needed to see a tad of an example in a direct relation to what I posted about. But I just found some more youtube vids with C# that I think will get me on track.

thanks.