Hi,
I always get the error mentioned in the title when I try to assign a parent to an instantiated prefab:
var number = 777;
var showZero = true;
var digitSpacing = 0.0625;
var digitTextures: Texture2D[];
var digit3D: Transform;
var shaderMainTextureName = "_MainTex";
private var isShowing = false;
[...]
for (var i = 0; i < numberAsString.length; i++)
{
var newDigit = Instantiate(digit3D, Vector3(x, 0.0, 0.0),
transform.rotation);
newDigit.transform.parent = gameObject;
newDigit.renderer.material.SetTexture(shaderMainTextureName,
digitTextures[numberAsString[i]]);
x += digitSpacing;
}
[...]
The object this script is attached to is instantiated here:
var score = 0;
var scoreFormula = "(token * (token - 1)) * (colors / 4) * (multiplier)";
var multiplier = 1;
var colors = 4;
private var scorePosition: Vector3;
var number3D: Transform;
function AddScore(token)
{
var points = eval(scoreFormula);
score += points;
Debug.Log(score);
var points3D = Instantiate(number3D, scorePosition, Quaternion.identity);
points3D.GetComponent(Number3DBehaviour).number = points;
points3D.GetComponent(Number3DBehaviour).Show();
}
[...]
Does anybody know what’s wrong here? I’m probably too high on coffeine right now to see my mistake :~)