From 378877650c100766acb5939da4937ad0e07d7225 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Thu, 11 Jan 2024 10:18:38 +0200 Subject: [PATCH] chore: try with paths --- .../Editor/EditorWindows/SampleSetup.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Samples~/WebGLSample/Editor/EditorWindows/SampleSetup.cs b/Samples~/WebGLSample/Editor/EditorWindows/SampleSetup.cs index 57176f82..3099890e 100644 --- a/Samples~/WebGLSample/Editor/EditorWindows/SampleSetup.cs +++ b/Samples~/WebGLSample/Editor/EditorWindows/SampleSetup.cs @@ -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() { @@ -50,6 +51,12 @@ 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(); @@ -57,11 +64,11 @@ private static void OnConfirm() 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()