I am using inheritance (C#) with a base class that has
and I want my subclasses to be able to use temp, but whenever i try to use temp i get this error
But this works. But if I replace Debug.log with the base class object it errors.
You can use the generic version of GetComponent() instead, e.g.:
However, I don't think you can use Unity API functions such as Find() in field initializers or constructors (or at least you're not supposed to). Instead, you should perform initializations of that sort in Awake() or Start().
Not sure what you mean about the Debug.Log() part.
answered Feb 17 '11 at 01:02 PM