public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { PurchaseProcessingResult result; // if any receiver consumed this purchase we return the status bool consumePurchase = false; bool resultProcessed = false; for (int i = 0; i < activeButtons.Count; i++) { if (i >= activeButtons.Count) { break; } IAPButton button = activeButtons[i]; //foreach (IAPButton button in activeButtons) // { if (button.productId == e.purchasedProduct.definition.id) { result = button.ProcessPurchase(e); if (result == PurchaseProcessingResult.Complete) { consumePurchase = true; } resultProcessed = true; } } foreach (IAPListener listener in activeListeners) { result = listener.ProcessPurchase(e); if (result == PurchaseProcessingResult.Complete) { consumePurchase = true; } resultProcessed = true; } // we expect at least one receiver to get this message if (!resultProcessed) { Debug.LogError("Purchase not correctly processed for product \"" + e.purchasedProduct.definition.id + "\". Add an active IAPButton to process this purchase, or add an IAPListener to receive any unhandled purchase events."); } return((consumePurchase) ? PurchaseProcessingResult.Complete : PurchaseProcessingResult.Pending); }
public override void OnInspectorGUI() { IAPButton button = (IAPButton)target; serializedObject.Update(); EditorGUILayout.LabelField(new GUIContent("Product ID:", "Select a product from the IAP catalog")); if (validIDs == null) { var catalog = ProductCatalog.LoadDefaultCatalog(); validIDs = new List <string>(); validIDs.Add(kNoProduct); foreach (var product in catalog.allProducts) { validIDs.Add(product.id); } } int currentIndex = string.IsNullOrEmpty(button.productId) ? 0 : validIDs.IndexOf(button.productId); int newIndex = EditorGUILayout.Popup(currentIndex, validIDs.ToArray()); if (newIndex > 0 && newIndex < validIDs.Count) { button.productId = validIDs[newIndex]; } else { button.productId = string.Empty; } if (GUILayout.Button("IAP Catalog...")) { ProductCatalogEditor.ShowWindow(); } DrawPropertiesExcluding(serializedObject, excludedFields); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { IAPButton button = (IAPButton)target; serializedObject.Update(); if (button.buttonType == IAPButton.ButtonType.Purchase) { EditorGUILayout.LabelField(new GUIContent("Product ID:", "Select a product from the IAP catalog")); var catalog = ProductCatalog.LoadDefaultCatalog(); m_ValidIDs.Clear(); m_ValidIDs.Add(kNoProduct); foreach (var product in catalog.allProducts) { m_ValidIDs.Add(product.id); } int currentIndex = string.IsNullOrEmpty(button.productId) ? 0 : m_ValidIDs.IndexOf(button.productId); int newIndex = EditorGUILayout.Popup(currentIndex, m_ValidIDs.ToArray()); if (newIndex > 0 && newIndex < m_ValidIDs.Count) { m_ProductIDProperty.stringValue = m_ValidIDs[newIndex]; } else { m_ProductIDProperty.stringValue = string.Empty; } if (GUILayout.Button("IAP Catalog...")) { ProductCatalogEditor.ShowWindow(); } } DrawPropertiesExcluding(serializedObject, button.buttonType == IAPButton.ButtonType.Restore ? restoreButtonExcludedFields : excludedFields); serializedObject.ApplyModifiedProperties(); }
public static void CreateUnityIAPButton() { // Create Button EditorApplication.ExecuteMenuItem("GameObject/UI/Button"); // Get GameObject of Button GameObject gO = Selection.activeGameObject; // Add IAP Button component to GameObject IAPButton iapButton = null; if (gO) { iapButton = gO.AddComponent <IAPButton>(); } if (iapButton != null) { UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); } }
public void RemoveButton(IAPButton button) { activeButtons.Remove(button); }
public void AddButton(IAPButton button) { activeButtons.Add(button); }