Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-727] feat: handle loading sample if installed in assets folder #198

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.IO;
using ReadyPlayerMe.Core.Analytics;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.UIElements;

Expand Down Expand Up @@ -85,6 +87,11 @@ private void RegisterButtons()

private void LoadAndOpenSample(string sampleName, string scenePath)
{
if (LoadFromAssetsFolder(sampleName, scenePath))
{
return;
}

var sampleLoader = new SampleLoader();

if (sampleLoader.Load(CORE_PACKAGE, sampleName))
Expand All @@ -96,6 +103,17 @@ private void LoadAndOpenSample(string sampleName, string scenePath)
EditorUtility.DisplayDialog(INTEGRATION_GUIDE, $"No sample with name {sampleName} found.", "OK");
}

private bool LoadFromAssetsFolder(string sampleName, string scenePath)
{
var folderPath = $"Assets/Ready Player Me/Core/Samples/{sampleName}";

if (!Directory.Exists(folderPath)) return false;
var fullScenePath = $"{folderPath}/{scenePath}.unity";
if (!File.Exists(fullScenePath)) return false;
EditorSceneManager.OpenScene(fullScenePath);
return true;
}

private void OpenDocumentation(string link)
{
Application.OpenURL(link);
Expand Down