- Home /
Question by
r_chevallier · Apr 25, 2016 at 07:34 PM ·
sharedmaterialtexture offset
shared material with multiple texture offset speeds
Hello,
Is there a way to have a single Shared Material that can have multiple texture offset speeds without effecting the speed of all the instances that use this shareMaterial? I have different instances of a game Object using this shared material but would like a different offset speed for certain ones.
I am asking because using texture offset breaks batching unless set up as a sharedMaterial and I have several instances using this shared material. When I alter the texture offset speed all the instances are changed.
Any ideas would be much apreciated.
Below is my code for one sharedMaterial:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public float scrollSpeed = 0.5F;
public Renderer rend;
void Start() {
rend = GetComponent<Renderer>();
}
void Update() {
float offset = Time.time * scrollSpeed;
rend.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(offset, 0));
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612075614im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How does renderer.material instances work? 0 Answers
Problem with possibly shared meshes 0 Answers
How to check whether a material is unique? 1 Answer