Skip to content

Commit

Permalink
- add: GetPathFolderInCurrentEnvironment method
Browse files Browse the repository at this point in the history
  • Loading branch information
DucNV2000 committed Jul 30, 2024
1 parent 8a5ea8f commit 930eee3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
6 changes: 3 additions & 3 deletions VirtueSky/ControlPanel/CPAdvertisingDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void DrawMaxField(Rect position)
if (GUILayout.Button("Install Max Sdk Plugin"))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/Utils/Editor/UnityPackage/max-sdk.unitypackage"), false);
}

Expand Down Expand Up @@ -139,7 +139,7 @@ static void DrawAdmobField(Rect position)
if (GUILayout.Button("Install Admob Sdk Plugin"))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/Utils/Editor/UnityPackage/google-mobile-ads.unitypackage"), false);
}

Expand Down Expand Up @@ -168,7 +168,7 @@ static void DrawIronSource(Rect position)
if (GUILayout.Button("Install IronSource Sdk Plugin"))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/Utils/Editor/UnityPackage/is-sdk.unitypackage"), false);
}

Expand Down
2 changes: 1 addition & 1 deletion VirtueSky/ControlPanel/CPFolderIconDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void OnDrawFolderIcon()
if (GUILayout.Button("Import texture icon folder"))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/FolderIcon/Editor/PackageIcon/icon_folder.unitypackage"), false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion VirtueSky/ControlPanel/CPGameServiceDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void OnDrawGameService()
if (GUILayout.Button("Install Google Play Game Service", GUILayout.Width(400)))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/Utils/Editor/UnityPackage/google-play-game.unitypackage"), false);
}

Expand Down
2 changes: 1 addition & 1 deletion VirtueSky/ControlPanel/CPRegisterPackageDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void DrawButtonAddSomePackage()
if (GUILayout.Button("Install Google Play Game Service", GUILayout.Width(400)))
{
AssetDatabase.ImportPackage(
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
"VirtueSky/Utils/Editor/UnityPackage/google-play-game.unitypackage"), false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions VirtueSky/FolderIcon/Editor/IconDictionaryCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static bool ContainsIconAsset(string[] assets)
foreach (string str in assets)
{
if (ReplaceSeparatorChar(Path.GetDirectoryName(str)) ==
FileExtension.GetPathInCurrentEnvironent(AssetsPath))
FileExtension.GetPathFileInCurrentEnvironment(AssetsPath))
{
return true;
}
Expand All @@ -52,13 +52,13 @@ internal static void BuildDictionary()
{
if (folderIconSettings.setupIconDefault)
{
var dir = new DirectoryInfo(FileExtension.GetPathInCurrentEnvironent(AssetsPath));
var dir = new DirectoryInfo(FileExtension.GetPathFolderInCurrentEnvironment(AssetsPath));
FileInfo[] info = dir.GetFiles("*.png");
foreach (FileInfo f in info)
{
var texture =
(Texture)AssetDatabase.LoadAssetAtPath(
FileExtension.GetPathInCurrentEnvironent($"{AssetsPath}/{f.Name}"),
FileExtension.GetPathFileInCurrentEnvironment($"{AssetsPath}/{f.Name}"),
typeof(Texture2D));
dictionary.Add(Path.GetFileNameWithoutExtension(f.Name), texture);
}
Expand Down
4 changes: 2 additions & 2 deletions VirtueSky/Iap/Editor/IapSettingEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ void ObfuscatorKey()
googleError: ref appleError,
googlePlayPublicKey: _iapSetting.GooglePlayStoreKey);
string pathAsmdef =
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
$"VirtueSky/Utils/Editor/TemplateAssembly/PurchasingGeneratedAsmdef.txt");
string pathAsmdefMeta =
FileExtension.GetPathInCurrentEnvironent(
FileExtension.GetPathFileInCurrentEnvironment(
$"VirtueSky/Utils/Editor/TemplateAssembly/PurchasingGeneratedAsmdefMeta.txt");
var asmdef = (TextAsset)AssetDatabase.LoadAssetAtPath(pathAsmdef, typeof(TextAsset));
var meta = (TextAsset)AssetDatabase.LoadAssetAtPath(pathAsmdefMeta, typeof(TextAsset));
Expand Down
13 changes: 10 additions & 3 deletions VirtueSky/Utils/Editor/FileExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static List<T> FindAll<T>() where T : Object

public static T FindAssetWithPath<T>(string fullPath) where T : Object
{
string path = GetPathInCurrentEnvironent(fullPath);
string path = GetPathFileInCurrentEnvironment(fullPath);
var t = AssetDatabase.LoadAssetAtPath(path, typeof(T));
if (t == null) Debug.LogError($"Couldn't load the {nameof(T)} at path :{path}");
return t as T;
Expand Down Expand Up @@ -119,16 +119,23 @@ public static T FindAssetAtResource<T>(string path) where T : ScriptableObject

public static string AssetInPackagePath(string relativePath, string nameAsset)
{
return GetPathInCurrentEnvironent($"{relativePath}/{nameAsset}");
return GetPathFileInCurrentEnvironment($"{relativePath}/{nameAsset}");
}

public static string GetPathInCurrentEnvironent(string fullRelativePath)
public static string GetPathFileInCurrentEnvironment(string fullRelativePath)
{
var upmPath = $"Packages/com.virtuesky.sunflower/{fullRelativePath}";
var normalPath = $"Assets/Sunflower/{fullRelativePath}";
return !File.Exists(Path.GetFullPath(upmPath)) ? normalPath : upmPath;
}

public static string GetPathFolderInCurrentEnvironment(string fullRelativePath)
{
var upmPath = $"Packages/com.virtuesky.sunflower/{fullRelativePath}";
var normalPath = $"Assets/Sunflower/{fullRelativePath}";
return Directory.Exists(upmPath) ? upmPath : normalPath;
}

public static string FormatJson(string json)
{
try
Expand Down

0 comments on commit 930eee3

Please sign in to comment.