|
I have a number of audio sources and they all have different volume. Initial idea was to find all sources with But later it appeared that if user sets slider to zero and then tries to set higher volume, volume stays zero. So I understood I need a variable to store initial volume and the formula will be As I didn't find easy way to add a public variable to AudioSource component, I decided to
add component AudioVolumeInitial.js (that contains only one line So here is piece of code from my AudioVolume.js. This piece is enough to demonstrate my problem.
This line is problematic one so far Anyway the best solution would be to find an easy way to get to the parent (that's what I want you to help me with). 2nd option is to attach component AudioVolumeInitial manually (boring, but I can do this if there no other way). And 3rd if I could just add one more public variable to AudioSource component (no idea how, help please). That's all there is. Thanks.
(comments are locked)
|
|
I managed to fix this with
(comments are locked)
|
|
Your problem is probably in line 5. If you set AudioVolumeInitial.initialVolume this won't affect the instance of the component you just created. Instead try this:
This is C# syntax, I don't use js so I'm not sure about the syntax there but the point is to store the return value of AddComponent as a AudioVolumeInitial component and use that to set the volume. No, in this everything seemed okay in JS.
Mar 01 '10 at 11:22 AM
Dima Antonov
(comments are locked)
|
