- Home /
Material doesn't have a texture property '_RendererColor'
I want to scroll ball texture to show its moving so I have written this kind of code:
// ball texture rolling
textureOffset.x -= myRigidBody.velocity.normalized.z * (speed / 500f);
textureOffset.y = myRigidBody.velocity.normalized.x * (speed / 40);
myMaterial.mainTextureOffset = Vector2.Lerp (myMaterial.GetTextureOffset (1), textureOffset, speed * Time.fixedDeltaTime);
I was getting this kind of error during game play in Unity Editor.
This kind of material assigned to ball object:
I have just upgraded Unity version 2017.3.1p4 and error started coming, I don't know what to do now. Give me suggestions to solve this.
Answer by Eno-Khaon · Sep 15, 2018 at 10:01 AM
It looks like you've just been very "lucky" so far.
myMaterial.GetTextureOffset (1)
... is a particularly illogical call to make. Check out the documentation on the function. You can either feed in the texture name (likely "_MainTex") or for better efficiency, you can feed in a nameID, obtained using Shader.PropertyToID() (again, likely using "_MainTex").
Shader variable "numbers" aren't necessarily going to be consistent, so you should always make sure you're using the correct one by the correct name.
I have replaced my code like this:
my$$anonymous$$aterial.mainTextureOffset = Vector2.Lerp (my$$anonymous$$aterial.GetTextureOffset ("_$$anonymous$$ainTex"), textureOffset, speed * Time.fixedDeltaTime);
This is working properly now...
so thanks for your quick reply.
Your answer
Follow this Question
Related Questions
My model turns black 1 Answer
Transparency Diffuse Problem 0 Answers
Bumped Diffuse not working correctly 1 Answer
DAY and NIGHT Texture on Planet Earth 0 Answers