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 beco13 · Jun 24, 2011 at 10:01 AM · iosbuildipadbce0019

iOS Build Error, runs normal in play mode

I want to build a project using iOS in the unity

The project I created runs normal in play mode. But when it comes to be built in Unity Builder it shows up errors like this

Assets/Script/Script PreBattle.js(21, 65): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Assets/Script/Script PreBattle.js(26, 58): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Assets/Script/Script PreBattle.js(30, 56): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Assets/Script/Script PreBattle.js(36, 56): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Assets/Script/Script PreBattle.js(42, 56): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Assets/Script/Script PreBattle.js(48, 56): BCE0019: 'OnGUI' is not a member of 'UnityEngine.Component'. Error building Player because scripts had compiler errors Unity.Editor.HostView:OnGUI() Exception: Error building Player because scripts had compiler errors UnityEditor.BuildPlayerWindow.BuildPlayerWithDefaultSettings (Boolean askForBuildLocation, BuildOptions forceOptions) UnityEditor.BuildPlayerWindow.GUIBuildButtons (Boolean enableBuildButton, Boolean enableBuildAndRunButton, Boolean canInstallInBuildFolder) UnityEditor.BuildPlayerWindow.ShowBuildTargetSettings () UnityEditor.BuildPlayerWindow.OnGUI ()

System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection and so on.... The question is why this happens? I run the project in the play mode and nothing goes wrong... someone help me please...thx :)
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 beco13 · Jun 27, 2011 at 08:38 AM 0
Share

pragma strict really helps :)

the problem is solved....I just type cast the component I want to show :) thx

1 Reply

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

Answer by Anxo · Jun 24, 2011 at 12:06 PM

Hi,

when you run an app on IOS it uses pragma strict. So you can not use most shortcuts.

if you add:

 #pragma strict

to the begging of your code, you will get the same errors in the editor. this will help you avoid the problems.

for example, you can use

 var TheMesh = GetComponent(MeshRenderer);
 TheMesh.enable = false;

in the editor. but with strict on, this would give you an error like "enable is not a member of Component" so you would have to use:

 var TheMesh : MeshRenderer = GetComponent(MeshRenderer);
 TheMesh.enabled = false;

Comment
Add comment · Show 4 · 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 · Jun 24, 2011 at 12:22 PM 0
Share

That won't solve the problem. If you declare The$$anonymous$$esh as a $$anonymous$$eshRenderer GetComponent($$anonymous$$eshRenderer) will still return a Component, not a $$anonymous$$eshRenderer and you'll get "Cannot convert 'UnityEngine.Component' to 'UnityEngine.$$anonymous$$eshRenderer'." there's also no need to spread this out over two lines. What you need to do is

 var The$$anonymous$$esh : $$anonymous$$eshRenderer = (GetComponent($$anonymous$$eshRenderer) as $$anonymous$$eshRenderer).enabled = false
avatar image michalbigplay · Jun 24, 2011 at 12:39 PM 0
Share

I've got similar issue, that is - build for web is fine, build for iOS couses similar errors.

For example: scene$$anonymous$$anager.transform.GetComponent("scriptScene$$anonymous$$anager").SubstractLife();

 //'SubstractLife' is not a member of 'UnityEngine.Component'. 

How do solve this problem?

avatar image Joshua · Jun 24, 2011 at 01:42 PM 0
Share

Look at the comment right above yours. SubstractLife is not a member of Component, so you must cast it as SubstractLife.

 (scene$$anonymous$$anager.transform.GetComponent(scriptScene$$anonymous$$anager) as scriptScene$$anonymous$$anager).SubstractLife();
avatar image Jessy · Jun 24, 2011 at 02:29 PM 0
Share

Joshua, it doesn't need to be so verbose.

 scene$$anonymous$$anager.GetComponent.<scriptScene$$anonymous$$anager>().SubstractLife(); 

is fine. I mean, it has a typo and uses camelCase where PascalCase would be standard, but it should compile.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

'Player Settings' does not show up when I click on it 9 Answers

Distribute terrain in zones 3 Answers

I can run the Unity3D Game through XCode, but can't run it directly through iPad. 3 Answers

Build and run question, iOS, newbie question 3 Answers

How to export to IOS 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