- Home /
Question by
MajoCardona · Oct 09, 2020 at 09:31 PM ·
texturetouchoffsetfinger
How I make finger touch move 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);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
touch input error - finger position offset 2 Answers
Best way of scrolling a texture without lagging? 0 Answers
How to move a specific texture from a shader? 0 Answers
Offset of texture with Raycast 1 Answer
can't offset normal map 1 Answer