Skip to content

Commit

Permalink
chore: try with paths
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonHough committed Jan 11, 2024
1 parent 4ff1647 commit 3788776
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Samples~/WebGLSample/Editor/EditorWindows/SampleSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public static class SampleSetup
private const string CANCEL_BUTTON_TEXT = "Cancel";

private const string RPM_WEBGL_SCREEN_SHOWN_KEY = "rpm-webgl-screen-shown";
private const string RPM_TEMPLATE_PACKAGE_NAME = "RpmWebGLTemplate.unitypackage";

private const string TEMPLATE_PACKAGE_ASSETS_FOLDER = "Assets/Ready Player Me/Core/Editor/WebView/RpmWebGLTemplate.unitypackage";
private const string TEMPLATE_PACKAGE_PACKAGES_FOLDER = "Packages/com.readyplayerme.core/Editor/WebView/RpmWebGLTemplate.unitypackage";

[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{
Expand Down Expand Up @@ -50,18 +51,24 @@ private static void ShowWebGLScreen()
}

private static void OnConfirm()
{
AssetDatabase.ImportPackage(GetRelativeAssetPath(), false);
SetWebGLTemplate();
}
[MenuItem("RPM Tools/Setup WebGL Sample", priority = 13)]
public static void ImportAndSetup()
{
AssetDatabase.ImportPackage(GetRelativeAssetPath(), true);
SetWebGLTemplate();
}

private static string GetRelativeAssetPath()
{
var assetGuid = AssetDatabase.FindAssets(RPM_TEMPLATE_PACKAGE_NAME)[0];
var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
var relativePath = assetPath.Replace(Application.dataPath, "Assets");

return relativePath;
if(!Directory.Exists(TEMPLATE_PACKAGE_PACKAGES_FOLDER)){}
Debug.Log($"{TEMPLATE_PACKAGE_PACKAGES_FOLDER} does not exist");
if(Directory.Exists(TEMPLATE_PACKAGE_ASSETS_FOLDER))
Debug.Log($"{TEMPLATE_PACKAGE_ASSETS_FOLDER} does not exist");
return !Directory.Exists(TEMPLATE_PACKAGE_PACKAGES_FOLDER) ? TEMPLATE_PACKAGE_PACKAGES_FOLDER : TEMPLATE_PACKAGE_ASSETS_FOLDER;
}

private static void SetWebGLTemplate()
Expand Down

0 comments on commit 3788776

Please sign in to comment.