I am watching a tutorial where it seem to work. But in my case, I am getting this error. I get it that non-static members have to have an object. But, I don't know much about how to fix this error.

using UnityEngine;
using System.Collections;

public class AnimatedTexture : MonoBehaviour {

    public Vector2 speed = Vector2.zero; 

    private Vector2 offset = Vector2.zero; 
    private Material material;

    void Start(){
        material = GetComponent<Renderer> ().material;

        offset = Material.GetTextureOffset ("_MainTex"); 

    void Update(){
        offset += speed * Time.deltaTime;

        material.SetTextureOffset ("_MainTex", offset);

You wrote Material.GetTextureOffset ("_MainTex"); in the Start() method. It should be material.GetTextureOffset ("_MainTex");.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.