Now that everything else is working, I need to pull the level from the button name and call that row from the spreadsheet.
Annoying thing I just discovered. Prefabs for buttons, where you add the script in the scene that it needs – they don’t work, bc the prefabs are outside the context of the scene. To have that work, I think I’d need it just be attached scripts, bc that works. Maybe I’ll consider switching my buttons to not really use the button functions that are context-dependent, and just do added script components.
Lol silly indexing problem. Button #1 is taking it to row, which is actually row 2. I guess I need to subtract one from it?
Make audio present or absent based on type of scene
Okay, so in PuzzleBot, here are the ways that audio interacts:
- In NameButton.GoOneLearn() (which is attached to the main camera and called upon click inside the button component): public void GoOneLearn()
// change GM instance audioList & score to be the ones you want in that level
GameManager.instance.scoreValue = 5;
This requires that there is a thing in GameManager called audioList. Let’s go look at that.
- GameManager only has thing thing, setting up audioList but never using it.
- public List<string> audioList = new List<string>();
Okay, so what script winds up calling audioList? Is it PlaySound?
Nope, PlaySound doesn’t’ call it.
Ahhhhh – it’s in PlayerCoroutine. Because PlaySound isn’t even attached to those objects!!!! WHOAH CRAZY. PlayerCoroutine() is attached to each of the objects that should (or shouldn’t) make sounds. And it’s not that no sound is attached – it actually attaches and plays a blank sound. This feels like a hack but whatever 😉 Keep things consistent. (Maybe come back and look at it #todo).
TextMesh onsetText = gameObject.GetComponent<TextMesh>();
AudioSource audioSource = gameObject.GetComponent<AudioSource>(); // script doesn‘t like this for ones where it‘s not there
if (audioSource == null) // consider just adding audio to game components at beginning of game? not sure there‘s a diff
audioSource = (AudioSource)gameObject.AddComponent<AudioSource>();
audioSource.clip = Resources.Load(“Sounds/“ + onsetText.text) as AudioClip;
audioSource.clip = Resources.Load(“Sounds/blank“) as AudioClip;
Ohhh okay. In Vowel Teams, the script on the menu buttons is called ButtonLoadScene.Propogate()
Interesting. Now my Check answers button is broken. I bet this is because I deleted a damn prefab. Hmm… actually it just looks like it’s because something got confused with the text showing up in front of that button and in front of the Answers buttons. It was working at enabling and un-enabling the mesh renderers, it’s just the z scales were off. I wonder if it’s something to do with how I redid any of the prefabs? It really shouldn’t have broken those, but I fussed with the text z scale and that didn’t fix it, and then I ALSO fussed with button z scale, and that DID fix it. Weirdly, I think I only fussed with the CheckButton z scales, and when those got fixed, so did the answer buttons. Huh. Let’s keep an eye on that. #todo (And maybe come back and confirm that that’s done right.)
Okay, so I moved the thing adding audio onto the GetButtonLevel() which is attached to the button scripts, so that I can use tags on the buttons to indicate which one should have which audio.
It’s not perfect, but I’ve got everything set up now.