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
1
Question by Anxo · Jan 01, 2011 at 03:54 PM · build-errorcompile-errorbce0019

I get an error on build but not when I run the game in the Editor. iPhone.

Hi. I am working on a game and everything runs fine when I test it using Unity Remote. I can play the game while while controlling it with the iPhone and watch it run in the editor.

But when I try to build the game I get the following error: Error building Player because scripts had compiler errors

The Error it is refearing to is the following: Assets/MyScripts/SpawnScript.js(42,73): BCE0019: 'NewParent' is not a member of 'UnityEngine.Component'.

Now I understand where the error is pointing me. What I dont understand is why does it run fine when I test it in the editor using the play button.

The following script is what the error is referring to:

if(hit.transform.gameObject.name == ThisTransform)
            {
                var EntryScript = EntryGameObject.GetComponent(EntryScript);
                if(EntryScript.NewParent.childCount == 0)
                {
                    var NewParent : Transform = EntryScript.NewParent;
                    CloneBox.transform.parent = NewParent;
                    filled = false;
                    print(hit.transform.gameObject.name);
                }
            }

What I am doing here is assigning a new parent to a instantiated clone. This has to be dynamic because the parent often changes. And who the new parent should be is determined by the EntryScript on EntryGameObject. Again, this all works perfectly fine when tested in the editor.

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
1
Best Answer

Answer by Eric5h5 · Jan 01, 2011 at 04:00 PM

When using Javascript on iPhone/Android, put "#pragma strict" at the top of all your scripts, and fix any resulting dynamic typing issues. GetComponent returns Component, so you have to cast that as the correct type instead of relying on dynamic typing. Using generics is usually the easiest way (and also you should use the convention of lowercase for variable names, which makes things less confusing):

var entryScript = entryGameObject.GetComponent.<EntryScript>();
Comment
Add comment · Show 1 · 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 Anxo · Jan 01, 2011 at 04:18 PM 0
Share

Thank you.

I am sure what you said made sense but I did not understand most of it. The #pragma strict is interesting and I get that, I saw the syntax changes in your script exsample and it worked. I did not get your explination but I am greatful for your help.

The #pragma strict I had to turn back off after this fix because it gave me an error on my Instantiate. Can not convert object to game object. but when I turn strict off it will build.

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

GUI box problem 1 Answer

Unity shader compile error. Shader error in 'Standard' too many math instructions for sm2.0 3 Answers

Need some helps 2 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Android Compiler Errors 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