コード例 #1
0
ファイル: Graph.cs プロジェクト: despin89/repo
        public static bool Save(string fileName, Graph graph)
        {
            var asset = ScriptableObject.CreateInstance <EncounterAsset>();

            CustomEditorUtils.SaveAsset(asset, "Assets/Resources/Encounters/", graph.GetEncounterTag());

            for (int i = 0; i < graph.GetNodeCount(); i++)
            {
                var node = graph.GetNodeAt(i) as EncounterNodeBase;
                asset.AddNode(node.Encounter);
                CustomEditorUtils.AddAssetToAsset(node.Encounter, asset);

                foreach (var allower in node.Encounter.Allowers)
                {
                    CustomEditorUtils.AddAssetToAsset(allower, asset);
                }

                foreach (var @event in node.Encounter.Events)
                {
                    CustomEditorUtils.AddAssetToAsset(@event, asset);
                }
            }

            EditorUtility.SetDirty(asset);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            EditorUtility.DisplayDialog("Saved", "Encounter Saved!", "OK");

            return(true);
        }
コード例 #2
0
        private void OnEnable()
        {
            this._localizationDatabase = Resources.Load <LocalizationDatabase>("Localization/LocalizationDatabase");

            if (this._localizationDatabase == null)
            {
                LocalizationDatabase localizationDatabase =
                    CreateInstance("LocalizationDatabase") as LocalizationDatabase;

                if (localizationDatabase != null)
                {
                    this._localizationDatabase = localizationDatabase;
                    CustomEditorUtils.SaveAssetWithStrongName(localizationDatabase, "Assets/Resources/Localization/",
                                                              "LocalizationDatabase");
                }
            }
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            LevelDescription description = this.target as LevelDescription;

            description.LevelEnvironment =
                EditorGUILayout.ObjectField("Level Type", description.LevelEnvironment, typeof(LevelEnvironmentEnum), false) as
                LevelEnvironmentEnum;

            GUILayout.Space(4);
            if (CustomEditorUtils.GetButton("Add Description", Color.green))
            {
                description.EncounterModels.Add(new EncounterModel());
            }
            GUILayout.Space(4);

            this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);

            int indexToDelete = -1;

            for (int i = 0; i < description.EncounterModels.Count; i++)
            {
                if (description.EncounterModels[i] != null)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    description.EncounterModels[i].Encounter =
                        EditorGUILayout.ObjectField("Encounter", description.EncounterModels[i].Encounter, typeof(EncounterAsset),
                                                    false) as EncounterAsset;
                    description.EncounterModels[i].MinCount = EditorGUILayout.IntField("MinCount",
                                                                                       description.EncounterModels[i]
                                                                                       .MinCount);
                    description.EncounterModels[i].MaxCount = EditorGUILayout.IntField("MaxCount",
                                                                                       description.EncounterModels[i]
                                                                                       .MaxCount);

                    if (CustomEditorUtils.GetButton("Delete Description", Color.red))
                    {
                        indexToDelete = i;
                    }

                    EditorGUILayout.EndVertical();
                }

                GUILayout.Space(4);
            }

            if (indexToDelete > -1)
            {
                bool result = EditorUtility.DisplayDialog("Delete component",
                                                          "Delete component: {0}".F(
                                                              description.EncounterModels[
                                                                  indexToDelete
                                                              ].GetType
                                                                  ()),
                                                          "OK", "Cancel");

                if (result)
                {
                    description.EncounterModels.Remove(description.EncounterModels[indexToDelete]);
                }
            }

            EditorGUILayout.EndScrollView();

            EditorUtility.SetDirty(this.target);
        }
