How to bind Prime31 ios storekit plugin with GUIText elements?

Hello everyone!

So, I’ve bought the storekit plugin from prime31, did a successfull implementation with all the items on the demo working and managed to get it working on my project also (sort of).

As I move into more complex scenarios, I’m incurring into a rather singular problem, for which I need your help.

I’m doing these operations on my code:

1-I want to fill a couple of GUIText objects with the product details. So I have a :Monobehaviour c# class where I handle all my GUI matters and where I call the StoreKit plugin.

2-So, I start by getting a List products from StoreKitManager.productListReceived, I then to all the required value assigning (from variables to the GUI controls).

3-Finally I make my “form” visible and was supposed to get the product data visible on the screen.

What really happens is that the form is returned blank…This is what I’ve debuged so far:

1-Added some Debug.Logs around to check if stuff was getting done. Confirmed that it is, so the connectability is working just fine, with product data being returned from the appstore.

2-Also detected that some debug.log are being printed only when execution ends, meaning that they are being printed way after their supposed execution point.

So my questions to you guys are:

1-Is debug.Log supposed to print immediatly upon call, or it may print with delay?

2-I’m left with the impression that for some reason there is a delay on the response from the appstore and unity just runs the rest of the code without waiting. Is this assumption correct? How can I fix it?

Below I’m sending a sample of the source code I’m using:

var productIdentifiers=new string[]{"myIdentifier"};
 StoreKitBinding.requestProductData( productIdentifiers );
 //Debug.Log( "In!! ");
 List<StoreKitProduct> _products=new List<StoreKitProduct>();
 StoreKitManager.productListReceived += allProducts =>
                    //this one only gets printed after everything else is it supposed to??
 Debug.Log( "received total products: " + allProducts.Count );
 _products = allProducts;
                    //this section is never hit
 Debug.Log("haz product");
 foreach(StoreKitProduct product in iapWrapper._products)
 IAPFormDesc.GetComponent<GUIText>().text="Product Description: "+ product.description;
 IAPFormName.GetComponent<GUIText>().text="Product Name: "+ product.title;
 IAPFormPrice.GetComponent<GUIText>().text="Price: " +product.price;
 IAPFormDesc.GetComponent<GUIText>().text="Product Description:" ;
 IAPFormName.GetComponent<GUIText>().text="Product Name: ";
 IAPFormPrice.GetComponent<GUIText>().text="Price: " ;

                    Debug.Log("no product?!");
 //I tried to make unity "wait" a while, but at no avail...
 float time=30.5F;

            //here I show my form

Thanks for the help guys!

Well, It’s kinda a silly answering myself, but I talked with the good people at prime31 and the problem was solved!

In order to share the knowledge, here goes the solution provided:

1-For my first question the answer was yes, Debug.Log is supposed to print right after it is called.

2-For my second question the answer was also yes, indeed the appstore sometimes takes it’s time replying to requests.

My problem was that I was separating the request/response process and the GUI/Form filling, making them different processes.

Following prime31’s advice, after using the events provided on the plugin and making the GUI changes fully dependant on the product request event, it’s working like a charm!