How to use GUI for IAP
I can not seem to find an answer, anywhere for this, so i will make my question as detailed as possible.
I have a game in Google Play, already launched. In my game i use GUI in every scene, i do not use normal UI. I am new to learning about IAP in Unity and i have been through a lot of documentation from Unity and other sources. I want to know the process of how to do this through GUI.
Example: If i were to make a currency (in C#, int || float) and then make a button in GUI.
.
//Code
public static int Gems = 0;
void OnGUI(){
if (GUI.button(new rect(1, 1, 1, 1), "Purchase 50 Gems")){
//What would i add here to activate the IAP?? so the user can then purchase the Gems?^^
}
}
I hope this makes sense to people and thank you to any one who tries to help.
Answer by DemonGamesLab · Jul 26, 2017 at 08:05 PM
!!FOUND THE ANSWER MY SELF!!! For anyone who is having the same issue, here is a link to explain all the code easily. And will show how to activate it from anywhere in script. https://www.youtube.com/watch?v=3IQ-CvBQz0o&t=744s
Answer by UnityCoach · Jul 26, 2017 at 09:04 AM
Hi,
Unity IAP isn't only about code, there are a few things to setup, the code is quite simple.
Here's a link to the "code less IAP" documentation.
It'll take you through the whole process.
Note it doesn't use OnGUI, but rather use Unity UI features.
Thats my issue, i dont want to use the codeless IAP, i want to use OnGUI as i am more than familiar with it. I even tried copying multiple youtubers in a test project and still couldent understand it all. Everywhere i look it says its simple, and i wouldent say im a dumb person. But its very confusing. I will check the link anyway as im always open to new info, but i still need / want to know how to do this using the OnGUI function
Edit Also, the things to set up i know how to do, like turn the services on and import the plugins etc, and to test it you need to make an apk and upload it on google play to test it, in dev mode etc. The bit that stops me is going from the point the user clicks to what code i should enter to make it all happen. (Trying to give you as much detail as possible). And thank you for taking your time to help.
Your answer
Follow this Question
Related Questions
How to change GUI label size 1 Answer
Loading Game Crash 1 Answer
Multiplayer Hiding Layer just for Local Player 0 Answers
EditorGUILayout.ObjectField and array 0 Answers