Exemplo n.º 1
0
    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);
            }
        });
    }
Exemplo n.º 2
0
        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
        }
Exemplo n.º 3
0
        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]);
     }
 }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        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.
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
 public static bool HasProduct(this IAPButton button)
 {
     return(IsReady() && CodelessIAPStoreListener.Instance.HasProductInCatalog(button.productId));
 }
Exemplo n.º 10
0
 public static Product GetProduct(this IAPButton button)
 {
     return(GetProduct(button.productId));
 }