44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using Cielonos.Core.Interaction;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace Cielonos.MainGame.Interactions
|
|
{
|
|
public partial class SceneTeleportationSite : InteractableObjectBase
|
|
{
|
|
[ValueDropdown("GetAllSceneNames")]
|
|
public string targetSceneName;
|
|
|
|
protected override void InitializeChoices()
|
|
{
|
|
choices.Add(new InteractionChoice("Teleport", Teleport));
|
|
}
|
|
|
|
private void Teleport()
|
|
{
|
|
if (targetSceneName != "")
|
|
{
|
|
Debug.Log($"[SceneTeleportationSite] Teleporting to scene: {targetSceneName}");
|
|
SceneManager.LoadScene(targetSceneName);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class SceneTeleportationSite
|
|
{
|
|
private List<string> GetAllSceneNames()
|
|
{
|
|
List<string> sceneNames = new List<string>();
|
|
int sceneCount = SceneManager.sceneCountInBuildSettings;
|
|
for (int i = 0; i < sceneCount; i++)
|
|
{
|
|
string path = SceneUtility.GetScenePathByBuildIndex(i);
|
|
string name = System.IO.Path.GetFileNameWithoutExtension(path);
|
|
sceneNames.Add(name);
|
|
}
|
|
return sceneNames;
|
|
}
|
|
}
|
|
} |