• 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 Capn J · Aug 20, 2011 at 04:09 AM · getcomponentupgradebce00193.43.3

Issues with 3.3 to 3.4 javascript update

i use getComponent somewhat regularly and once upgraded to 3.4 everything seems to blow up. I did see the JavascriptGuide with the release notes but i'm havin issues figuring it out in this situation:

    var UnlockedLevelObject;//set up empty variable for a gameObject
 
 
 function Start () {
     UnlockedLevelObject = GameObject.Find("LevelCarrier");//fill the empty variable with instantiated gameObject
 
     var LevelCarrierObject : LevelCarrier = UnlockedLevelObject.gameObject.GetComponent(LevelCarrier);//access variable in found gameObject above
     LevelCarrierObject.LevelToPlay = 0;//set variable insode that gameObject
 }

Thoughts?

Comment
Add comment · Show 7
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 FTheCloud · Aug 20, 2011 at 04:43 AM 0
Share

Yeah, downgrade to unity 3.3 until 3.4 is more stable.

avatar image Capn J · Aug 20, 2011 at 04:47 AM 0
Share

will 3.3 publish to Android 3.0 devices?

avatar image Joshua · Aug 20, 2011 at 04:59 AM 0
Share

There's no way to help you if you don't specify the problem you are having. The code you posted above works perfectly fine, compiles and runs without errors and as expected.

@FTheCloud 3.4 is only unstable on windows, which should be fixed with the release of 3.4.1 in the coming week. The problem he is having seems to be unrelated to this however, so I don't see why you think it's useful to suggest downgrading.

avatar image Capn J · Aug 20, 2011 at 05:07 AM 0
Share

The script above compiles fine in 3.3, but in 3.4 is throws this(I make calls like this quite a bit so i get MANY of the same errors)

Asset/Scripts/test.js(7,69): BCE0019: 'gameObject' is not a member of 'Object'.

i think it has something todo with this:

http://unity3d.com/unity/whats-new/unity-3.4#javascript-upgrade-guide

avatar image Joshua · Aug 20, 2011 at 05:12 AM 0
Share

I've tested this script, even a second time just now just to make sure, and it compiles and works just fine - on 3.4 of course. I've had to create a gameobject and a .js named LevelCarrier of course, with a single variable int named LevelToPlay, to make it all work.

From your error it would seem it's having issues with Unity's API DLL's. Try putting both scripts in a folder in the root of your project named "Standard Assets" to see if this fixes it, since scripts in this folder are compiled earlier and have elevated privileges. If this doesn't fix it, try re-installing Unity.

It's definitely not a problem with your code.

Show more comments

1 Reply

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

Answer by Eric5h5 · Aug 20, 2011 at 05:25 AM

You shouldn't use untyped variables, such as "var UnlockedLevelObject;". You should supply the type either explicitly or by using a value. (e.g., "var foo = 5;" is fine because it derives the type (int) by the fact that you supplied an int as a value.) In this case, the type should be GameObject.

You should specify whether you're doing iOS/Android programming, because in that case, Unity 3.4 adds an invisible "#pragma strict" to all scripts. This doesn't happen if you're doing web/Mac/PC programming. So "this code doesn't work in Unity 3.4" isn't really true--in some cases it does, in some cases it doesn't. (As an aside, you'll find coding easier if you follow the convention of using lowercase for variable names, leaving uppercase for classes and functions.)

Comment
Add comment · Show 2 · 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 Joshua · Aug 20, 2011 at 05:27 AM 0
Share

Clever, I forgot about the new invisible #pragma strict and only tested for normal.

avatar image Capn J · Aug 20, 2011 at 05:55 AM 0
Share

@Eric5h5 - Thx man, 3.3 made me lazy, i went in a specified my types and everything is good

@Joshua - Thx for the help mate, and after seeing what 3.4 did to my game's performance...holy &^. Game is running and instantiating on the Android wicked fast, just need to test on a 3.0 device and i'm ready for an update.

Thx again fellas.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why am I getting this error when accessing a variable or function on my script using GetComponent - 'x' is not a member of 'UnityEngine.Component'? 1 Answer

dynamic typing in Unity iOS: ...not a member of 'UnityEngine.Component' 2 Answers

Unity 3.0 help mee 4 Answers

parent->m_HasCachedTransformMatrix Error 2 Answers

BCE0019: is not a member of 'UnityEngine.Component' when trying to Build and Run iOS Unity 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges