Category Archives: Uncategorized

Instantiate buttons based on txt file

I’ve done this before, but don’t remember where.

https://docs.unity3d.com/Manual/InstantiatingPrefabs.html

http://answers.unity3d.com/questions/18219/instantiate-prefab-with-c-script.html

https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

 

As child of canvas:

http://answers.unity3d.com/questions/1226961/instantiate-prefab-from-script-inside-a-canvas.html

Hmph. Something has been going wrong with how I tried to do this, so I gave up. I want to come back to this later. #todo

 

Okay, coming back to this on 9-21-17. Maybe I can figure this out today, I feel like I need a problem to solve.

 

Build numbers

Huh, I had never changed my build number before!

https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html#//apple_ref/doc/uid/TP40011225-CH33-SW9

It’s literally input box #4 on Xcode. Cool, that’ll help me!

Making canvas UI elements look good

So I’m struggling with my canvas elements cuz they come out the wrong size and the wrong place. This has been affecting my menus, but more importantly, my  Check Asnwer button now ovelraps with other things, and it looks bad.

WHOAH just change the canvas scaler on each of the scene’s canvases from Pixel relative to Screen Size relative and then everythign is fixed.

https://docs.unity3d.com/Manual/script-CanvasScaler.html

 

YAYYYY

Fixing GameManager

Right now I’m having this annoying thing happen where the ShortLongA scene works when it’s opened by itself, but it doesn’t work when it goes through the Menu button.

Specifcially, the gamemanager instance isn’t finding the CheckHideButton and the CheckHideText automatically. That means it’s somewhere in a script that’s not getting activated by the menu button, but IS getting activated when the program starts.

OOH maybe it’s in Awake? How does Awake work exactly, is it for the scene or .. hmmm…

Yes I think it is! I’ts in the Awake in gthe game amnager, and that only happens once in the game (I think…?)

I added the defining of the CheckButton and text to the Propogate Scene script, and that fixed it.

YAY!

ALthough now I seem to have a problem with my login. I think that’s because it didn’t have a GM loader? Yup, adding the GM loader fixed that too. Cool!

Add username and password

So for this, I don’t have a server background yet. I’m just going to embed it into my unity stuff.

I’ve got it so that it works by using InputField, but I have the following questions:

  • how do I make it so it only has to log in once
  • is there any way to make it so they don’t have to log into every app on every ipad? this feels annoying & sad, and would really detract from teachers being able to use it
  • is there any way to keep the login info on new version

Things I’m looking at

  • https://gamedev.stackexchange.com/questions/135915/unity-5-input-field-how-to-confirm-password-entry-with-enter-only-and-not-a

Maybe I’d rather have something like this:

https://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html

If there’s a unique identifier on each ipad, then I can actually control how many ipads are using my app, and know which ones are…

BUt  now that I’m thinking about it while writing the code … // this confirms that its a specific ipad using the app  this ... wont work bc it wont get past the app store

Hmph.

http://www.assistiveware.com/support/faq/page/50

One thing I could do is just put my templates on the app store, and put everything else on TestFlight. I don’t know how that works with the auto updating thing the school has, but it could sidestep this annoyance.

Looks like I can at least only login once per ipad. Not sure how th is would work for updated versions, or the fact that I’m planning on having multiple apps :/

http://answers.unity3d.com/questions/1272349/load-different-scene-on-first-load.html

It would probably be a good idea for me to get a second ipad at some point and set it up to download the way the school does, so I can test these things out #todo

 

Make it so only audio gets built that is needed

Now that I’ve started putting my projects together (which makes life SO MUCH BETTER at least for now), I run the risk of making everything unnecessarily large by including all of the audio in any individual build.

This is bc Unity auto includes anything under the Resources folder.

Apparently you can rename folders to have ~ first but that seems to have mixed reviews on forums.

https://forum.unity3d.com/threads/excluding-folders-from-build.408375/

First I need to separate out audio by which app it’s in, and then script to go to that specific folder inside Resources instead of just Resources.

 

 

Answer colliders for ShortLongA

Now I need some sort of feedback system for ShortLongA. It shouldn’t be a show/hide button like in Vowel Teams, but instead some sort of thing where it lists how many need to be changed, or circles them (but then it’s just move it to the other one … might still be worth it).

Excited to usertest the answer feedback function in this.

In my heart of hearts, I really want a recording feature for the hard mode, where kids then record their own reading of the word. But this is going to require some significant backend. There’s an inbetween version where then they compare their recording to the right answer, but that could be tricky without a tutor and without it saved somewhere for teachers to look at / use.

 

Standardize across game templates

So now that I have pulling in the .txt file variables working, I need to tell it which  .txt file to bring in.

So far I’ve done this by adding a gameobject to each scene named & tagged “SceneType”. It has a textmesh component with the rendering turned off, and the name of the .txt file in it.