コード例 #4
0
        private void OnGUI()
        {
            if (GUILayout.Button("Generate Localization File"))
            {
                this.GenerateStringsFile();
            }

            if (GUILayout.Button("Get Scenes Localization"))
            {
                EditorSceneManager.SaveOpenScenes();

                IEnumerable <string> scenesNames =
                    Directory.GetFiles(@"Assets\Scenes\", "*.unity").Select(Path.GetFileName);

                foreach (string scenesName in scenesNames)
                {
                    EditorSceneManager.OpenScene(@"Assets\Scenes\" + scenesName);

                    IEnumerable <ILocalizable> localizables =
                        FindObjectsOfType <MonoBehaviour>().OfType <ILocalizable>().ToArray();
                    this.GetLocalization(localizables);

                    EditorSceneManager.MarkAllScenesDirty();
                    EditorSceneManager.SaveOpenScenes();
                }

                EditorUtility.SetDirty(this._localizationDatabase);
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }

            if (GUILayout.Button("Get Assets Localization"))
            {
                List <ILocalizable> localizables           = new List <ILocalizable>();
                string[]            localizableAssetsGUIDs = AssetDatabase.FindAssets("t:ScriptableObject");

                localizables.AddRange(
                    localizableAssetsGUIDs.Select(
                        guid =>
                        AssetDatabase.LoadAssetAtPath <ScriptableObject>(
                            AssetDatabase
                            .GUIDToAssetPath
                                (guid)))
                    .OfType <ILocalizable>());

                this.GetLocalization(localizables);

                EditorUtility.SetDirty(this._localizationDatabase);
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }

            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
            this._showStaticStrings = EditorGUILayout.Foldout(this._showStaticStrings, "Static Strings", true,
                                                              new GUIStyle
            {
                fontStyle = FontStyle.Bold,
                fontSize  = 12
            });
            EditorGUILayout.EndHorizontal();

            if (this._showStaticStrings)
            {
                GUI.SetNextControlName("AddStaticStringButton");
                if (GUILayout.Button("Add Static String"))
                {
                    if (!string.IsNullOrEmpty(this._staticStringText) &&
                        (this._staticStringText != "Static String Text") &&
                        !string.IsNullOrEmpty(this._staticStringAlias) &&
                        (this._staticStringAlias != "Static String Alias"))
                    {
                        if (Regex.IsMatch(this._staticStringAlias, @"^[a-zA-Z_]+$"))
                        {
                            string error = this._localizationDatabase.TryAddString(this._staticStringText,
                                                                                   this._staticStringAlias);

                            if (!string.IsNullOrEmpty(error))
                            {
                                Debug.LogError(error);
                                EditorUtility.DisplayDialog("Error", error, "OK");
                            }
                            else
                            {
                                EditorUtility.SetDirty(this._localizationDatabase);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();

                                this._staticStringAlias = string.Empty;
                                this._staticStringText  = string.Empty;

                                GUI.FocusControl("AddStaticStringButton");
                                GUI.FocusControl("_staticStringAlias");
                            }
                        }
                        else
                        {
                            EditorUtility.DisplayDialog("Alias Error", "Alias must contain only letters and underscore",
                                                        "OK");
                        }
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Error", "Cannot add empty data",
                                                    "OK");
                    }
                }

                GUI.SetNextControlName("_staticStringAlias");
                this._staticStringAlias = EditorGUILayout.TextField("Static String Alias", this._staticStringAlias);
                this._staticStringText  = EditorGUILayout.TextField("Static String Text", this._staticStringText);

                GUILayout.Space(10);

                if (this._localizationDatabase.CachedStrings.Count(e => !string.IsNullOrEmpty(e.Value.Alias)) > 0)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    GUILayout.Label("Static Strings", EditorStyles.boldLabel);

                    int indexToDeleteString           = -1;
                    LocalizableString[] cachedStrings =
                        this._localizationDatabase.CachedStrings.Values.Where(e => !string.IsNullOrEmpty(e.Alias))
                        .ToArray();

                    for (int i = 0; i < cachedStrings.Length; i++)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                        GUILayout.Label(cachedStrings[i].Alias);
                        GUI.color = Color.red;
                        if (GUILayout.Button("Delete", GUILayout.Width(100)))
                        {
                            indexToDeleteString = i;
                        }
                        GUI.color = Color.white;
                        EditorGUILayout.EndHorizontal();
                        GUILayout.Label(cachedStrings[i].Text, CustomEditorUtils.ItalicStyle());
                        EditorGUILayout.EndVertical();
                    }

                    EditorGUILayout.EndVertical();

                    if (indexToDeleteString > -1)
                    {
                        bool result = EditorUtility.DisplayDialog("Delete string",
                                                                  "Delete string: {0}".F(cachedStrings[
                                                                                             indexToDeleteString
                                                                                         ].Text),
                                                                  "OK", "Cancel");
                        if (result)
                        {
                            string error = this._localizationDatabase.TryRemoveStringById(cachedStrings[
                                                                                              indexToDeleteString
                                                                                          ].Id);

                            if (!string.IsNullOrEmpty(error))
                            {
                                Debug.LogError(error);
                            }
                            else
                            {
                                EditorUtility.SetDirty(this._localizationDatabase);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();
                            }
                        }

                        this.Repaint();
                    }
                }
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
            this._showAllStrings = EditorGUILayout.Foldout(this._showAllStrings, "All Strings", true,
                                                           new GUIStyle
            {
                fontStyle = FontStyle.Bold,
                fontSize  = 12
            });
            EditorGUILayout.EndHorizontal();

            if (this._showAllStrings)
            {
                GUILayout.Space(10);

                if (this._localizationDatabase.CachedStrings.Count > 0)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    int indexToDeleteString           = -1;
                    LocalizableString[] cachedStrings = this._localizationDatabase.CachedStrings.Values.ToArray();

                    for (int i = 0; i < cachedStrings.Length; i++)
                    {
                        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                        GUILayout.Label(cachedStrings[i].Text, CustomEditorUtils.ItalicStyle());
                        GUI.color = Color.red;
                        if (GUILayout.Button("Delete", GUILayout.Width(100)))
                        {
                            indexToDeleteString = i;
                        }
                        GUI.color = Color.white;
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndVertical();

                    if (indexToDeleteString > -1)
                    {
                        bool result = EditorUtility.DisplayDialog("Delete string",
                                                                  "Delete string: {0}".F(cachedStrings[
                                                                                             indexToDeleteString
                                                                                         ].Text),
                                                                  "OK", "Cancel");
                        if (result)
                        {
                            string error = this._localizationDatabase.TryRemoveStringById(cachedStrings[
                                                                                              indexToDeleteString
                                                                                          ].Id);

                            if (!string.IsNullOrEmpty(error))
                            {
                                Debug.LogError(error);
                            }
                            else
                            {
                                EditorUtility.SetDirty(this._localizationDatabase);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();
                            }
                        }

                        this.Repaint();
                    }
                }
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
            this._showKeyStrings = EditorGUILayout.Foldout(this._showKeyStrings, "Key Strings", true,
                                                           new GUIStyle
            {
                fontStyle = FontStyle.Bold,
                fontSize  = 12
            });
            EditorGUILayout.EndHorizontal();

            if (this._showKeyStrings)
            {
                GUI.SetNextControlName("AddKeyStringButton");
                if (GUILayout.Button("Add Key String"))
                {
                    if (!string.IsNullOrEmpty(this._keyStringText) &&
                        (this._keyStringText != "Key String Text") &&
                        !string.IsNullOrEmpty(this._keyStringKey) &&
                        (this._keyStringKey != "String Key"))
                    {
                        if (Regex.IsMatch(this._keyStringKey, @"^[a-zA-Z_]+$"))
                        {
                            string error = this._localizationDatabase.TryAddKeyString(this._keyStringText,
                                                                                      this._keyStringKey);

                            if (!string.IsNullOrEmpty(error))
                            {
                                Debug.LogError(error);
                                EditorUtility.DisplayDialog("Error", error, "OK");
                            }
                            else
                            {
                                EditorUtility.SetDirty(this._localizationDatabase);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();

                                this._keyStringText = string.Empty;
                                this._keyStringKey  = string.Empty;

                                GUI.FocusControl("AddKeyStringButton");
                                GUI.FocusControl("_keyStringAlias");
                            }
                        }
                        else
                        {
                            EditorUtility.DisplayDialog("Alias Error", "Key must contain only letters and underscore",
                                                        "OK");
                        }
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Error", "Cannot add empty data",
                                                    "OK");
                    }
                }

                GUI.SetNextControlName("_keyStringAlias");
                this._keyStringKey  = EditorGUILayout.TextField("String Key", this._keyStringKey);
                this._keyStringText = EditorGUILayout.TextField("Key String Text", this._keyStringText);

                GUILayout.Space(10);

                if (this._localizationDatabase.CachedStrings.Count(e => !string.IsNullOrEmpty(e.Value.Key)) > 0)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    GUILayout.Label("Key Strings", EditorStyles.boldLabel);

                    int indexToDeleteString           = -1;
                    LocalizableString[] cachedStrings =
                        this._localizationDatabase.CachedStrings.Values.Where(e => !string.IsNullOrEmpty(e.Key))
                        .ToArray();

                    for (int i = 0; i < cachedStrings.Length; i++)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                        GUILayout.Label(cachedStrings[i].Key);
                        GUI.color = Color.red;
                        if (GUILayout.Button("Delete", GUILayout.Width(100)))
                        {
                            indexToDeleteString = i;
                        }
                        GUI.color = Color.white;
                        EditorGUILayout.EndHorizontal();
                        GUILayout.Label(cachedStrings[i].Text, CustomEditorUtils.ItalicStyle());
                        EditorGUILayout.EndVertical();
                    }

                    EditorGUILayout.EndVertical();

                    if (indexToDeleteString > -1)
                    {
                        bool result = EditorUtility.DisplayDialog("Delete string",
                                                                  "Delete string: {0}".F(cachedStrings[
                                                                                             indexToDeleteString
                                                                                         ].Text),
                                                                  "OK", "Cancel");
                        if (result)
                        {
                            string error = this._localizationDatabase.TryRemoveStringById(cachedStrings[
                                                                                              indexToDeleteString
                                                                                          ].Id);

                            if (!string.IsNullOrEmpty(error))
                            {
                                Debug.LogError(error);
                            }
                            else
                            {
                                EditorUtility.SetDirty(this._localizationDatabase);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();
                            }
                        }

                        this.Repaint();
                    }
                }
            }
        }
