Question by 
               shadowpuppet · Aug 20, 2016 at 06:48 PM · 
                playerprefstexturessaveload  
              
 
              saving texture change in PlayerPrefs
I have a script where I can toggle through textures but how do I save it to player prefs. the way the script is set up ( i think) is that when I press V I save the int of the texture that is displayed in the currentTexture var. And it looks like it is saving in that if I press V on texture 3 it appears in the saved texture slot and will change to whatever is the current texture when I press V. but when I press N nothing happens. Probably because I don't know what to set the playerprefs to. I have tried a number of ways the below script is just one of the non working ones
 using UnityEngine;
 using System.Collections;
 
 public class swaptop : MonoBehaviour {
     public int savedTexture;
     public Texture[] textures;
     public int currentTexture;
 
     public GameObject top;
     void Start () {
         //textures[currentTexture] = renderer.material.mainTexture ;
     }
     
 
     void Update () {
         if(Input.GetKeyDown (KeyCode.T)) {
             currentTexture++;
             currentTexture %= textures.Length;
             renderer.material.mainTexture = textures[currentTexture];
             savedTexture = PlayerPrefs.GetInt ("newTop");
         }
             if(Input.GetKeyDown (KeyCode.V)) {
             PlayerPrefs.SetInt("newTop", currentTexture);
 
         }
                 if(Input.GetKeyDown (KeyCode.N)) {
             currentTexture =    PlayerPrefs.GetInt ("newTop");
 
         }
 
     }
 }    
 
              
               Comment
              
 
               
              Your answer