This way, for any given scene, it can still have the same scripts attached to it, and it finds the correct .txt

Note – I have it done pretty redundantly right now. There are 2-liners pulling this in in the exact same way in the following scripts:

  • GameManager.InitGame()
  • WordDictAdd.SetUp()
  • WordDictAdd.CreateObjects()
  • LoadEasyMode.Propogate()
    • [which, should be noted, should also switch names etc. #todo]
  • GoMenuVowelTeams.MainMenu()
    • [#todo also should change names]

GameManager.InitGame() is my first attempt to make this so it doens’t have to be repeated.

Hmm. So this isn’t working as smoothly as I wanted it to. This might be a good instance to run it by Joao.

A thing I’d also like to know is if making an empty game object with a non-rendered textmesh that tags the scene is the way I’m supposed to do it.

Ooh – apparently there’s multi-scene editing, that sounds nice.  #todo

https://docs.unity3d.com/Manual/MultiSceneEditing.html

Some interesting food for thought around using names and stuff:

  • against:
    • https://akbiggs.silvrback.com/please-stop-using-gameobject-find
  • pro
    • https://www.reddit.com/r/gamedev/comments/3t74w4/unity_devs_should_stop_using_gameobjectfind/

#todo – I could have the same menu scene for everything, but I’m not sure that’s worth it right now. It feels like it would make it hard to make builds and my energy really isn’t going into menu stuff right now. Eventually maybe.

Add in sounds depending on easy/hard mode:

  • right now this mainly happens in GetButtonLevel, where it checks if it has an easy tag, and if so, adds sounds
    • complication: for VowelTeams, answers is always in there. (this could just be a standardized thing I have, where anything tagged answers is always there…)
  • It also happens in GameManager.Awake() so that any scene I start with will have sounds without having to go through the menu

This makes me think I want to have this information embedded into my text file, so that I don’t have to individually specify it every time.

 

Use .txt column variables in scene

Command R replaces everything in the script. Exit to cancel, enter to keep.

Now I’m working on automating pulling in the column names, creating the things they need from those, and inserting htem into everything. This is basically WordDictAdd.SetUpOnsets. I want this for a couple reasons – 1, the script was super repetitive. 2, making new templates with this system is a real pain, and involves an annoying amount of manually find&replacing. Feels like I shouldn’t need a python script to do this, I can do it inside C# Unity itself.

Okay – so first goal – bring in the names of the columns and return them.

Done.

Now:

  • name GameObject[] sets using the string
    • This is a little tricky.
    • http://answers.unity3d.com/questions/247517/c-gameobject-lists.html
    • OH – I don’t need to name them separately. They’re just object sets. They don’t need the name embedded the way they do in the hard code.

To fix:

Turned off InitGame SetUpOnsets in several places (Propogate on the main camera, and also in GameMnaager when it starts)

I also took out the level name, which is a real pain. So now I should go back and add in the level name but make it so it skips it in the set

 

Random thoughts on how to do more specific feedback in the future:

  • have a set of answer objects in each slot, that get filled in by the Reader, to have the textmesh of the right answer block
  • then, if they are currently colliding with something that has the same textmesh, they are correct. (tehy can be colliding with more than one thing – if there is a correct thing colliding with them, it works) – #todo – the only problem with this is this feasibly could have them out of order but marked as correct -play around with this

Okay, so now I’ve got it working for VowelTeams.

I’ve imported ShortLongA scene to see how this can translate. A thing I think I now need to do is to tag each scene with which .txt file it uses, so I can use the same gameManager prefab. This wouldn’t be necessary if it weren’t in the same project, so I should consider this. I’m pretty sure it’s better to be in the same project tho so that if I change any of the main scripts, they’re always changed, instead of having so many versions of them runn

 

Fix up button levels

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[1], 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()
        {
            SceneManager.LoadScene(1Learn);
            //1014-16
            // change GM instance audioList & score to be the ones you want in that level
            GameManager.instance.audioList.Add(Onset);
            GameManager.instance.audioList.Add(Ending);
            GameManager.instance.audioList.Add(Answer);

            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).

void PlayAudio()
    {
        

        TextMesh onsetText = gameObject.GetComponent<TextMesh>();
        AudioSource audioSource = gameObject.GetComponent<AudioSource>(); // script doesnt like this for ones where its not there 

        if (audioSource == null) // consider just adding audio to game components at beginning of game? not sure theres a diff 
        {
            audioSource = (AudioSource)gameObject.AddComponent<AudioSource>();
        }

        if (GameManager.instance.audioList.Contains(gameObject.tag))
        {
            
            audioSource.clip = Resources.Load(Sounds/ + onsetText.text) as AudioClip;
        }
        else
        {
            audioSource.clip = Resources.Load(Sounds/blank) as AudioClip;
        }

        audioSource.Play();

    }

 

 

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.