- Home /
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 done...is it supposed to??
Debug.Log( "received total products: " + allProducts.Count );
_products = allProducts;
};
if(_products.Count>0)
{
//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;
}
}
else
{
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;
StartCoroutine(Wait(time));
//here I show my form
showIAPForm();
Debug.Log("LoadingForm");
Thanks for the help guys!
Answer by RFLG · Aug 13, 2012 at 09:58 PM
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!
I am having the same issues too. Users can navigate out of the store area before the purchase is complete and therefore leave the area where the storekit scripts were being ran.
For clarification, I am guessing you basically don't allow the user to do anything until a purchaseSuccessful or purchaseFailed event occurs, right?
i get this plugin am i have to make change only storkitguimanager.cs? or other files too? unity3diy
Well Nabeel, it really depends on what you want to do. I wrote a small article about In-App purchases with and without Prime31's plug-in on our tech blog. It covers most of what you can and can't do, and also some pointers on how to do some operations. You can read it here: http://wecamefrommars.tumblr.com/post/63176938499/implementing-in-app-purchases-with-unity3d
Your answer
Follow this Question
Related Questions
Bug with EtceteraGUIManager.cs . 1 Answer
Game crashed on IOS 0 Answers
Distribute terrain in zones 3 Answers
iOS Plugin - Pass a struct from C++ to C# 1 Answer
Dll distribution of Conditionally Compiled project 0 Answers