知识点:对数据的本地化存储和取用(PlayerPrefs 类)
诞生角色
using UnityEngine;
using System.Collections;
/// <summary>
/// 诞生角色
/// </summary>
public class BirthPlayer : MonoBehaviour
{
private int clothIndex = 0;
public GameObject player;
public Texture[] cloth;
private void Awake()
{
if (PlayerPrefs.HasKey("Cloth"))
clothIndex = PlayerPrefs.GetInt("Cloth");
}
private void Start()
{
GameObject clone =
(GameObject)Instantiate(player, transform.position, transform.rotation);
clone.GetComponentInChildren<SkinnedMeshRenderer>().material.mainTexture
= cloth[clothIndex];
}
}
更换服装
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
/// <summary>
/// 更换服装
/// </summary>
public class ChangeCloth : Mon