Пример #1
0
        protected virtual void DrawAssetList(List <AssetInfo> assetInfoList, float width)
        {
            var fieldWidth = (width - ButtonWidth) / 2;

            // Heading:
            try
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Name", "Sort by name."), GUILayout.Width(fieldWidth)))
                {
                    AssetInfoLists.SortList(AssetType, AssetInfoLists.SortBy.Name);
                }
                if (GUILayout.Button(new GUIContent("Folder Path", "Sort by folder path."), GUILayout.Width(fieldWidth)))
                {
                    AssetInfoLists.SortList(AssetType, AssetInfoLists.SortBy.Path);
                }
                GUILayout.Label(string.Empty, GUILayout.Width(ButtonWidth));
            }
            finally
            {
                EditorGUILayout.EndHorizontal();
            }
            // Rows:
            if (assetInfoList == null)
            {
                return;
            }
            var indexToDelete = -1;

            for (int i = 0; i < assetInfoList.Count; i++)
            {
                var assetInfo = assetInfoList[i];
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(assetInfo.name, EditorStyles.textField, GUILayout.Width(fieldWidth)))
                {
                    Selection.activeObject = EditorUtility.InstanceIDToObject(assetInfo.instanceID);
                    EditorGUIUtility.PingObject(assetInfo.instanceID);
                }
                EditorGUI.BeginDisabledGroup(true);
                GUILayout.TextField(assetInfo.path, GUILayout.Width(fieldWidth));
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent("Delete", "Delete " + assetInfo.name + "."), GUILayout.Width(ButtonWidth)))
                {
                    if (EditorUtility.DisplayDialog("Delete " + AssetType.Name + "?", assetInfo.name + "\n\nYou cannot undo this action.", "Delete", "Cancel"))
                    {
                        indexToDelete = i;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            if (indexToDelete != -1)
            {
                DeleteAsset(assetInfoList, indexToDelete);
            }
        }