Visitor Start Site no longer needs to be in build settings
This commit is contained in:
parent
3b2abc2dd9
commit
54c09cc9ab
@ -9,43 +9,45 @@ namespace Passer {
|
|||||||
public class SiteNavigator_Editor : Editor {
|
public class SiteNavigator_Editor : Editor {
|
||||||
protected SiteNavigator siteNavigator;
|
protected SiteNavigator siteNavigator;
|
||||||
|
|
||||||
protected string[] siteNames;
|
//protected string[] siteNames;
|
||||||
|
|
||||||
#region Enable
|
#region Enable
|
||||||
|
|
||||||
protected virtual void OnEnable() {
|
protected virtual void OnEnable() {
|
||||||
siteNavigator = (SiteNavigator)target;
|
siteNavigator = (SiteNavigator)target;
|
||||||
|
|
||||||
InitializeSiteNames();
|
//InitializeSiteNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void InitializeSiteNames() {
|
//protected virtual void InitializeSiteNames() {
|
||||||
//HumanoidVisitors.CheckScenes();
|
// //HumanoidVisitors.CheckScenes();
|
||||||
//List<string> humanoidVisitors = HumanoidVisitors.visitors;
|
// //List<string> humanoidVisitors = HumanoidVisitors.visitors;
|
||||||
|
|
||||||
EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
// EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
||||||
int siteCount = editorBuildSettingsScenes.Length; // - HumanoidVisitors.visitors.Count;
|
// int siteCount = editorBuildSettingsScenes.Length; // - HumanoidVisitors.visitors.Count;
|
||||||
|
|
||||||
List<string> siteList = new List<string>();
|
// List<string> siteList = new List<string>();
|
||||||
siteList.Add("-none-");
|
// siteList.Add("-none-");
|
||||||
for (int i = 0; i < siteCount; i++) {
|
// for (int i = 0; i < siteCount; i++) {
|
||||||
if (!editorBuildSettingsScenes[i].enabled) {
|
// if (!editorBuildSettingsScenes[i].enabled) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
string sceneName = editorBuildSettingsScenes[i].path;
|
// string sceneName = editorBuildSettingsScenes[i].path;
|
||||||
int lastSlash = sceneName.LastIndexOf('/');
|
// if (sceneName.Length > 6) {
|
||||||
sceneName = sceneName.Substring(lastSlash + 1);
|
// int lastSlash = sceneName.LastIndexOf('/');
|
||||||
sceneName = sceneName.Substring(0, sceneName.Length - 6); // remove .unity
|
// sceneName = sceneName.Substring(lastSlash + 1);
|
||||||
|
// sceneName = sceneName.Substring(0, sceneName.Length - 6); // remove .unity
|
||||||
|
|
||||||
// Does not work at the moment the visitors are all scenes
|
// // Does not work at the moment the visitors are all scenes
|
||||||
//bool isVisitor = IsHumanoidVisitor(sceneName, humanoidVisitors);
|
// //bool isVisitor = IsHumanoidVisitor(sceneName, humanoidVisitors);
|
||||||
//if (!isVisitor) {
|
// //if (!isVisitor) {
|
||||||
siteList.Add(sceneName);
|
// siteList.Add(sceneName);
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// siteNames = siteList.ToArray();//new string[siteCount];
|
||||||
//}
|
//}
|
||||||
}
|
|
||||||
siteNames = siteList.ToArray();//new string[siteCount];
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsHumanoidVisitor(string sceneName, List<string> humanoidVisitors) {
|
private bool IsHumanoidVisitor(string sceneName, List<string> humanoidVisitors) {
|
||||||
foreach(string visitor in humanoidVisitors) {
|
foreach(string visitor in humanoidVisitors) {
|
||||||
@ -92,34 +94,17 @@ namespace Passer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void StartSceneInspector() {
|
protected void StartSceneInspector() {
|
||||||
|
SerializedProperty startSceneProp = serializedObject.FindProperty(nameof(siteNavigator.startScene));
|
||||||
|
SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(startSceneProp.stringValue);
|
||||||
|
|
||||||
GUIContent text = new GUIContent(
|
GUIContent text = new GUIContent(
|
||||||
"Start Scene",
|
"Start Scene",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
sceneAsset = (SceneAsset)EditorGUILayout.ObjectField(text, sceneAsset, typeof(SceneAsset), false);
|
||||||
|
|
||||||
SerializedProperty startSceneProp = serializedObject.FindProperty(nameof(siteNavigator.startScene));
|
startSceneProp.stringValue = AssetDatabase.GetAssetPath(sceneAsset);
|
||||||
|
|
||||||
if (siteNames == null || siteNames.Length == 0) {
|
|
||||||
startSceneProp.stringValue = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ix = 0;
|
|
||||||
for (; ix < siteNames.Length; ix++) {
|
|
||||||
if (siteNames[ix] == startSceneProp.stringValue)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ix == siteNames.Length) ix = 0;
|
|
||||||
if (Application.isPlaying) {
|
|
||||||
using (new EditorGUI.DisabledScope(true)) {
|
|
||||||
EditorGUILayout.Popup(text, ix, siteNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
ix = EditorGUILayout.Popup(text, ix, siteNames);
|
|
||||||
startSceneProp.stringValue = siteNames[ix];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Inspector
|
#endregion Inspector
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace Passer {
|
namespace Passer {
|
||||||
|
|
||||||
@ -65,7 +66,8 @@ namespace Passer {
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (startScene != null && startScene != "" && startScene != "-none-") {
|
if (startScene != null && startScene != "" && startScene != "-none-") {
|
||||||
Debug.Log("Load scene " + startScene);
|
Debug.Log("Load scene " + startScene);
|
||||||
UnityEngine.SceneManagement.SceneManager.LoadScene(startScene);
|
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(startScene, new LoadSceneParameters(LoadSceneMode.Additive));
|
||||||
|
//UnityEngine.SceneManagement.SceneManager.LoadScene(startScene);
|
||||||
currentSite = new HistoryEntry() {
|
currentSite = new HistoryEntry() {
|
||||||
siteName = "directload",
|
siteName = "directload",
|
||||||
siteLocation = "passervr.com/sites/start",
|
siteLocation = "passervr.com/sites/start",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user