Skip to content

Commit 39dac85

Browse files
committedFeb 22, 2025
removed hardcoded path for Readme files
1 parent ead75cb commit 39dac85

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed
 

‎Samples~/SamplesGuideInfo/Scripts/Editor/ReadmeEditor.cs

+18-6
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@
1313
[CustomEditor(typeof(Readme))]
1414
public class ReadmeEditor : Editor
1515
{
16-
static string s_ReadmeSourceDirectory = "Assets/Samples/Unity Singleton/3.0.0/Samples/SamplesGuideInfo";
17-
1816
const float k_Space = 8f;
1917

2018
static void RemoveTutorial()
2119
{
22-
if (EditorUtility.DisplayDialog("Remove Readme Assets",
20+
string s_ReadmeSourcePath = GetReadmePath();
21+
if (string.IsNullOrEmpty(s_ReadmeSourcePath))
22+
{
23+
Debug.LogWarning("Could not determine the Readme folder path.");
24+
return;
25+
}
26+
27+
string s_ReadmeSourceDirectory = Path.GetDirectoryName(s_ReadmeSourcePath) + "\\SamplesGuideInfo";
2328

24-
$"All contents under {s_ReadmeSourceDirectory} will be removed, are you sure you want to proceed?",
25-
"Proceed",
26-
"Cancel"))
29+
if (EditorUtility.DisplayDialog("Remove Readme Assets", $"All contents under {s_ReadmeSourceDirectory} will be removed, are you sure you want to proceed?", "Proceed", "Cancel"))
2730
{
2831
if (Directory.Exists(s_ReadmeSourceDirectory))
2932
{
@@ -47,6 +50,15 @@ static void RemoveTutorial()
4750
}
4851
}
4952

53+
static string GetReadmePath()
54+
{
55+
var readmeAsset = Selection.activeObject;
56+
if (readmeAsset == null) return string.Empty;
57+
58+
string path = AssetDatabase.GetAssetPath(readmeAsset);
59+
return path;
60+
}
61+
5062
static Readme SelectReadme()
5163
{
5264
var ids = AssetDatabase.FindAssets("Readme t:Readme");

0 commit comments

Comments
 (0)
Failed to load comments.