void DrawPackageContent(RIBackendPackageMetaData pInfo) { GUILayout.Space(packageRowVerticalSpace); // title and install/uninstall control GUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = packageCheckBoxWidth; bool install = GUILayout.Toggle(PackageIsInstalled(pInfo), GUIContent.none, packageInstallToggleStyle); if (EditorGUI.EndChangeCheck()) { if (install) { AssetDatabase.ImportPackage(GetFullPackagePath(pInfo.packageName), true); } else { string installPath = GetPackageInstallPath(pInfo); string msg = string.Format("Delete the folder {0} and its contents?", installPath); if (EditorUtility.DisplayDialog("Delete folder", msg, "Yes", "No")) { AssetDatabase.DeleteAsset(installPath); } } } GUILayout.Label(pInfo.title, packageTitleStyle); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); // description GUILayout.Label(pInfo.description, packageDescriptionStyle); }
string GetPackageInstallPath(RIBackendPackageMetaData packageInfo) { return(ProjectSettings.BackendInstallPath + packageInfo.folderName); }
bool PackageIsInstalled(RIBackendPackageMetaData packageInfo) { string packageInstallPath = Util.AssetToSystemPath(GetPackageInstallPath(packageInfo)); return(System.IO.Directory.Exists(packageInstallPath)); }