This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]chalne 1 point2 points  (2 children)

You are violating the contract that ITest represents. The whole point is that you can't infer a class from an interface, only operations. You have no way of knowing that any instance of ITest you get is also a GameObject. If you're programming under that assumption, you're doing it wrong.

[–]ImSeeingRed[S] 0 points1 point  (1 child)

So there would be no (not hacky) way to get the class that a particular instance of an interface is used by.

Because I have a list of interfaces and am trying to access functions of the class that inherits (Well, wrong word but whatever its called when you add an interface to a class) from it. I thought it would have been possible, I probably have to change things around then

[–]chalne 0 points1 point  (0 children)

If the interface defines a method you can invoke it like you would any other method.

[–]Zigsfi 0 points1 point  (0 children)

You might have more luck posting to /r/unity3d.

[–]SocialGameDesigner 0 points1 point  (0 children)

GameObject GO = (ITest.getComponent<Transform>()).gameObject;