So I’ve narrowed down what’s failing. When the user clicks on the screen for the first time, this gets executed:
AddDice(3, 6); // Add 3d6
It’s relatively simple function (the two parameter version simply adds a default to the materialIdx):
private void AddDice(int count, int faces, int materialIdx)
{
int dieIdx = -1;
for(int i = 0; i < diceFaces.Length dieIdx == -1; i++)
{
if (diceFaces[i] == faces)
dieIdx = i;
}
if (dieIdx != -1)
{
Transform dieModel = diceModels[dieIdx];
for(int i = 0; i < count; i++)
{
Transform die = (Transform)Instantiate(dieModel, transform.position, Quaternion.identity);
die.parent = transform;
die.gameObject.name = "D"+faces;
// Change the material
DieController c = (DieController)die.GetComponent(typeof(DieController));
c.ChangeMaterial(materialIdx);
SpawnDie(die);
}
TurnDieSoundOnOff(soundOn);
}
}
Where diceModels is an array of transforms, and is filled with a list of prefabs.
What’s crashing here is the Instantiate of dieModel, but only if called soon after start up on a Radeon X1600, on the standalone Mac player, on anything above Simple quality. The quality settings change sent me on a wild goose chase for a while, and I spent some time tweaking with the shadows, lights and anti-aliasing, but it’s neither that nor the shaders. If I don’t instantiate the default dice at load time (commenting out that line), but instead load up with an empty slate then add them through the UI (which calls exactly the same method), everything works fine on the X1600/standalone Mac player combo.
This got me thinking that maybe some resources weren’t being loaded properly on that specific combo. When discussing initially about resource instantiation I was told to reference everything by Transform and Material arrays, since that way Unity knew when to load them. Otherwise, if I attempted to do it by name, I’d have to stick everything in a Resources folder so that they were loaded before the app runs. With that in mind, I tried to stick everything in the Resources folder. No dice.
Skipping ahead a couple of steps, I did find a workaround - instead of referencing the dice models, I created an array of references to the DieControllers, and then do the instantiate based on the DieController’s game object. That’s a change I was moving towards for other reasons (it saves me from using the array with the number of die faces, plus a couple calls), but seems to have helped with this as well.
I’m a happy man - it seems to work now on X1600, on whatever quality setting. Now, if anyone can explain to me why the other code works in most cases except with Radeon X1600/standalone mac player, I’d be delighted.