Quantcast
Viewing all articles
Browse latest Browse all 959

Answer by Graham Dunnett

`GetComponent()` returns a `Component`. That's a Unity base class. When you create a script, it inherits from `Component`. The script you create has extra members, of course, so, in your example, it looks as though your script has a member called `isBuild`. When you use `GetComponent()` to find your script, you can do: var s : YourScript = g.GetComponent(YourScript) as YourScript; if (s.isBuild) { //blah This grabs the component, and casts it to `YourScript`, which has the `isBuild` member. Alternatively you can use the generic version: var s : YourScript = g.GetComponent.(); if (s.isBuild) { //blah which does the exact same thing. Obviously you'd check that `s` has a value before using it.

Viewing all articles
Browse latest Browse all 959

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>