Does anyone here know how to extend a class and still be able to use the connection that you’re extending.
Let me explain… I’m trying to extend the TextAsset class.
class DynamicTextAsset extends TextAsset {
// Code Here...
}
But, if I assign a variable, I can’t connect a text file in the inspector. Is it possible to do this?
// I can't connect a text file to this one
var myDynamicTextAsset : DynamicTextAsset;
// But, I can connect a text file to this one
var myTextAsset : TextAsset;
I wouldn’t say that direct sub-classing isn’t recommended as a whole. I think the problem here is that the inspector doesn’t check whether you’ve sub-classed off of something it knows about, it only sees your variable as being a DynamicTextAsset and dragging a TextAsset on to that just won’t work as they’re not the same (again from the Inspector’s one-level deep point of view).
In short Nathan, I don’t think you can do a drag assignment in that case, but don’t fear sub-classing in general.
And I have been updated on just how wrong I am. You should not sub-class Unity’s built-in classes as that won’t work or will be problematic. You write and sub-class off your own classes, but not the built-in Unity classes like TextAsset. My apologies for the confusion.