public override void OnInspectorGUI() { IAPButton button = (IAPButton)target; serializedObject.Update(); if (button.buttonType == IAPButton.ButtonType.Purchase) { EditorGUILayout.LabelField(new GUIContent("Продукт ID:", "Select a product from the IAP catalog")); //var catalog = ProductCatalog.LoadDefaultCatalog(); if (IAPModule.Instance == null) { Debug.LogError("Не найден [IAPModule]"); return; } var catalog = IAPModule.Instance.allProducts; m_ValidIDs.Clear(); m_ValidIDs.Add(kNoProduct); foreach (var product in catalog) { 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(); }
[MenuItem("GGTeam/SmartMobileCore/Modules/IAP/IAP-Button (Пустая)", false, 4)] //5 public static void CreateUnityIAPButton() { // Create Button EditorApplication.ExecuteMenuItem("GameObject/UI/Button"); // Get GameObject of Button GameObject gO = Selection.activeGameObject; gO.name = "IAP_Button (Empty)"; 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); }