js to C# - Instantiate(scoreParticle, object - Vector3(0,0,0.3), Quaternion.identity)

Hi! need help to js to C# convertion

Jscript code:

#pragma strict
#pragma implicit
#pragma downcast

private var object:Vector3;

var scoreParticle:GameObject;

function Update()

{

var minusScore=Instantiate(scoreParticle, object - Vector3(0,0,0.3), Quaternion.identity) as GameObject; //instantiate scoreParticle

minusScore.renderer.material=score10; //give material to scoreParticle

minusScore.renderer.material.color = color;//give ball's color to scoreParticle

}

You should rename object and keep in mind that the result of instantiate (like what you did) can only be casted to the type that you declared for your prefab on top.

public class YourScriptFileName : MonoBehaviour
{
private Vector3 objPosition;
public GameObject scoreParticle=null; //null is required to eliminate warning 649

void Update()
{
var minusScore = Instantiate(scoreParticle,objPosition - new Vector3(0,0,0.3f),Quaternion.identity) as GameObject;
minusScore.renderer.material = score10;
minusScore.renderer.material.color = color;

}
}

var keyword in C# is different, it will not declare a dynamic variable and like your #pragma strict js codes, it always disallow converting a variable to another type, it just tells the C# compiler to see the type of the variable in the return type of the expression in front of it. Oh did i sounded to technical? The variable will have the type of the result of the Instantiate and the cast.