GUI.DrawTexture Rendering Issues

Hi, I’m trying to position a texture whenever there is a touch / mouse move, and
updates the texture relative to the touch / mouse coordinates.
Using the TUIO protocol, I’m receiving touch event and thereby updates the touches events which in turn store them to the dictionary.

The problem is: (Note: All coordinates be it touch or mouse is exactly the same.)

  1. GUI.DrawTexture + Touch Coordinates = Bad rendering texture while moving.
  2. GUI.DrawTexture + Mouse Coordinates = No rendering problem.

Can anyone pin point me to where might be the cause of the issue :slight_smile:

Here is my code:

public Texture2D texture;
    private Dictionary<int, int> activeTouchInput;
    private string HandID = "1000";
    private float width = 100.0f;
    private float height = 100.0f;
    

    private void OnGUI()
    {
        // Position only if there are active tags.
        if (activeTouchInput.Count > 0)
            PositionTexture();
    }

    private void PositionTexture()
    {
        // Linq Query to the get the touch value from the dictionary
        TouchInput activeTouch = (from activeTouch in activeTouchInput.Values
                                    where activeTouch.ID == this.ID
                                  select activeTouch).FirstOrDefault();

        float halfX = width * 0.5f;
        float halfY = height * 0.5f;

        // This line of code creates a very bad rendering of the texture while moving.
        // Basically it just takes the touch value from the dictionary and display a texture over it.
        GUI.DrawTexture(new Rect((activeTouch.X - 1) - halfX, (activeTouch.Y - 1) - halfX, width, height), texture, ScaleMode.ScaleToFit, true, 0.0f);

        // This line of code creates a very smooth rendering of the texture while moving.
        // The input is from mouse position.
        GUI.DrawTexture(new Rect(Input.mousePosition.x - halfX, (Screen.height - Input.mousePosition.y) - halfY, 300, 300), texture, ScaleMode.ScaleToFit, true, 0.0f);
    }

In what way is the rendering bad while moving??

Maybe you could try to do the same swipe with mouse and with touch and write the intermediate coordinates to a file in both cases, so that you can compare them. The must be some difference between mouse and touch, if you get different results.