x


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
more ▼

asked Jul 05, 2012 at 02:18 PM

Nanco gravatar image

Nanco
1 3 2 2

Please format your code so it is readable.

Jul 06, 2012 at 12:11 PM Graham Dunnett ♦♦

There, I did it for you...

Jul 06, 2012 at 12:23 PM Graham Dunnett ♦♦
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 06, 2012 at 12:27 PM

Graham Dunnett gravatar image

Graham Dunnett ♦♦
21.5k 30 41 118

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x24
x21

asked: Jul 05, 2012 at 02:18 PM

Seen: 1774 times

Last Updated: Jul 06, 2012 at 12:27 PM