- Home /
Unity3d fails when uses float value.
As you might know i have some global variables. When i use that variable from login_screen (c# script) everything is okey, but when i'm trying to use it in another scene (in JS script) it fails.
Debug.Log(GlobalClass.current_session);
Debug.Log(GlobalClass.y_coordinate);
First like - ok (its string), but on second line unity3d closes.
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; } } }
Answer by StephanK · Mar 19, 2010 at 09:34 AM
If you are using the same code you posted as an answer to your earlier question it fails because the getter y_coordinate returns itself and not the member m_y_coordinate like it should.
In general you should include relevant code (like the decalaration of GlobalClass) and any error messages you might get in your question.
but GlobalClass.current_session returns exactly what i want.
Yes, that is because the current_session getter correctly returns m_session while the y_coordinate getter returns itself rather than m_y_coordinate. I guess this is a typo, but if you have that typo in your actual code it can't work.
get { return y_coordinate; } oops, i found that misprint. thx
Your answer
Follow this Question
Related Questions
Insert a semicolon at the end Error. (JavaScript) 1 Answer
Saving Object Position in Float NOT Object 1 Answer
3d text will not display float 1 Answer
Resticing variables to whole numbers 3 Answers
Float.Parse() Question (Quickie) 1 Answer