コード例 #5
0
ファイル: AllowersWindow.cs プロジェクト: despin89/repo
        private void OnGUI()
        {
            if (this._encounterInfo != null)
            {
                this._allowerTypeIndex = EditorGUILayout.Popup(this._allowerTypeIndex, this._allowerTypeNames);

                if (EditorWindowBase.GetButton("Add Allower", 80, Color.green))
                {
                    if (this._allowerTypeIndex < 0)
                    {
                        return;
                    }

                    AllowerInfoBase allowerInfoBase = CreateInstance(this._allowerTypeNames[this._allowerTypeIndex]) as AllowerInfoBase;
                    if (allowerInfoBase != null)
                    {
                        this._encounterInfo.Allowers.Add(allowerInfoBase);
                        CustomEditorUtils.AddAssetToAsset(allowerInfoBase, this._encounterInfo);
                    }
                    else
                    {
                        throw new ArgumentException("component is NULL.");
                    }
                }

                this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);

                GUILayout.Space(10);

                if (this._encounterInfo.Allowers.Count > 0)
                {
                    int indexToDelete = -1;
                    for (int i = 0; i < this._encounterInfo.Allowers.Count; i++)
                    {
                        var allower = this._encounterInfo.Allowers[i];
                        if (allower != null)
                        {
                            EditorGUILayout.BeginVertical(GUI.skin.box);
                            Editor.CreateEditor(this._encounterInfo.Allowers[i]).OnInspectorGUI();

                            if (EditorWindowBase.GetButton("-", 20, Color.red))
                            {
                                indexToDelete = i;
                            }

                            EditorGUILayout.EndVertical();

                            if (indexToDelete > -1)
                            {
                                bool result = EditorUtility.DisplayDialog("Delete", "Delete Event",
                                                                          "OK", "Cancel");
                                if (result)
                                {
                                    this._encounterInfo.Allowers.Remove(this._encounterInfo.Allowers[indexToDelete]);
                                    DestroyImmediate(this._encounterInfo.Allowers[indexToDelete], true);

                                    AssetDatabase.SaveAssets();
                                    AssetDatabase.Refresh();
                                }

                                this.Repaint();
                            }
                        }
                    }
                }

                EditorGUILayout.EndScrollView();
            }
        }
