Skip to main content
semicolon..
Source Link
Katu
  • 2.1k
  • 1
  • 15
  • 19

You have to cast it to ClientValues type.

var cSharpScript = (ClientValues)gObject2.GetComponent("Clientvalues");

or

var cSharpScript = gObject2.GetComponent("Clientvalues") as ClientValues;

First one causes runtime error if cast fails and the second one returns null if it fails. Important difference. But both should do the trick.

You have to cast it to ClientValues type.

var cSharpScript = (ClientValues)gObject2.GetComponent("Clientvalues")

or

var cSharpScript = gObject2.GetComponent("Clientvalues") as ClientValues;

First one causes runtime error if cast fails and the second one returns null if it fails. Important difference. But both should do the trick.

You have to cast it to ClientValues type.

var cSharpScript = (ClientValues)gObject2.GetComponent("Clientvalues");

or

var cSharpScript = gObject2.GetComponent("Clientvalues") as ClientValues;

First one causes runtime error if cast fails and the second one returns null if it fails. Important difference. But both should do the trick.

Source Link
Katu
  • 2.1k
  • 1
  • 15
  • 19

You have to cast it to ClientValues type.

var cSharpScript = (ClientValues)gObject2.GetComponent("Clientvalues")

or

var cSharpScript = gObject2.GetComponent("Clientvalues") as ClientValues;

First one causes runtime error if cast fails and the second one returns null if it fails. Important difference. But both should do the trick.