initial commit

This commit is contained in:
cblech
2025-01-04 13:29:07 +01:00
commit 22f67f4347
124 changed files with 12157 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;
#if UNITY_EDITOR
using UnityEditor;
#endif
[Serializable]
public class SwitchableScene
{
public int index;
}
#if UNITY_EDITOR
// custom property drawer
[CustomPropertyDrawer(typeof(SwitchableScene))]
public class SwitchableSceneDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
// Get the SceneSwitcher component
if (SceneSwitcher.Instance == null)
{
return new Label("SceneSwitcher component not found in the scene.");
}
// create dropdown based on the SceneSwitcher options
var root = new VisualElement();
// Get the list of scenes
List<(string name, int index)> scenes = SceneSwitcher.Instance.GetScenes();
// create dropdown
var indexProperty = property.FindPropertyRelative("index");
var dropdown = new PopupField<string>("Scene", scenes.ConvertAll(t => t.name), scenes[indexProperty.intValue].name);
dropdown.RegisterValueChangedCallback(evt =>
{
indexProperty.intValue = scenes.FindIndex(t => t.name == evt.newValue);
indexProperty.serializedObject.ApplyModifiedProperties();
});
root.Add(dropdown);
return root;
}
}
#endif