Home>

Created a variable in the superclass, assigned to itAudioSoursein the inspector.

[Serialize field] private

In a child class, I'm trying to use a variable likeAudioSoursebut requires you to drag the componentAudioSourseto the object to which the child script is attached.

What to write so that it inheritsAudioSoursefrom superclass?

Just wondering: what is a superclass? Base class?

aepot2022-01-01 19:57:09

apparently the field shouldn't be private, shouldn't it?

Алексей Шиманский2022-01-01 19:57:09

No, he simply does not understand the meaning of the word class instance and thinks that if he serialized a field in a superclass instance, it must have the same reference for all descendant instances (as would be the case with a static one). I literally messed up everything that is possible and that's a mess in my head.

Yaroslav2022-01-01 19:57:09

What you assigned in the inspector belongs only to this instance of the component. The inheritor cannot use the private fields of the base class in any way. What to do? Learn the basics of the language!

Yaroslav2022-01-01 19:57:09