Hello, I have a “FILE” and “TextFile”, “ImageFile”, “AudioFile” and “VideoFile” as children to (inherit from) “FILE”.
“FILE” is abstract so I don’t add it to my objects, I add the other scripts, text, image, etc. - What I wanna do, is once I pickup a text/image/video/audio file, I wanna ‘get’ the text/image/video/audio file script/component and add it to another object I have elsewhere.
I tried something like this:
var fileScript = fileObj.GetComponent(typeof(FILE));
I think this gets it fine, right?
I mean, if fileObj had a TextFile attached, this should get me that component, because a TextFile is of type FILE (inherits from it - TextFile ‘is a’ FILE)… RIGHT?
But then how to add it to my other object? tried something like this:
but my guess is, is that the previous adds a new component, not the same one I picked/got from my fileObj, I wanna add the SAME one, how?
This also doesn’t work:
Some comments and clarifications if you can on the return types of GetComponent and the inputs of AddComponent are very much appreciated as well.
Thanks a lot.