#if UNITY_EDITOR using System; using ShiroginSDK.Runtime.Core.Editor.Attributes; using ShiroginSDK.Runtime.Core.SDK; using ShiroginSDK.Runtime.Shared.Constants; using UnityEditor; using UnityEngine; namespace ShiroginSDK.Editor.IAP { [CustomPropertyDrawer(typeof(IAPProductDropdownAttribute))] public class IAPProductDropdownDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (property.propertyType != SerializedPropertyType.String) { EditorGUI.LabelField(position, label.text, "Use with string only."); return; } var config = Resources.Load(SDKConstants.ConfigResourcePath); if (config == null || config.storeRepository == null) { EditorGUI.PropertyField(position, property, label); return; } var items = config.storeRepository.GetAll(); var options = new string[items.Count]; for (var i = 0; i < items.Count; i++) options[i] = items[i] != null ? items[i].productId : ""; var index = Mathf.Max(0, Array.IndexOf(options, property.stringValue)); index = EditorGUI.Popup(position, label.text, index, options); if (index >= 0 && index < options.Length) property.stringValue = options[index]; } } } #endif