- Home /
Android Compiler Errors
New to scripting, trying to build a tutorial game to the android phone. Getting 2 errors,
BCE0019: 'isMatched' is not a member of 'Object'.
and
BCE0048 Object does not support slicing
With the bce0019 error, theres a couple other items with the same exact error (isFaceUp, img).
I beleive all the issues are contained in this portion of the script:
class Card extends System.Object
{
var isFaceUp:boolean = false;
var isMatched:boolean = false;
var img:String;
var id:int;
function Card(img:String, id:int)
{
this.img = img;
this.id = id;
}
}
function BuildDeck()
{
var totalRobots:int = 4;
var card:Object;
var id:int = 0;
for(i=0; i<totalRobots; i++)
{
var aRobotParts:Array = ["Head", "Arm", "Leg"];
for(j=0; j<2; j++)
{
var someNum:int = Random.Range(0, aRobotParts.length);
var theMissingPart:String = aRobotParts[someNum];
aRobotParts.RemoveAt(someNum);
card = new Card("robot" + (i+1) + "Missing" + theMissingPart, id);
aCards.Add(card);
card = new Card("robot" + (i+1) + theMissingPart,id);
aCards.Add(card);
id++;
}
}
}
function FlipCardFaceUp(card:Card)
{
card.isFaceUp = true;
if(aCardsFlipped.IndexOf(card) < 0)
{
aCardsFlipped.Add(card);
if(aCardsFlipped.Count == 2)
{
playerCanClick = false;
yield WaitForSeconds(1);
if(aCardsFlipped[0].id == aCardsFlipped[1].id)
{
//MATCH!
aCardsFlipped[0].isMatched = true;
aCardsFlipped[1].isMatched = true;
matchesMade ++;
if(matchesMade >= matchesNeededToWin)
{
playerHasWon = true;
}
}
else
{
aCardsFlipped[0].isFaceUp = false;
aCardsFlipped[1].isFaceUp = false;
}
aCardsFlipped = new ArrayList();
playerCanClick = true;
}
}
}
Answer by SisterKy · Aug 31, 2011 at 03:33 PM
Your problem is here:
var card:Object;
you need instead:
var card:Card;
The class Card extends the class Object but the variable card is only of class Object not of the extended class Card. And Object does not have a variable isMatched... Greetz, Ky.
I tried your change, I get the same error when I attempt to build it though.
no, I think the sniplet should do... wait a moment... I was so fixed on finding what caused the error that I didn't even think about it... why are you extending from System.Object? I'm not sure if Unity can deal with that the way you want it... I don't have much experience with these things but I think there's probably a reason why they recommend to extend from ScriptableObject class for cases like this...
(and again: I think you are trying to compile, not to build, are you? Please try to use these terms cleanly as they mean quite different things in Unity. compile -> stuff plays in unity editor; build -> stuff plays outside of unity editor)
Well, heres what I do. I goto File, Build settings, save as filename.apk, and click build. So during the compile process it fails with those errors. Sorry for being such a newb. Im a 3d modeler/animator, not scripter so this is very unfamiliar to me.
As for the system.object, I am following a tutorial and as described in the tutorial, the system.object I guess acts as a class that everything in Unity is derived from. Its supposed to be nondescript to cover everything not identified. (if im understanding it right)
oh, no sorry, then you are probably right... I'm unfamiliar with the android-kit and thought it was the same as standard, my bad... blushes (I'm from a artist background, too, btw...) ... but the bce-errors still classify as compiler-errors as opposed to runtime-exceptions...
yes, everything in Unity derives from System.Object, that's correct. (Except maybe Structs but that's another topic entirely...) ... hrm. If it's in your tutorial it has probably been tested and should work...? (I still find it kind of fishy... the recommendations are probably there for a reason and they say our self-made classes should usually derive from $$anonymous$$onoBehaviour or ScriptableObject (which ultimately derive from System.Object themselves))
hm wait... you get the exact same error? Still saying
"'is$$anonymous$$atched' is not a member of 'Object'."? or does it say
"'is$$anonymous$$atched' is not a member of 'Card'."?
Thinking about this some more, you probably still get the exact same error, right? I missed that var card:Object; is a local variable for function BuildDeck and has no influence on stuff in function FlipCardFaceUp (card:Card) where the local variable card already is :Card.... hrmmmm... that's weird!... can you post where you define aCardsFlipped?
Your answer
![](https://koobas.hobune.stream/wayback/20220612195106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Javascript array problem... 1 Answer
BCE0019: 'mesh' is not a member of 'UnityEngine.Component' on Android Build 2 Answers
Unity 3.4 standard assets not working in iOS builds? 4 Answers
NotificationCenter (from the community wiki) problem 1 Answer
Access JavaScript variables on c# script (Android build fails!) 1 Answer