void Awake() { // Singleton control if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } else if (instance != this) { Destroy(this.gameObject); } }
void LoadSprites() { GameObject avatarSaverGameObject = GameObject.FindGameObjectWithTag("Avatar Saver"); AvatarSaver avatarSaver = null; if (avatarSaverGameObject) { avatarSaver = avatarSaverGameObject.GetComponent <AvatarSaver> (); } // Check to see if can load and there is data to load if (avatarSaver && avatarSaver.GetHairFrontOutline() != null) { if (avatarSaver.GetHairBackOutline() == null) { hairBackOutline.sprite = null; hairBackPaint.sprite = null; hairBackOutline.color = Color.clear; hairBackPaint.color = Color.clear; } else { hairBackOutline.sprite = avatarSaver.GetHairBackOutline(); hairBackPaint.sprite = avatarSaver.GetHairBackPaint(); hairBackPaint.color = avatarSaver.GetHairColor(); } hairFrontOutline.sprite = avatarSaver.GetHairFrontOutline(); hairFrontPaint.sprite = avatarSaver.GetHairFrontPaint(); hairFrontPaint.color = avatarSaver.GetHairColor(); eyeImage.sprite = avatarSaver.GetEyeSprite(); headPaint.color = avatarSaver.GetSkinColor(); bodyPaint.color = avatarSaver.GetSkinColor(); topOutline.sprite = avatarSaver.GetTopOutline(); topPaint.sprite = avatarSaver.GetTopPaint(); topPaint.color = avatarSaver.GetTopColor(); bottomsOutline.sprite = avatarSaver.GetBottomsOutline(); bottomsPaint.sprite = avatarSaver.GetBottomsPaint(); bottomsPaint.color = avatarSaver.GetBottomsColor(); shoeOutline.sprite = avatarSaver.GetShoeOutline(); shoePaint.sprite = avatarSaver.GetShoePaint(); shoePaint.color = avatarSaver.GetShoeColor(); } }