Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/12/2014, 13:27
Dempo87
 
Fecha de Ingreso: octubre-2013
Ubicación: Murcia
Mensajes: 54
Antigüedad: 11 años, 4 meses
Puntos: 0
Respuesta: ¿Como acceder desde un script a una variable instanciada en otro script?

Código C#:
Ver original
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Datos {
  5.  
  6.     public int indiceDemarcacion = 0;
  7.  
  8. }

Código C#:
Ver original
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DatosPersonaje : MonoBehaviour {
  5.  
  6.     //ESCENA DATOS PERSONAJE
  7.     public Datos datosPersonaje;
  8.  
  9.     void Start(){
  10.         datosPersonaje = new Datos();
  11.  
  12.     }
  13.  
  14.     void Update(){
  15.  
  16.     }
  17.  
  18.     void OnGUI(){
  19.  
  20.     }

Código C#:
Ver original
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Caracteristicas : MonoBehaviour {
  5.  
  6.     //ESCENA CARACTERISTICAS
  7.     public DatosPersonaje caractDatosPer;
  8.     public InformacionJugador caractInformacionJug;
  9.  
  10.     //Variables
  11.     public string[] posicion = new string[] {""};
  12.     public int recPosicion;
  13.     public int posicionSwitch = 0;
  14.  
  15.     void Start() {
  16.         caractDatosPer = new DatosPersonaje();
  17.         caractInformacionJug = new InformacionJugador();
  18.  
  19.     }
  20.  
  21.     void Update() {
  22.  
  23.     }
  24.  
  25.     void OnGUI () {
  26.  
  27.         posicion[recPosicion] = caracteristicas.datosPersonaje.demarcacion[caracteristicas.datosPersonaje.indiceDemarcacion];//1ª Prueba
  28.  
  29.         posicionSwitch = recPosicion;//2ª Prueba
  30.  
  31.         posicionSwitch = caracteristicas.datosPersonaje.indiceDemarcacion;//3ª Prueba

el ultimo script es donde tengo el problema. Se puede acceder a la variable que digo de alguna de esas formas? por que no lo consigo

Última edición por Dempo87; 10/12/2014 a las 13:40