Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Andrew Cherkashin · Mar 19, 2010 at 07:17 AM · javascriptfloat

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; } } }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Andrew Cherkashin · Mar 19, 2010 at 10:26 AM 0
Share

but GlobalClass.current_session returns exactly what i want.

avatar image StephanK · Mar 19, 2010 at 11:29 AM 0
Share

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.

avatar image Andrew Cherkashin · Mar 19, 2010 at 08:23 PM 0
Share

get { return y_coordinate; } oops, i found that misprint. thx

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges