public override void OnInspectorGUI()
    {
        IapProductData productData = (IapProductData)target;

        serializedObject.Update();

        EditorGUILayout.LabelField(new GUIContent("Product ID:", "Select a product from the IAP catalog"));

#if UNITY_PURCHASING
        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(productData.productId) ? 0 : m_ValidIDs.IndexOf(productData.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();
        }
#else
        m_ProductIDProperty.stringValue = string.Empty;
        var defaultColor = GUI.color;
        GUI.color = Color.red;
        GUILayout.Label("You must install Unity Purchasing");
        GUI.color = defaultColor;
#endif

        DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" });

        serializedObject.ApplyModifiedProperties();
    }
Пример #2
0
        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();
        }
Пример #3
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();
        }
 void OpenCatalog()
 {
     ProductCatalogEditor.ShowWindow();
 }