- Home /
BCE0048 type Object does not support slicing
Dear Unity Community I am an indie video game developer always on the search of that contract…….. I am working on this very important project to give a demonstration of how “portable” Unity can be, the decision was between UDK, Torque and Unity, the “license agreement of Unity” interested the “investors”, if they like the demonstration this could be very good, because they want to sponsor many games for multiplatform, so…to safe time I purchase the Book “Unity 3D Game Development by example” and used one example I notice in the forum other people has used also. The game is the memory game called “Robot Repair”. I have experience developing with the other two engines but this is the first ride with Unity, I used the source code from the book which was a very good book and really covers my goals to give a quick demonstration and don’t have to research/plan a prototype for months to come. Anyway… The “JavaScript” code works fine, I was able to compile, build the Windows executable, and Web deployment, but………. “Slicing criterion” is not supported when trying to build the game for Android Platform. I am researching the solution right now and finding many interesting rules when developing to Android and iPhone, like for example or the iPhone is better “not to” de-allocate memory when using objects like “projectiles” for example, just create them and re-use them over and over as much as you need it until the game is over, then you kill’m ….. right??? My question, what is the best solution for the “slicing” problem? Like I said am reading about Android/iPhone Development for the first day today and if someone could give me a hand I would appreciate it very much. ( I thought maybe I could get the answer quicker here) Thank you very much. The code: (I separate the code with notations so I can better find what I need when I need it)
//===================================================== The Card grid variables
var cols:int = 4;//The number of columns in the grid
var rows:int = 4;//The number of rows in the grid
var totalCards:int = cols*rows;//The total of rows and cols above = 16
var matchesNeededToWin:int = totalCards * 0.5;//Half of the total number of cards (two cards combination matched)
var matchesMade:int = 0;//No matches
var cardW:int = 100;//Card number of pixels Width
var cardH:int = 100;//Card number of pixels Height
var aCards:Array;//Cards Array
var aGrid:Array;//Shuffled cards Array
var aCardsFlipped:ArrayList;//The two cards for the player
var playerCanClick:boolean;//Disable buttons
var playerHasWon:boolean = false;//Has the player won?
//var i:int = 0; Unnecessary but tried to avoid Android Compilation errors
//var j:int = 0; Unnecessary but tried to avoid Android Compilation errors
//============================================================= Code Block end
//============================================================= Build Deck
function BuildDeck()
{
var totalRobots:int = 4; //4 robots to work with (loop to run 4 times below)
var card:Object; // Reference to a card
var id:int = 0;//Id the cards
for (i = 0; i= matchesNeededToWin)
{
playerHasWon = true;
}
}
else
{
aCardsFlipped[0].isFaceUp = false;
aCardsFlipped[1].isFaceUp = false;
}
aCardsFlipped = new ArrayList();
playerCanClick = true;
}
}
}
//============================================================= Code Block end
//========================================================= Win Game Message
function BuildWinPrompt()
{
var winPromptW:int = 100;
var winPromptH:int = 90;
var halfScreenW:float = Screen.width/2;
var halfScreenH:float = Screen.height/2;
var halfPromptW:int = winPromptW/2;
var halfPromptH:int = winPromptH/2;
GUI.BeginGroup(Rect (halfScreenW-halfPromptW, halfScreenH-halfPromptH, winPromptW, winPromptH));
Application.LoadLevel("gameEnd");
GUI.Box (Rect (0,0,winPromptW,winPromptH),"Winner!!");
//====================================================
//Play again button disable on this screen
//====================================================
//if(GUI.Button(Rect(10,40,80,20), "Play Again"))
//{
//Application.LoadLevel("Title");
//}
GUI.EndGroup();
}
//======================================================= Code Block end
Answer by Graham-Dunnett · Jul 06, 2012 at 12:27 PM
With mobile development you must use typing on all your variables, otherwise it can cause your mobile game to run very slowly as the runtime tries to work out the datatype for each object. You should have a pragma strict at the top of your source code. This tells the compiler to complain when you have not typed your variables.
Slicing means accessing the elements of an array. One of the variables you have you are treating as an array, but the compiler does not think the variable is an array. I suspect when you add the pragma strict to your code you'll get many more warnings and errors before the code compiles.
Your answer
![](https://koobas.hobune.stream/wayback/20220613073740im_/https://answers.unity.com/themes/thub/images/avi.jpg)