Finger touch moves texture offset

I’m very new in unity and still learning. I have a dome with a 360° texture in it, I need to be able to move the offset of the texture with the finger, so I can see the rest of the 360° texture.

This is what I have so far. Don’t know why isn’t working…

public class offset : MonoBehaviour
{
    private Touch touch;
    private float speedModifier;

    // Start is called before the first frame update
    void Start()
    {
        speedModifier = 0.01f;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Moved)
            {
                float OffsetX = Time.time * speedModifier;
                GetComponent<Renderer>().material.mainTextureOffset = new Vector2(OffsetX, OffsetX);
            }
        }
       
    }
}

Line 21 is a hairy line of code.

Break it apart. Here’s a guide:

http://plbm.com/?p=248

That said, when you get a reference to .material, it makes a copy and hands it back to you.

You are modifying that copy and then doing nothing with it.

Because the way the line is written, this detail is not obvious, hence why I suggest a rewrite.

You need to assign the modified copy of the Material back to the renderer.