Creating A Search Callback System in Unity

With the ability to put our list data into our buckets in place, now we have to look at how we are able to retrieve that information to be able to search for a case. To start, we will need to create a new method within our AWSManager:

Again, to get all of this information, we are able to just follow along with the documentation that is provided to us from AWS. What we have done is called upon the S3Client and asked for the list of cases that we have created. As for the name of the file, we are using the Key.
From here, we need to call this method, so we will call upon it within our ProcessInfo method within the search panel script:

For just testing purposes, we are just going to place the 55 in there and check to see if this part of our script works before we continue on with the next portion:

As we can see, once we hit the search button, we get our debug logs with all the different case numbers that we currently have within our bucket.
Now that we have implemented the process in which we can call upon all the different cases, let’s take a look at how we can go about calling a specific report. As for how we can pull the number, we have a couple different ways we can go about searching for the specific case. First, we can continue with what we have built:

Quick addition of caseNumberInput.text

What we have done is created a target for our key to be that is requested by the user in the input field. From here, if the object is found, we have our debug.log letting us know a case has been found:

Upon searching for the specific case number, we get our log report to show up. However, we are using up extra resources by searching through all of the various case files. With it only having a couple right now isn’t too bad, however if there were hundreds or thousands of cases to search through we would be using up a lot of resources in just searching.
So to fix this, we are going to implement the Linq library into our code:

What this will allow us to do is search through the whole list and give the result based on a true or false statement. This creates a much less resource intensive method than before:

Now that we have this method changed around a little, let’s see if it works in our program:

Now that we have the ability to find a specific case, let’s find out how we can go about and download that info into our app:

For the first step, we are going to start by checking if there is a response to our stream. Once we have that response, we want to use a stream reader to read our data, as when we converted it before, it is in a state that we can’t read. From there, we are going further into the chain to access the memory stream, and then we are reading the bytes of the file. Finally, we are reversing the serialization process we did earlier to be able to read what the data is that we want:

As we can see, upon searching for case #222, we are able to see what the name of that case is within our console. Now that we know that pulling the case file information works, we need to store the information into our UIManager. We will add a quick line of code to the end of the “using (MemoryStream…)” to be able to populate the fields within the UIManager:

From here, we can test it within our application:

Now that we have this set up, let’s finish up a few small parts to finish off the search of the file case. Upon successfully getting a case, we will move to our next panel which will bring up the data of the case:

From here, we can test it in the application and see if linking it to the overview review panel works, or we need to make a few tweaks:

There we have it. We managed to successfully pull the information from our bucket and we are able to view all of the information that we submitted from the case. With this finished, we can make some minor touch ups to parts to have it more polished. Other than that, we have finished this small little project and we can take a look into how we can utilize Unity Analytics.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store