Синтаксис:
Используется javascript
Debug.Log(GlobalClass.current_session); //эта срочка выполняется
Debug.Log(GlobalClass.y_coordinate); //эта "роняет" юнити, но такая же строчка в прошлой сцене прекрасно работает
Debug.Log(GlobalClass.y_coordinate); //эта "роняет" юнити, но такая же строчка в прошлой сцене прекрасно работает
UPD.
Забыл написать как я глобальные переменные инициализирую.
Синтаксис:
Используется c
using UnityEngine;
using System.Collections;
public class GlobalClass : MonoBehaviour {
void Awake () {
DontDestroyOnLoad (this);
}
private static string m_session = "";
public static string current_session
{
get { return m_session; }
set { m_session = value; }
}
private static float m_x_coordinate = 0;
public static float x_coordinate
{
get { return m_x_coordinate; }
set { m_x_coordinate = value; }
}
private static float m_y_coordinate = 0;
public static float y_coordinate
{
get { return y_coordinate; }
set { m_y_coordinate = value; }
}
private static float m_z_coordinate = 0;
public static float z_coordinate
{
get { return m_z_coordinate; }
set { m_z_coordinate = value; }
}
}
using System.Collections;
public class GlobalClass : MonoBehaviour {
void Awake () {
DontDestroyOnLoad (this);
}
private static string m_session = "";
public static string current_session
{
get { return m_session; }
set { m_session = value; }
}
private static float m_x_coordinate = 0;
public static float x_coordinate
{
get { return m_x_coordinate; }
set { m_x_coordinate = value; }
}
private static float m_y_coordinate = 0;
public static float y_coordinate
{
get { return y_coordinate; }
set { m_y_coordinate = value; }
}
private static float m_z_coordinate = 0;
public static float z_coordinate
{
get { return m_z_coordinate; }
set { m_z_coordinate = value; }
}
}