forked from Shardstone/trail-into-darkness
First commit on my server, yey!
This commit is contained in:
46
Assets/Code/Util/BootMode.cs
Normal file
46
Assets/Code/Util/BootMode.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.EditorCode {
|
||||
#if UNITY_EDITOR
|
||||
public enum BootType {
|
||||
FullBoot,
|
||||
SceneBoot,
|
||||
UnityDefault
|
||||
}
|
||||
/// <summary>
|
||||
/// Allows the user to set the boot mode for the project which will be used by the EntryPoint to mark if the startup scene should be loaded or not
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public class BootMode : MonoBehaviour {
|
||||
public static BootType BootType {
|
||||
get => (BootType)EditorPrefs.GetInt("bootType");
|
||||
private set {
|
||||
EditorPrefs.SetInt("bootType", (int)value);
|
||||
Debug.Log($"Boot mode {BootType} set...");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
if(!EditorPrefs.HasKey("bootType")) {
|
||||
BootType = BootType.UnityDefault;
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Nox/Boot/Full Boot...", false)]
|
||||
private static void SetFullBoot() {
|
||||
BootType = BootType.FullBoot;
|
||||
}
|
||||
|
||||
[MenuItem("Nox/Boot/Scene Boot...", false)]
|
||||
private static void SetSceneBoot() {
|
||||
BootType = BootType.SceneBoot;
|
||||
}
|
||||
|
||||
[MenuItem("Nox/Boot/Unity Default No Boot...", false)]
|
||||
private static void SetDefaultBoot() {
|
||||
BootType = BootType.UnityDefault;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
2
Assets/Code/Util/BootMode.cs.meta
Normal file
2
Assets/Code/Util/BootMode.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2108493160a8044a1b742355e4fc0e9c
|
||||
8
Assets/Code/Util/Editor.meta
Normal file
8
Assets/Code/Util/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62f869281de314cf7956996cef15aefa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/Code/Util/Editor/SceneReferenceEditor.cs
Normal file
28
Assets/Code/Util/Editor/SceneReferenceEditor.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.Core
|
||||
{
|
||||
[CustomEditor(typeof(SceneReference))]
|
||||
public class SceneReferenceEditor : Editor {
|
||||
private SceneReference sceneReference;
|
||||
|
||||
private SerializedProperty gameState;
|
||||
private SerializedProperty playMode;
|
||||
|
||||
private void OnEnable() {
|
||||
sceneReference = (SceneReference)target;
|
||||
playMode = serializedObject.FindProperty("playMode");
|
||||
gameState = serializedObject.FindProperty("gameState");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
EditorGUILayout.PropertyField(gameState, new GUIContent("Game Active State"));
|
||||
if(sceneReference.gameState == GameState.GameMode) {
|
||||
EditorGUILayout.PropertyField(playMode, new GUIContent("Play Mode"));
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Code/Util/Editor/SceneReferenceEditor.cs.meta
Normal file
3
Assets/Code/Util/Editor/SceneReferenceEditor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6fdc03906db404a8f51b19aadd8e304
|
||||
timeCreated: 1770537083
|
||||
Reference in New Issue
Block a user