コード例 #6
0
ファイル: EditItemWindow.cs プロジェクト: despin89/repo
        private void OnGUI()
        {
            if (this._item != null)
            {
                this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);
                Editor.CreateEditor(this._item).DrawDefaultInspector();

                GUILayout.Space(10);

                if (GUILayout.Button("Rename Asset File"))
                {
                    this.OnRename();
                }

                EditorGUILayout.BeginHorizontal();

                this._componentTypeIndex = EditorGUILayout.Popup(this._componentTypeIndex, this._componentTypeNames);

                Color prevAddComponenButtonColor = GUI.color;
                GUI.color = Color.green;
                if (GUILayout.Button("Add Component"))
                {
                    if (this._componentTypeIndex < 0)
                    {
                        return;
                    }

                    ComponentInfoBase componentBase = CreateInstance(this._componentTypeNames[this._componentTypeIndex]) as ComponentInfoBase;
                    if (componentBase != null)
                    {
                        this._item.AddComponent(componentBase);
                        CustomEditorUtils.AddAssetToAsset(componentBase, this._item);
                    }
                    else
                    {
                        throw new ArgumentException("component is NULL.");
                    }
                }
                GUI.color = prevAddComponenButtonColor;

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginVertical();
                GUILayout.Label("Item Components", EditorStyles.boldLabel);
                int indexToDelete = -1;
                for (int i = 0; i < this._item.ComponentInfos.Count; i++)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    if (this._item.ComponentInfos[i] != null)
                    {
                        Editor.CreateEditor(this._item.ComponentInfos[i]).OnInspectorGUI();
                    }

                    Color prevDeleteComponentButtonColor = GUI.color;
                    GUI.color = Color.red;
                    if (GUILayout.Button("Delete Component"))
                    {
                        indexToDelete = i;
                    }
                    GUI.color = prevDeleteComponentButtonColor;
                    EditorGUILayout.EndVertical();
                }

                if (indexToDelete > -1)
                {
                    bool result = EditorUtility.DisplayDialog("Delete component",
                                                              "Delete component: {0}".F(
                                                                  this._item.ComponentInfos[
                                                                      indexToDelete
                                                                  ].GetType()),
                                                              "OK", "Cancel");

                    if (result)
                    {
                        this._item.RemoveComponent(this._item.ComponentInfos[indexToDelete]);
                        DestroyImmediate(this._item.ComponentInfos[indexToDelete], true);

                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndScrollView();
            }
        }
