- Home /
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
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.
@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.
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.
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;
Your answer
Follow this Question
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