Instantiate player select prefab don't show in android. PLEASE HELP! I can't find error.
I have a script that contains the prefabs for the player's selection. This script is in an empty object. In Editor it works fine, but in built apk don't show these prefabs. Either change a text link to this prefabs. I can't find in forums. Please, can you help me?
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class PlayerSelect : MonoBehaviour {
public GameObject[] prefabs;
public int seleccionado;
[SerializeField] Transform initPosition;
GameObject PrefabInstanciado;
public static PlayerSelect instance;
private void Awake()
{
if(instance != null && instance != this)
{
Destroy(this.gameObject);
}
instance = this;
DontDestroyOnLoad(this.gameObject);
}
void Start()
{
seleccionado = 0;
PrefabInstanciado = Instantiate(prefabs[0], initPosition.position, initPosition.rotation) as GameObject;
PrefabInstanciado.name = "new Player";
}
public void Continuar(string name)
{
PlayerPrefs.SetInt("personaje", seleccionado);
SceneManager.LoadScene(name);
}
public void Siguiente()
{
if (seleccionado < (prefabs.Length - 1))
seleccionado += 1;
else
seleccionado = 0;
Destroy(PrefabInstanciado);
PrefabInstanciado = Instantiate(prefabs[seleccionado], initPosition.position, initPosition.rotation) as GameObject;
PrefabInstanciado.name = "new Player";
}
public void Anterior()
{
if(seleccionado > 0)
seleccionado -= 1;
else
seleccionado = prefabs.Length - 1;
Destroy(PrefabInstanciado);
PrefabInstanciado = Instantiate(prefabs[seleccionado], initPosition.position, initPosition.rotation) as GameObject;
PrefabInstanciado.name = "new Player";
}
}
[1]: /storage/temp/179057-controlbotones.jpg
controlbotones.jpg
(166.3 kB)
Comment
Your answer