- Home /
www.texture on Projector wont clamp
I am trying to change the texture used on a projector at runtime from a texture on my server. I have managed to get working, when not building to web player, but the texture won't clamp. It is repeating even though I have tried to get it in the script. I'm sure it is something basic I am not doing, but I'm trying to pick up scripting as I go along. here is my code
public class ProjectorTextureLoad : MonoBehaviour
{
public int desiredWidth = 1024;
public int desiredHeight = 512;
private Texture2D _texture;
public string url = "http://mylogo.png";
IEnumerator Start () {
WWW www = new WWW(url);
_texture = new Texture2D(desiredWidth, desiredHeight, TextureFormat.ARGB32, false); _texture.wrapMode = TextureWrapMode.Clamp; _texture.Apply(false);
yield return www;
Projector proj = gameObject.GetComponent();
proj.material.SetTexture("_ShadowTex", www.texture); } }
Answer by Zerot · Jul 27, 2012 at 07:18 PM
Just skimmed over it, but it looks like you are creating a new texture and storing it in the variable _texture and then set the texture using www.texture. Those are 2 different objects, so setting the clamping on _texture has no effect.
Before "proj.material.SetTexture("_ShadowTex", www.texture);" add the line "www.texture.wrapMode = TextureWrapMode.Clamp;" and it should work fine.
Thanks mate really appreciate that. it totally makes sense too. I have cut the script down now too as some of it isn't needed like creating the _texture. Unfortunately it is still working as before, the clamp just wont seem to work on that www.texture before it is being applied to the projector
Your answer
![](https://koobas.hobune.stream/wayback/20220613074801im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to scale an object between two values over distance 1 Answer
How to clamp ovally? 1 Answer
2D GunPivot Bug 1 Answer
Clamping velocity and angular velocity at the same time? 0 Answers
How to limit a rigitbody to an area 1 Answer