- Home /
 
               Question by 
               simplyRubbish · Dec 31, 2011 at 04:57 AM · 
                textureterrainimageruntime  
              
 
              Changing terrain texture at runtime
I need to change my terrain's texture during runtime, specifically when the user loads the game it asks them which image to select. The images will be the same size (512x512) so size differences won't be an issue, I just don't know how to tell the terrain to load a different texture at run time.
Any help is appreciated. Thank you.
               Comment
              
 
               
              Answer by team_eden · Dec 04, 2014 at 01:03 AM
 var texturesIn:    Texture2D[] =new Texture2D [15];    
 var textureInSplats:SplatPrototype[]    =new SplatPrototype[1];
 
 function changeTexture(inTexture:int)
 {        
     textureInSplats[0] = new SplatPrototype();
     textureInSplats[0].texture=texturesIn[inTexture]; // texture here
     textureInSplats[0].tileSize= new Vector2(50,50); //tiling size
     terrainGameObject.GetComponent(Terrain).terrainData.splatPrototypes = textureInSplats;
     terrainGameObject.GetComponent(Terrain).Flush();
         
 }
Your welcome.
-TE
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                