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 moonLite · Jun 23, 2012 at 07:34 PM · stringstring.splitsystem.type

Error for 1st exactly same name var String

Hi guys,

Though I managed solved the problem but I'm curious what is going on.

 var tileName1 : String;
 //var tileName1 : String;

 function revealCardOne()
 {
     matchOne = hit.transform.gameObject;
     tileName1 = matchOne.transform.parent.name;
     
     if (matchOne == null)
     {
         print("No object found!");
     }
     else
     {
         tName1 = tileName1.Split("_"[0]);
     }
     

 }

It does sound stupid but when the 1st line of var tileName1 : String; is used it gives me this error:

Assets/TileGenerator_Script.js(91,47): BCE0022: Cannot convert 'String' to 'System.Type'. Assets/TileGenerator_Script.js(99,36): BCE0019: 'Split' is not a member of 'System.Type'.

But when I used the 2nd one, i retype again, it doesn't give me any error at all. Is it a bug or am I miss out something?

Thanks

Comment
Add comment · Show 2
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 yoyo · Jun 24, 2012 at 05:41 AM 0
Share

There is more going on than what you show here, as this code fragment doesn't compile (because 'hit' isn't defined). Can you show more of the code?

You might try putting "#pragma strict" at the top of your source file -- this will force you to declare all variables and may help identify problems.

avatar image moonLite · Jun 24, 2012 at 07:09 AM 0
Share

@yoyo, I have put #pragma strict at the top, it's error, it was actually "=" equal sign, I should have put the ":" I totally missed it out

Thanks for helping.

1 Reply

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

Answer by whydoidoit · Jun 24, 2012 at 05:45 AM

From your description it is very likely what you actually typed was:

    var tileName1 = String;

Which makes tileName1 a variable of type Type containing the type of a String.

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 moonLite · Jun 24, 2012 at 07:06 AM 0
Share

Sorry guys for asking such silly question, I kept looking at the spelling words but totally forgotten about the symbol. OH!!! I saved a copy of my error code, it was really var tileName1 = String;

avatar image moonLite · Jun 24, 2012 at 07:07 AM 0
Share

@whydoidoit thanks mike!

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

String.Split Not Splitting Correctly. Some Duplicates are being deleted. 1 Answer

Grab part of a string by looking for keyword 2 Answers

How to split a string using unity flash player? 0 Answers

The method Resources.Load does not accept strings after splitting. 0 Answers

Parse String and Serialise 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