Visitor scene does not have to be in build settings anymore
(only to select it in preferences for now).
This commit is contained in:
parent
2294c78e90
commit
1f4e410688
@ -302,8 +302,6 @@ namespace Passer.Humanoid {
|
|||||||
ix = 0;
|
ix = 0;
|
||||||
ix = EditorGUILayout.Popup("Testing Visitor", ix, personalHumanoidNames);
|
ix = EditorGUILayout.Popup("Testing Visitor", ix, personalHumanoidNames);
|
||||||
anyChanged = humanoidSceneNameProp.stringValue != HumanoidVisitors.visitors[ix];
|
anyChanged = humanoidSceneNameProp.stringValue != HumanoidVisitors.visitors[ix];
|
||||||
if (anyChanged)
|
|
||||||
Passer.Humanoid.HumanoidVisitors.SetPersonalHumanoid(humanoidSceneNameProp.stringValue, HumanoidVisitors.visitors[ix]);
|
|
||||||
|
|
||||||
humanoidSceneNameProp.stringValue = HumanoidVisitors.visitors[ix];
|
humanoidSceneNameProp.stringValue = HumanoidVisitors.visitors[ix];
|
||||||
return anyChanged;
|
return anyChanged;
|
||||||
|
@ -131,7 +131,7 @@ namespace Passer.Humanoid {
|
|||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
static class HumanoidPreferencesIMGUIRegister {
|
static class HumanoidPreferencesIMGUIRegister {
|
||||||
public static bool reload;
|
//public static bool reload;
|
||||||
|
|
||||||
[SettingsProvider]
|
[SettingsProvider]
|
||||||
public static SettingsProvider CreateHumanoidSettingsProvider() {
|
public static SettingsProvider CreateHumanoidSettingsProvider() {
|
||||||
@ -139,39 +139,8 @@ namespace Passer.Humanoid {
|
|||||||
label = "Humanoid Control",
|
label = "Humanoid Control",
|
||||||
guiHandler = (searchContext) => {
|
guiHandler = (searchContext) => {
|
||||||
|
|
||||||
//SerializedObject serializedSettings = HumanoidPreferences.GetOrCreateSerializedSettings();
|
|
||||||
|
|
||||||
//SerializedProperty configurationProp = serializedSettings.FindProperty("configuration");
|
|
||||||
//Configuration oldConfiguration = (Configuration)configurationProp.objectReferenceValue;
|
|
||||||
|
|
||||||
//configurationProp.objectReferenceValue = EditorGUILayout.ObjectField("Configuration", configurationProp.objectReferenceValue, typeof(Configuration), false);
|
|
||||||
//SerializedObject serializedConfiguration = new SerializedObject(configurationProp.objectReferenceValue);
|
|
||||||
|
|
||||||
//bool anyChanged = false;
|
|
||||||
//anyChanged |= (configurationProp.objectReferenceValue != oldConfiguration);
|
|
||||||
//anyChanged |= Configuration_Editor.ConfigurationGUI(serializedConfiguration);
|
|
||||||
//serializedConfiguration.ApplyModifiedProperties();
|
|
||||||
//serializedSettings.ApplyModifiedProperties();
|
|
||||||
|
|
||||||
//Configuration_Editor.CheckExtensions((Configuration)configurationProp.objectReferenceValue);
|
|
||||||
|
|
||||||
VisitorSceneInspector();
|
VisitorSceneInspector();
|
||||||
|
|
||||||
// if (reload) {
|
|
||||||
// reload = false;
|
|
||||||
//#if hUNET
|
|
||||||
// OnLoadHumanoidPlayerUnet.CheckHumanoidPlayer();
|
|
||||||
//#endif
|
|
||||||
//#if hPHOTON1 || hPHOTON2
|
|
||||||
// OnLoadHumanoidPlayerPun.CheckHumanoidPlayer();
|
|
||||||
//#endif
|
|
||||||
//#if hBOLT
|
|
||||||
// OnLoadHumanoidPlayerBolt.CheckHumanoidPlayer();
|
|
||||||
//#endif
|
|
||||||
//#if hMIRROR
|
|
||||||
// OnLoadHumanoidPlayerMirror.CheckHumanoidPlayer();
|
|
||||||
//#endif
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
keywords = new HashSet<string>(
|
keywords = new HashSet<string>(
|
||||||
new[] { "Humanoid", "Oculus", "SteamVR" }
|
new[] { "Humanoid", "Oculus", "SteamVR" }
|
||||||
@ -207,8 +176,6 @@ namespace Passer.Humanoid {
|
|||||||
ix = 0;
|
ix = 0;
|
||||||
ix = EditorGUILayout.Popup("Default Visitor scene", ix, visitorNames);
|
ix = EditorGUILayout.Popup("Default Visitor scene", ix, visitorNames);
|
||||||
anyChanged = visitorSceneName != HumanoidVisitors.visitors[ix];
|
anyChanged = visitorSceneName != HumanoidVisitors.visitors[ix];
|
||||||
if (anyChanged)
|
|
||||||
HumanoidVisitors.SetPersonalHumanoid(visitorSceneName, HumanoidVisitors.visitors[ix]);
|
|
||||||
|
|
||||||
HumanoidPreferences.visitorSceneName = HumanoidVisitors.visitors[ix];
|
HumanoidPreferences.visitorSceneName = HumanoidVisitors.visitors[ix];
|
||||||
|
|
||||||
|
@ -45,10 +45,10 @@ namespace Passer {
|
|||||||
|
|
||||||
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
||||||
if (humanoid == null) {
|
if (humanoid == null) {
|
||||||
string visitorSceneName = HumanoidPreferences.visitorSceneName;
|
string visitorScenePath = HumanoidPreferences.visitorSceneName;
|
||||||
if (!string.IsNullOrEmpty(visitorSceneName)) {
|
if (!string.IsNullOrEmpty(visitorScenePath)) {
|
||||||
//Debug.Log(visitorSceneName);
|
//Debug.Log(visitorSceneName);
|
||||||
UnityEngine.SceneManagement.SceneManager.LoadScene(visitorSceneName, LoadSceneMode.Additive);
|
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(visitorScenePath, new LoadSceneParameters(LoadSceneMode.Additive));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.LogWarning("Could not start Visitor: Please select Default Visitor Scene in Edit Menu->Preferences->Humanoid Control");
|
Debug.LogWarning("Could not start Visitor: Please select Default Visitor Scene in Edit Menu->Preferences->Humanoid Control");
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace Passer.Humanoid {
|
namespace Passer.Humanoid {
|
||||||
@ -12,97 +10,18 @@ namespace Passer.Humanoid {
|
|||||||
public static List<string> visitors = new List<string>();
|
public static List<string> visitors = new List<string>();
|
||||||
|
|
||||||
static HumanoidVisitors() {
|
static HumanoidVisitors() {
|
||||||
//CheckVisitors();
|
|
||||||
CheckScenes();
|
CheckScenes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string fileName = "HumanoidVisitors.cs";
|
|
||||||
|
|
||||||
public static void CheckScenes() {
|
public static void CheckScenes() {
|
||||||
EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
||||||
foreach (EditorBuildSettingsScene editorBuildSettingsScene in editorBuildSettingsScenes) {
|
foreach (EditorBuildSettingsScene editorBuildSettingsScene in editorBuildSettingsScenes) {
|
||||||
string localSceneName = editorBuildSettingsScene.path;
|
string localSceneName = editorBuildSettingsScene.path;
|
||||||
if (!visitors.Contains(localSceneName))
|
if (!visitors.Contains(localSceneName)) {
|
||||||
visitors.Add(localSceneName);
|
visitors.Add(localSceneName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private static void CheckVisitors() {
|
|
||||||
// string[] names = Directory.GetFiles(Application.dataPath, "HumanoidVisitors.cs", SearchOption.AllDirectories);
|
|
||||||
// int dataPathLength = Application.dataPath.Length;
|
|
||||||
|
|
||||||
// int filenameLength = fileName.Length;
|
|
||||||
// foreach (string name in names) {
|
|
||||||
// string dirName = name.Substring(0, name.Length - filenameLength);
|
|
||||||
|
|
||||||
// string[] sceneNames = Directory.GetFiles(dirName, "*.unity");
|
|
||||||
|
|
||||||
// foreach (string sceneName in sceneNames) {
|
|
||||||
// string localSceneName = "Assets" + sceneName.Substring(dataPathLength);
|
|
||||||
// localSceneName = localSceneName.Replace('\\', '/');
|
|
||||||
// if (!visitors.Contains(localSceneName))
|
|
||||||
// visitors.Add(localSceneName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static bool SceneExists(string scenePath) {
|
|
||||||
foreach (EditorBuildSettingsScene buildScene in EditorBuildSettings.scenes) {
|
|
||||||
if (buildScene.path == scenePath)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void AddScene(string scenePath) {
|
|
||||||
if (SceneExists(scenePath))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Debug.Log("Add " + scenePath);
|
|
||||||
|
|
||||||
EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
|
||||||
EditorBuildSettingsScene[] newEditorBuildSettingsScenes = new EditorBuildSettingsScene[editorBuildSettingsScenes.Length + 1];
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < editorBuildSettingsScenes.Length; i++) {
|
|
||||||
newEditorBuildSettingsScenes[i] = editorBuildSettingsScenes[i];
|
|
||||||
}
|
|
||||||
newEditorBuildSettingsScenes[i] = new EditorBuildSettingsScene(scenePath, true);
|
|
||||||
EditorBuildSettings.scenes = newEditorBuildSettingsScenes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RemoveScene(string scenePath) {
|
|
||||||
if (!SceneExists(scenePath))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Debug.Log("Remove " + scenePath);
|
|
||||||
|
|
||||||
EditorBuildSettingsScene[] editorBuildSettingsScenes = EditorBuildSettings.scenes;
|
|
||||||
EditorBuildSettingsScene[] newEditorBuildSettingsScenes = new EditorBuildSettingsScene[editorBuildSettingsScenes.Length - 1];
|
|
||||||
|
|
||||||
int i;
|
|
||||||
int j = 0;
|
|
||||||
bool found = false;
|
|
||||||
for (i = 0; i < editorBuildSettingsScenes.Length; i++) {
|
|
||||||
if (editorBuildSettingsScenes[i].path != scenePath) {
|
|
||||||
// Check if we do not find the scene to remove
|
|
||||||
if (j < editorBuildSettingsScenes.Length - 1)
|
|
||||||
newEditorBuildSettingsScenes[j++] = editorBuildSettingsScenes[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
if (found)
|
|
||||||
EditorBuildSettings.scenes = newEditorBuildSettingsScenes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetPersonalHumanoid(string oldSceneName, string newSceneName) {
|
|
||||||
if (!HumanoidVisitors.visitors.Contains(newSceneName))
|
|
||||||
return;
|
|
||||||
|
|
||||||
RemoveScene(oldSceneName);
|
|
||||||
AddScene(newSceneName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user