Skip to content

playjoa/Unity-IAP-System-With-ScriptableObject-Products

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Unity-IAP-ScriptableObject-Products

- Obs: Tested with "com.unity.purchasing": "3.2.3"!

Easily create custom products

  • Make your custom type of product!
  • Easily create custom views for your products to be displayed in game!
  • Full IAP Controller.

Edit Product Data in Inspector

1

Initialize the controller in StartUp Screen

1

Create your custom views to display in game

1

Create any type of products

namespace IAP_System.Base.Products
{
    [System.Serializable]
    [CreateAssetMenu(menuName = "IAP Custom Product", fileName = "New Custom IAP Product")]
    public class MyCustomIAPProduct : InAppPurchaseProduct
    {
        public override string ProductQuantityText => "$ " + productQty;

        public override void AwardPlayer()
        {
            Debug.Log($"Add {productQty} to my custom product type");
        }
    }
}

Customize your IAP products

namespace IAP_System.Base.Products
{
    public abstract class InAppPurchaseProduct : ScriptableObject
    {
        [SerializeField] protected string productKey = "myGame500Coins";
        [SerializeField] protected ProductType productType = ProductType.Consumable;
        [SerializeField] protected string productName = "500 Coins";
        [TextArea] public string productDescription = "Get 500 coins";
        [SerializeField] protected int productQty = 500;
        [SerializeField] protected Sprite productSprite;
        
        public virtual string ProductKey => productKey;
        public virtual ProductType ProductType => productType;
        public virtual string ProductName => productName;
        public virtual string ProductDescription => productDescription;
        public virtual int ProductQuantity => productQty;
        public virtual string ProductQuantityText => productQty.ToString();
        public virtual Sprite ProductSprite => productSprite;
        public virtual string ProductNicePrice => IAPController.ME.GetPrice(this);

        public virtual void BuyProduct() => IAPController.ME.BuyProductID(this);
        public abstract void AwardPlayer();
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages