Touchscreens, Unity and all that hub-bub

I have inherited this Unity project. Most of the work has been done, and for the most part its all working. Got a few minor bugs other than this touchscreen issue, but is trying to get them all worked out.

The biggest, most important problem is this touchscreen issue, and is why I am here to see what I can learn. Seems like I'm not the only one with this problem. (Makes me feel a little better LOL ^_~)

Here is a link to a thread I posted to on the unity forums: http://forum.unity3d.com/threads/77569-UnityGui-useless-for-touchscreens

I am here to add me name to this list:
Ish having the same issues with a touchscreen.
Working on a mac-mini, elo touchscreen.

I got this project handed to me, and this seems the only thing left to do. Get this project to work on this touchscreen.

Only got 4 buttons that move my gameobject, and one for a help panel.

so, ok...after reading this thread, there seems only two options... 1. Get the mouse emulation to work correctly, (cool...how is that done?) or 2. write a plugin / use one of those that are already available for some panels. (where do I find one of these plugins?[and then after finding it, how to use it?])

It would be nice to see some kind of simple example of how this is done, please...

The funny thing I find here, is that when I test this project in Unity, it works fine on the touch screen. The problem occurs when I export the project into the stand alone player... Funny, huh? ^_~

I have been trying to learn unity on the fly here. I normally do flash action script, and html/css. So the java-scripts aren't too awful difficult. There's not been any c# scripts used so far...kindof weak in c# anyway, so good.

I'm not really sure of the questions I need to be asking. I do know this needs to get fixed, as the project has already been delivered in-spite of the bugs. They have been very cool about all this, and I want to fix this for them.

Project runs on a mac-mini with a elo 32 inch touch screen, and software.

Maybe my 4 control buttons, and the 5th menu button should be taken out of the unity GUIStyle thing and placed in a different way?

I admit it...I'ma kindof lost here.

PS...

I do feel this bit bears repeating...

The funny thing I find here, is that when I test this project in Unity, it works fine on the touch screen. The problem occurs when I export the project into the stand alone player... Funny, huh? ^_~

Ok, I got it...sortof.

The answer lay in this thread: http://answers.unity3d.com/questions/5382/can-i-change-guibutton-behaviour

You need to create the rect outside of the onGUI function first. Second, keep all your button functions in an upDate function, rather than in your onGUI function, as we had done here. The only thing that goes in the onGUI would be the GUIButton itself, which is created with the rect that was created outside on the onGUI function.

Now, we are coding in java-script rather than C# like the exampe I found, so had to re-write the code for that. Also, we are using a texture button, so those adjustments are included in my js conversion. This will give you a repeating button, which is what we needed. So, here's my version of the above example:

private var myButtonRect : Rect;
private var myButtonTexture : Texture2D;
function Awake()
{
    myButtonRect= new Rect(0, 0, 200, 100);
}
function Update()
{
    var fMouseX : float  = Input.mousePosition.x;
    var fMouseY : float  = Screen.height - Input.mousePosition.y; // Inverted Y

    if (ButtonRect.Contains(new Vector2(fMouseX, fMouseY)))
    {
        // Then all you have to do is code your button behaviour for each mouse action

        if (Input.GetMouseButton(0))
        {
            // Your code for mouse left click
        }

        if (Input.GetMouseUp(0))
        {
            // Your code for left button released
        }

        // And so on...
    }
}
function OnGUI()
{
    GUI.Button(myButtonRect, myButtonTexture, "Whatever");
}