コード例 #7
0
        private void OnGUI()
        {
            this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);

            if (GUILayout.Button("Add Items Group"))
            {
                ItemsGroup itemsGroup = CreateInstance <ItemsGroup>();
                if (itemsGroup != null)
                {
                    this._itemsGroups.Add(itemsGroup);
                    CustomEditorUtils.SaveAsset(itemsGroup, "Assets/Resources/Items/~ItemsGroups/", "NewItemsGroup");
                }
            }

            GUILayout.Space(10);

            if (this._itemsGroups.Count > 0)
            {
                int indexToDeleteGroup = -1;
                for (int i = 0; i < this._itemsGroups.Count; i++)
                {
                    ItemsGroup itemGroup = this._itemsGroups[i];
                    if (itemGroup != null)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                        itemGroup.Name = EditorGUILayout.TextField(itemGroup.Name,
                                                                   new GUIStyle
                        {
                            fontSize  = 14,
                            fontStyle = FontStyle.Bold
                        });
                        EditorUtility.SetDirty(itemGroup);

                        if (GUILayout.Button("Add Item"))
                        {
                            ItemInfo item = CreateInstance <ItemInfo>();
                            if (item != null)
                            {
                                itemGroup.Items.Add(item);
                                CustomEditorUtils.SaveAsset(item, "Assets/Resources/Items/ItemsData/", "NewItem", itemGroup);
                            }
                        }

                        Color prevDeleteGroupButtonColor = GUI.color;
                        GUI.color = Color.red;
                        if (GUILayout.Button("Delete Group"))
                        {
                            indexToDeleteGroup = i;
                        }
                        GUI.color = prevDeleteGroupButtonColor;

                        GUILayout.Space(10);

                        EditorGUI.BeginDisabledGroup(itemGroup.Items.Count == 0);
                        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                        itemGroup.IsObjectsShown = EditorGUILayout.Foldout(itemGroup.IsObjectsShown,
                                                                           "{0}".F(itemGroup.Name), true,
                                                                           new GUIStyle
                        {
                            fontStyle = FontStyle.Bold,
                            fontSize  = 12
                        });
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndDisabledGroup();

                        GUI.color = Color.grey;
                        if (itemGroup.IsObjectsShown)
                        {
                            int indexToDeleteItem = -1;
                            for (int j = 0; j < itemGroup.Items.Count; j++)
                            {
                                if (itemGroup.Items[j] != null)
                                {
                                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                    EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);

                                    EditorGUILayout.BeginVertical(GUILayout.MinWidth(200.0f));
                                    EditorGUIUtility.labelWidth = 40F;
                                    EditorGUILayout.LabelField("Name: ", itemGroup.Items[j].Name.Text,
                                                               new GUIStyle {
                                        fontStyle = FontStyle.Bold
                                    });
                                    EditorGUILayout.LabelField("Tag: ", itemGroup.Items[j].Tag,
                                                               new GUIStyle {
                                        fontStyle = FontStyle.Bold
                                    });
                                    EditorGUILayout.LabelField("Type: ", itemGroup.Items[j].Type.ToString(),
                                                               new GUIStyle {
                                        fontStyle = FontStyle.Bold
                                    });
                                    EditorGUILayout.EndVertical();

                                    Rect rect = GUILayoutUtility.GetLastRect();

                                    if (itemGroup.Items[j].ItemSprite)
                                    {
                                        rect.x += 200F;
                                        EditorGUILayout.BeginVertical(GUILayout.MinWidth(50.0f));
                                        //GUI.DrawTexture(rect, itemGroup.Items[j].ItemSprite.texture,
                                        //    ScaleMode.ScaleToFit);

                                        rect.height = 50.0f;
                                        rect.width  = 50.0f;

                                        Rect texRect = new Rect(0, 0, itemGroup.Items[j].ItemSprite.texture.width,
                                                                itemGroup.Items[j].ItemSprite.texture.height);

                                        Vector2 min = Rect.PointToNormalized(texRect,
                                                                             itemGroup.Items[j].ItemSprite.rect.min);

                                        float height = itemGroup.Items[j].ItemSprite.rect.height /
                                                       itemGroup.Items[j].ItemSprite.texture.height;
                                        float width = itemGroup.Items[j].ItemSprite.rect.width /
                                                      itemGroup.Items[j].ItemSprite.texture.width;

                                        GUI.DrawTextureWithTexCoords(rect, itemGroup.Items[j].ItemSprite.texture,
                                                                     new Rect(min.x, min.y, width, height));

                                        EditorGUILayout.EndVertical();
                                    }
                                    EditorGUILayout.EndHorizontal();

                                    if (GUILayout.Button("Edit Item"))
                                    {
                                        EditItemWindow.ShowWindow(itemGroup.Items[j]);
                                    }

                                    Color prevDeleteItemButtonColor = GUI.color;
                                    GUI.color = Color.red;
                                    if (GUILayout.Button("Delete Item"))
                                    {
                                        indexToDeleteItem = j;
                                    }
                                    GUI.color = prevDeleteItemButtonColor;

                                    EditorGUILayout.EndVertical();
                                }

                                GUILayout.Space(15);

                                if (indexToDeleteItem > -1)
                                {
                                    bool result = EditorUtility.DisplayDialog("Delete item",
                                                                              "Delete item: {0}".F(
                                                                                  itemGroup.Items[
                                                                                      indexToDeleteItem
                                                                                  ].Name),
                                                                              "OK", "Cancel");

                                    if (result)
                                    {
                                        foreach (
                                            ComponentInfoBase component in itemGroup.Items[indexToDeleteItem].ComponentInfos)
                                        {
                                            DestroyImmediate(component, true);
                                        }

                                        string path = AssetDatabase.GetAssetPath(itemGroup.Items[indexToDeleteItem]);
                                        AssetDatabase.DeleteAsset(path);

                                        DestroyImmediate(itemGroup.Items[indexToDeleteItem], true);
                                        itemGroup.Items.RemoveAt(indexToDeleteItem);

                                        AssetDatabase.SaveAssets();
                                        AssetDatabase.Refresh();
                                    }

                                    indexToDeleteItem = -1;
                                    this.Repaint();
                                }
                            }
                        }
                        GUI.color = Color.white;

                        EditorGUILayout.EndVertical();

                        if (indexToDeleteGroup > -1)
                        {
                            bool result = EditorUtility.DisplayDialog("Delete item group",
                                                                      "Delete item group: {0}".F(
                                                                          this._itemsGroups[
                                                                              indexToDeleteGroup
                                                                          ].Name),
                                                                      "OK", "Cancel");
                            if (result)
                            {
                                foreach (ItemInfo item in this._itemsGroups[indexToDeleteGroup].Items)
                                {
                                    string path = AssetDatabase.GetAssetPath(item);
                                    AssetDatabase.DeleteAsset(path);

                                    DestroyImmediate(item, true);
                                }

                                string assetPath = AssetDatabase.GetAssetPath(this._itemsGroups[indexToDeleteGroup]);
                                AssetDatabase.DeleteAsset(assetPath);

                                DestroyImmediate(this._itemsGroups[indexToDeleteGroup], true);
                                this._itemsGroups.RemoveAt(indexToDeleteGroup);

                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();
                            }

                            indexToDeleteGroup = -1;
                            this.Repaint();
                        }
                    }
                }
            }

            EditorGUILayout.EndScrollView();
        }