【发布时间】:2016-05-09 13:56:09
【问题描述】:
在我的游戏主菜单中有一个部分供玩家选择角色的皮肤并进入游戏。
我正在努力将用户选择的“Controller Animator”和“Transform”保存在 PlayerPrefers 中,并在下一个场景“Game”中的 x-0、Y-0、z-0 处实例化它。
所有皮肤都已将其“控制器”和“变换”附加到检查器(见附图)。
只有我不能在下一个“游戏”场景中实例化它们。
在我的脚本下方选择皮肤并进入“游戏”。
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Choice : MonoBehaviour {
public RuntimeAnimatorController anim;
public Transform Bee;
string skinChoice = "skin";
public void ChangeAnimator() {
Animator animator = Bee.gameObject.GetComponent<Animator>();
animator.runtimeAnimatorController = anim;
}
public void Play()
{
SceneManager.LoadScene ("Game");
}
}
【问题讨论】:
-
使用 playerprefs 非常简单:docs.unity3d.com/ScriptReference/PlayerPrefs.html
标签: c# unity3d unityscript unity5 unity3d-2dtools