- Home /
Is there a shared class/interface between Graphic components and Canvas Groups?
I'm making a component that can control the alpha on any graphic components or canvas groups. I'd like to just have one serialized field which can accept both types of these components, i.e. one field that accepts any component with an "alpha" value. Is that possible? If not, what would be the best way of handling this?
Answer by SlowCircuit · Jun 10, 2018 at 04:13 AM
No.
You can see here: https://docs.unity3d.com/ScriptReference/CanvasGroup.html And here: https://docs.unity3d.com/ScriptReference/UI.Graphic.html
At the top under the name you can see what class they inherit from and you can click on those to see what class they inherit from as well.
As far as I know there's no way to have one field only that can accept both of those components. You may just need to use two.
Yeah I looked at those, I was just wondering if there might have been a shared interface between them that I could have used for this purpose. I guess not