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 Matt 15 · Oct 31, 2010 at 01:58 AM · iphonegetcomponentbce0019unityiphonedynamic typing

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

I've read through some forums, and I know the issue is related to Unity iPhone not supporting dynamic typing, but I still can't manage to get the syntax right on this one. Below is the syntax that works in standard Unity.

-- here is a snip of code, where I'm trying to test if the int "idNumber" is the same as the int "idNumber" on the object a ray is hitting where "hit" is the Raycast and "touchingThreeScore" is the name of the script attached to (and that has the variable idNumber) and the transform that is held in thisTransform

if(hit.collider.gameObject.GetComponent(touchingThreeScore).idNumber == thisTransform.GetComponent(touchingThreeScore).idNumber){ Debug.Log("You're Amazing for helping me out!!!");}

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

2 Replies

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

Answer by Eric5h5 · Oct 31, 2010 at 03:31 AM

if ( (hit.collider.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber == 
     (thisTransform.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber) {

Although probably you'd want to cache "thisTransform.GetComponent(touchingThreeScore)".

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 Matt 15 · Oct 31, 2010 at 05:11 AM 0
Share

This totally worked! Thank you! how would i go about caching the line you suggested? I guess my question really is, what type of item would it be? Component? or int?

Thanks again!

avatar image Eric5h5 · Oct 31, 2010 at 03:44 PM 0
Share

@$$anonymous$$att: var script = thisTransform.GetComponent(touchingThreeScore) as touchingThreeScore; The type is the same as the script name.

avatar image
0

Answer by Jessy · Oct 31, 2010 at 03:51 AM

Your code works fine in Unity 3. Ideally, you'd also GetComponent altogether, and use a generic list and the Find function, but UT hasn't supplied information about the appropriate syntax for lambdas in UnityScript, and I wouldn't bother with generic functions without them.

This didn't help.

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 Eric5h5 · Oct 31, 2010 at 04:29 AM 0
Share

His code actually doesn't work fine in Unity 3; anything with dynamic typing will fail when trying to make a build. GetComponent is slightly faster than using generics, so I wouldn't avoid it.

avatar image Jessy · Oct 31, 2010 at 01:59 PM 0
Share

I'll take your word on the dynamic typing thing, but that's terrible that there's no error generated prior to building. Interesting note on the GetComponent; do you have a link to results?

avatar image Eric5h5 · Oct 31, 2010 at 03:51 PM 0
Share

When doing iOS scripts one should always put #pragma strict at the top, and that will solve the error generation problem. This used to be implicit in Unity iPhone when it was a separate app, but probably because of the cross-platform nature of Unity 3, that doesn't happen anymore. I don't have a link offhand, just some benchmarks I did.

avatar image Jessy · Oct 31, 2010 at 04:30 PM 0
Share

It's not like we still don't deal with iOS projects. It doesn't affect me much, because I don't use UnityScript, but I think it's pretty lame to have to throw that pragma in now.

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

1 Person is following this question.

avatar image

Related Questions

Unable to load Unity iPhone examples as scenes 1 Answer

Why does this script I got from the Unity Document site does not work? 1 Answer

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

Ani.Mate error when port a PC game to iPhone 2 Answers

Making a GetComponent array 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