private void DrawBundles() { if (CurrentTemplate.Bundles == null || CurrentTemplate.Bundles.Count == 0) { return; } GUILayout.Label("Bundles", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(); bundleScrollPos = EditorGUILayout.BeginScrollView(bundleScrollPos, GUILayout.Width(300), GUILayout.Height(100)); // DrawBundles /// Storage variable if one of them is gonna be removed. Products.Bundle m_itemToRemove = null; foreach (var @base in CurrentTemplate.Bundles) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(@base.Id); if (GUILayout.Button("Edit")) { BundleEditor.Init(@base, (bundle) => { // New Item created. int target = CurrentTemplate.Bundles.FindIndex(x => x.Id.Equals(bundle.Id)); if (target != -1) { CurrentTemplate.Bundles[target] = bundle; UpdateTemplate(); } }); } if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Beware!", "Do you want to delete this item? All products using this item will be removed also!!", "Go ahead", "Cancel")) { m_itemToRemove = @base; } } EditorGUILayout.EndHorizontal(); } if (m_itemToRemove != null) { // Remove the base. CurrentTemplate.Bundles.Remove(m_itemToRemove); // Update the template. UpdateTemplate(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
private void OnGUI() { GUILayout.Label("TemplateEditor"); if (GUILayout.Button("Create Item")) { ItemEditor.Init(null, (product) => { // New Item created. CurrentTemplate.ItemDefinitions.Add(product); UpdateTemplate(); }); } if (CurrentTemplate.ItemDefinitions != null && CurrentTemplate.ItemDefinitions.Count > 0) { if (GUILayout.Button("Create Product")) { ProductEditor.Init(null, (product) => { // New Product // TODO => CHECK FOR ID CONFLICT. CurrentTemplate.Products.Add(product); UpdateTemplate(); }); } } if (CurrentTemplate.Products != null && CurrentTemplate.Products.Count > 0) { if (GUILayout.Button("Create Bundle")) { BundleEditor.Init(null, (bundle) => { // New Bundle // TODO => CHECK FOR ID CONFLICT. CurrentTemplate.Bundles.Add(bundle); UpdateTemplate(); }); } } // List Items & Products & Bundles DrawItems(); DrawProducts(); DrawBundles(); // }