private void OnGUI()
        {
            GUILayout.Label("Product Editor");

            CurrentBase.Id = EditorGUIHelper.DrawTextField("Id", ref CurrentBase.Id);

            // ITEM ID.
            GUILayout.Label("Select item from the list.");
            selection = EditorGUILayout.Popup(selection, itemList);
            if (selection != -1)
            {
                CurrentBase.ItemId = itemList[selection];
            }

            var amountAsString = CurrentBase.Amount.ToString();

            // draw amount.
            amountAsString = EditorGUIHelper.DrawTextField("Amount", ref amountAsString);
            int result;

            if (int.TryParse(amountAsString, out result))
            {
                CurrentBase.Amount = result;
            }

            CurrentBase.Name    = EditorGUIHelper.DrawTextField("Name", ref CurrentBase.Name);
            CurrentBase.Desc    = EditorGUIHelper.DrawTextField("Desc", ref CurrentBase.Desc);
            CurrentBase.IconURL = EditorGUIHelper.DrawTextField("Icon URL", ref CurrentBase.IconURL);

            pricesEditor.Draw(CurrentBase);

            if (GUILayout.Button("Save"))
            {
                CompletedAction?.Invoke(CurrentBase);

                var window = (ProductEditor)GetWindow(typeof(ProductEditor));
                window.Close();
            }
        }
        private void OnGUI()
        {
            GUILayout.Label("Item Editor");

            GUILayout.Label("Id");

            selection = EditorGUILayout.Popup(selection, appSettings.GameItemList);
            if (selection != -1)
            {
                CurrentBase.Id = appSettings.GameItemList[selection];
            }

            CurrentBase.Name    = EditorGUIHelper.DrawTextField("Name", ref CurrentBase.Name);
            CurrentBase.Desc    = EditorGUIHelper.DrawTextField("Desc", ref CurrentBase.Desc);
            CurrentBase.IconURL = EditorGUIHelper.DrawTextField("Icon URL", ref CurrentBase.IconURL);

            if (GUILayout.Button("Save"))
            {
                CompletedAction?.Invoke(CurrentBase);

                var window = (ItemEditor)GetWindow(typeof(ItemEditor));
                window.Close();
            }
        }
        private void OnGUI()
        {
            GUILayout.Label("Bundle Editor");

            CurrentBase.Id      = EditorGUIHelper.DrawTextField("Id", ref CurrentBase.Id);
            CurrentBase.Name    = EditorGUIHelper.DrawTextField("Name", ref CurrentBase.Name);
            CurrentBase.Desc    = EditorGUIHelper.DrawTextField("Desc", ref CurrentBase.Desc);
            CurrentBase.IconURL = EditorGUIHelper.DrawTextField("Icon URL", ref CurrentBase.IconURL);

            GUILayout.Label("Products");
            if (itemList.Length > 0)
            {
                if (GUILayout.Button("Add Product"))
                {
                    CurrentBase.BundleItems.Add(new Products.Bundle.BundleItem()
                    {
                        ItemId = itemList[0], Amount = 1
                    });
                    selection = selection.Append(0).ToArray();
                }
            }
            /// Storage variable if one of them is gonna be removed.
            Products.Bundle.BundleItem m_itemToRemove = null;

            EditorGUILayout.BeginVertical();
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(300), GUILayout.Height(100));

            // Draw products included in this bundle.
            int length = CurrentBase.BundleItems.Count;

            for (int i = 0; i < length; i++)
            {
                EditorGUILayout.BeginHorizontal();

                selection[i] = EditorGUILayout.Popup(selection[i], itemList);
                if (selection[i] != -1)
                {
                    CurrentBase.BundleItems[i].ItemId = itemList[selection[i]];
                }

                var amountAsString = CurrentBase.BundleItems[i].Amount.ToString();
                // draw amount.
                amountAsString = EditorGUIHelper.DrawTextField("Amount", ref amountAsString);
                int result;
                if (int.TryParse(amountAsString, out result))
                {
                    CurrentBase.BundleItems[i].Amount = result;
                }

                if (GUILayout.Button("Remove"))
                {
                    m_itemToRemove = CurrentBase.BundleItems[i];
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            if (m_itemToRemove != null)
            {
                int indexToRemove = CurrentBase.BundleItems.FindIndex(x => x.ItemId == m_itemToRemove.ItemId);
                if (indexToRemove != -1)
                {
                    CurrentBase.BundleItems.RemoveAt(indexToRemove);
                }
            }

            pricesEditor.Draw(CurrentBase);

            GUILayout.Space(20);
            if (GUILayout.Button("Save"))
            {
                CompletedAction?.Invoke(CurrentBase);

                var window = (BundleEditor)GetWindow(typeof(BundleEditor));
                window.Close();
            }
        }