Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Akeit0 committed Jan 21, 2024
1 parent 8771b43 commit 314a6e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/NuGetForUnity/Editor/Configuration/NugetConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class NugetConfigFile
/// while auto-restoring.
/// </summary>
public bool SlimRestore { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether a package is installed to /Packages/PackagesFolder or /Assets
/// </summary>
Expand All @@ -121,7 +121,7 @@ public bool InstallToPackagesFolder
UnityPathHelper.InstallToPackagesFolder = value;
if (value)
{

var rel = PathHelper.GetRelativePath(Application.dataPath, RepositoryPath);
RepositoryPath = Path.Combine(UnityPathHelper.NugetAssetsPath, rel);
}
Expand Down Expand Up @@ -375,6 +375,7 @@ public static NugetConfigFile Load([NotNull] string filePath)
configFile.RelativePackagesConfigDirectoryPath = value;
}
}

return configFile;
}

Expand Down Expand Up @@ -491,7 +492,7 @@ public void Save([NotNull] string filePath)

if (!string.IsNullOrEmpty(savedRepositoryPath))
{

// save the un-expanded repository path
addElement = new XElement("add");
addElement.Add(new XAttribute("key", "repositoryPath"));
Expand Down Expand Up @@ -525,6 +526,7 @@ public void Save([NotNull] string filePath)
addElement.Add(new XAttribute("key", "slimRestore"));
addElement.Add(new XAttribute("value", SlimRestore.ToString().ToLowerInvariant()));
config.Add(addElement);

if (InstallToPackagesFolder)
{
addElement = new XElement("add");
Expand Down
15 changes: 6 additions & 9 deletions src/NuGetForUnity/Editor/Helper/UnityPathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Text;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;

#region No ReShaper
Expand All @@ -31,7 +30,7 @@ static UnityPathHelper()
AbsoluteAssetsPath = Path.GetFullPath(Application.dataPath);
AbsoluteProjectPath = Path.GetDirectoryName(AbsoluteAssetsPath) ?? throw new InvalidOperationException("Can't detect project root.");
var packagePath = Path.Combine(AbsoluteProjectPath, "Packages");
NugetAssetsPath=Path.Combine(packagePath, "NuGetAssets");
NugetAssetsPath=Path.Combine(packagePath, "NuGetAssets");
}

private static bool installToPackagesFolder=false;
Expand All @@ -57,14 +56,13 @@ internal static bool InstallToPackagesFolder
}
}
/// <summary>
/// Gets the path to the InstallPath directory.
/// Gets the path to the ../Package/NuGetAssets directory.
/// </summary>
[NotNull]
internal static string NugetAssetsPath { get; }



/// <summary>
/// Gets the absolute path to the NuGetAssets directory.
/// Gets the absolute path to the Unity-Project 'Assets' directory.
/// </summary>
[NotNull]
internal static string AbsoluteAssetsPath { get; }
Expand All @@ -73,7 +71,7 @@ internal static bool InstallToPackagesFolder
/// Gets the absolute path to the Unity-Project root directory.
/// </summary>
[NotNull]
internal static string AbsoluteProjectPath { get; }
internal static string AbsoluteProjectPath { get; }

/// <summary>
/// Checks if given path is within Assets folder.
Expand All @@ -94,8 +92,7 @@ internal static bool IsPathInAssets([NotNull] string path)
[NotNull]
private static string GetAssetsRelativePath([NotNull] string path)
{

return PathHelper.GetRelativePath(AbsoluteAssetsPath, path);
return PathHelper.GetRelativePath(Application.dataPath, path);
}
}
}
1 change: 1 addition & 0 deletions src/NuGetForUnity/Editor/Ui/NugetPreferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ public NugetPlugin(string name, string path)

[CanBeNull]
public Assembly Assembly { get; }

public string Name { get; }

public string Path { get; }
Expand Down
4 changes: 1 addition & 3 deletions src/NuGetForUnity/Editor/Ui/NugetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,10 +1056,8 @@ private void DrawUpdatesHeader()
/// <summary>
/// Draws the "Refresh" and "Preferences" buttons in the upper right corner, which are visible in every tab.
/// </summary>

private void DrawMandatoryButtons()
{

if (GUILayout.Button("Refresh", GUILayout.Width(60)))
{
Refresh(true);
Expand Down Expand Up @@ -1512,4 +1510,4 @@ private sealed class VersionDropdownData
public string[] DropdownOptions { get; set; }
}
}
}
}

0 comments on commit 314a6e6

Please sign in to comment.