Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Problema para confirmar personaje (prefab)

Iniciado por Bydark, Julio 04, 2016, 06:18:06 PM

Tema anterior - Siguiente tema
Antes de nada siento enormemente tener que ponerlo aquí, pero no se cuantos mensajes necesito para postear en otras secciones del foro..perdón!!
 
 
 
Mi problema es el siguiente, estoy haciendo una escena donde elegir personaje, el cambio de personaje se realiza, pero necesito confirmar que quiero usar ese prefab y tenerlo en la siguiente escena listo para ser cargado.
 
Os dejo el código como lo llevo hasta ahora, como podréis ver, el "Play" funciona igual que el botón "Next" ya que realmente no se seleccionar el prefab y pasar a otra escena..
 
¿Alguna ayuda? Mil gracias!
 
 
 

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class CharacterSelector : MonoBehaviour {
 
public List<GameObject> characterList;
public int index=0;
void Start () {

   GameObject[] characters = Resources.LoadAll<GameObject>("Prefab");
   foreach (GameObject c in characters) {
      GameObject _char = Instantiate(c) as GameObject;
      _char.name = c.name;
      _char.transform.SetParent(GameObject.Find("CharacterList").transform);
      characterList.Add(_char);
      _char.SetActive(false);
      GameObject.Find("CharName").GetComponent<Text>().text = characterList[index].name;
      characterList[index].SetActive(true);
 
   }
}
public void Next(){
   characterList [index].SetActive (false);
   if (index == characterList.Count - 1) {
      index = 0;
   } else {
      index++;
   }
   GameObject.Find("CharName").GetComponent<Text>().text = characterList[index].name;
   characterList [index].SetActive (true);
   
}
public void Previous(){
   characterList [index].SetActive (false);
   if (index == 0) {
      index = characterList.Count-1;
   } else {
      index--;
   }
   GameObject.Find("CharName").GetComponent<Text>().text = characterList[index].name;
   characterList [index].SetActive (true);
   
}
 

public void Play(){
   characterList [index].SetActive (false);
   if (index == characterList.Count - 1) {
      index = 0;
   } else {
      index++;
   }
   GameObject.Find("CharName").GetComponent<Text>().text = characterList[index].name;
   characterList [index].SetActive (true);
}
void Update(){
   characterList [index].transform.Rotate (0,0.5f,0);
}
}

 
 

técnicamente solo necesitas presentarte. Si ya lo hiciste contacta con el administrador @pioj

Julio 04, 2016, 06:32:12 PM #2 Ultima modificación: Julio 04, 2016, 06:36:17 PM por Bydark
Cita de: leocub58 date=1467649394técnicamente solo necesitas presentarte. Si ya lo hiciste contacta con el administrador @pioj
   


Gracias, ya me he presentado pero ha sido hace poco, quizás hay que esperar más, sino contactaré con el, un saludo :) .
 
 
 
EDITO: Ya me deja, voy a poner el post en su sitio, siento el desorden xD.
 
 


Etiquetas: