protected override void Start() { base.Start(); this.iapButton = this.gameObject.GetComponentInChildren <IAPButton>(); iapManager.OnGrantEvent.AddListener((grant, fromLocal) => { if (GameContext.IsNavigationEnabled && this.IsActive) { this.SelectDefault(); } if (activeGrantRequest.IsValid() && activeGrantRequest.Equals(grant)) { this.IAPConfirmed(); } }); iapManager.OnGrantFailedEvent.AddListener((grant, reason) => { if (GameContext.IsNavigationEnabled && this.IsActive) { this.SelectDefault(); } if (activeGrantRequest.IsValid() && activeGrantRequest.Equals(grant)) { this.IAPError(reason); } }); }
private static void ApplyEditorHack(this IAPButton button) { #if UNITY_EDITOR if (button.priceText != null && !button.priceText.text.StartsWith("$")) { button.priceText.text = "$" + button.priceText.text; } #endif }
private static void ApplyAndroidHack(this IAPButton button) { #if UNITY_ANDROID && !UNITY_EDITOR var str = button.titleText?.text; if (str?.Contains("(") == true) { button.titleText.text = str.Substring(0, str.IndexOf("(", StringComparison.InvariantCulture) - 1); } #endif }
public Texture2D getIAPButtonTexture(IAPButton iapButtonType) { if (Soomla.Store.StoreInventory.GetItemBalance((iapButtonType == IAPButton.MoreSmokeBombs ? "more_smokebombs" : "unlock_all_levels")) == 0) { return(iapButtonDictionary [iapButtonType]); } else { return(iapButtonInactiveDictionary [iapButtonType]); } }
static void CreateUnityIAPButtonInternal() { GameObject buttonObject = CreateButtonObject(); if (buttonObject) { IAPButton iapButton = buttonObject.AddComponent <IAPButton>(); if (iapButton != null) { UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); UnityEditorInternal.ComponentUtility.MoveComponentUp(iapButton); } } }
public static void ApplyPlatformHacks(this IAPButton button, bool update = true) { if (update) { var method = typeof(IAPButton).GetMethod("UpdateText", BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) { Debug.LogError("Missing UpdateText Method"); } else { method.Invoke(button, null); } } ApplyAndroidHack(button); // ApplyEditorHack(button); // this gets confusing after a while. }
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 static bool HasProduct(this IAPButton button) { return(IsReady() && CodelessIAPStoreListener.Instance.HasProductInCatalog(button.productId)); }
public static Product GetProduct(this IAPButton button) { return(GetProduct(button.productId)); }