- Home /
Unity 4.3 RenderToCubemap problem !
Hey,Guys
I seem to have encountered another problem again.This time its cubemaps
I created on Dynaimc reflection system for unity in Unity 4.0.It used to work fine So i didnt touch that even after upgrading to 4.3 .
Today when i wanted to add that for my vehciles
I encountered a problem with cubemap generation
AS you can see from the images only right side of the image (left of the cubemap) seems to be updated to the change where as rest of them are just taking the previous cubemap's front picture(I think so ) (in first case its back)
I even tried with Unity's Example script to generate cubemap from camera But it was same result
Rather than posting whole script and make you guys fell bored to read all of that i just posted the main part where it all takes place
Cubemap cube = new Cubemap(512,TextureFormat.ARGB32,true);
GameObject go = new GameObject("Cam" ,typeof(Camera));
go.transform.position = refletions[i].PositionTrans.renderer.bounds.center;
go.transform.rotation = Quaternion.identity;
go.camera.cullingMask = NeglectLayer;
go.camera.RenderToCubemap(cube);
refletions[i].cubeMap = cube;
refletions[i].LastPos= refletions[i].PositionTrans.position;
Material mat = new Material(refletions[i].PositionTrans.renderer.sharedMaterial);
mat.SetTexture("_Cube",cube);
refletions[i].PositionTrans.renderer.sharedMaterial = mat;
DestroyImmediate(go);
Thanks..