Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 peter · Aug 31, 2010 at 12:06 AM · variablesglobal

global variables possible in unityiphone 1.5.1

global variables possible in unityiphone 1.5.1 I'm using the scripts example from unity site but I seem to get a "fail" when building in xcode

// The static variable in a script named 'TheScriptName.js' static var someGlobal = 5;

// You can access it from inside the script like normal variables: print(someGlobal); someGlobal = 1;

To access it from another script you need to use the name of the script followed by a dot and the global variable name.

print(TheScriptName.someGlobal);
TheScriptName.someGlobal = 10;
Comment
Add comment · Show 1
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 BinaryCaveman · Aug 31, 2010 at 12:38 AM 0
Share

Is this a question or a statement? If it is a question, could you make your question more clear? If it is a statement, then this should not be a question. :)

1 Reply

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

Answer by jtbentley · Aug 31, 2010 at 01:55 AM

You can't access it dynamically like that on an iphone due to a lack of dynamic typing.

You would need to do this in your other script..

var someGlobal = TheScriptName.someGlobal;

function Start() { print ("result : "+someGlobal); }

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 peter · Aug 31, 2010 at 02:22 AM 0
Share

The change on script worked in the editor by using your suggestion and also not using capital on beginning of scriptname, but it doesn't build in xcode 3.1. Is it because I need to use xcode4?

Below is the error response after trying to build. OH SO CLOSE! Any suggestions? I've been hacking away at using global variables all day and I'm stumped.

ld: ldr 12-bit displacement out of range (6000 max +/-4096) in _AudioQueueAddPropertyListener$stub in _AudioQueueAddPropertyListener$stub from /Users/madpoet/balltest/balltest/build/testunity.app/testunity

avatar image peter · Aug 31, 2010 at 02:23 AM 0
Share

And thx so much kind sir!!!!!

avatar image peter · Aug 31, 2010 at 03:21 PM 0
Share

Update:

I kept getting build errors when using Global (static) variables so I tried switching the sdk setting from UNITY , project setting, player to sdk 3.0 and now it builds w/o errors, BUT...will this cause problems later when I upgrade to sdk 4? I'm assu$$anonymous$$g unityiphone1.5.1 works w/sdk4 and is compliant w/new appstore requirements.

THX FOR ANY HELP!!

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

Changing static variables from another script? 1 Answer

Accessing a global variable's referenced object's variable 1 Answer

Global variables help 1 Answer

My static variable is not changing 2 Answers

Editing local variables in another script 2 Answers


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