First commit for private source control. Older commits available on Github.
This commit is contained in:
79
Assets/Scripts/Editor/Drawers/BaseInteractionDrawer.cs
Normal file
79
Assets/Scripts/Editor/Drawers/BaseInteractionDrawer.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BriarQueen.Framework.Managers.Interaction.Data;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Editor.Drawers
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(BaseInteraction), true)]
|
||||
public class BaseItemInteractionDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
if (property.managedReferenceValue == null)
|
||||
{
|
||||
if (GUI.Button(position, "Select Interaction Type"))
|
||||
{
|
||||
ShowTypeMenu(property);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
return;
|
||||
}
|
||||
|
||||
var type = property.managedReferenceValue.GetType();
|
||||
var headerRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
if (GUI.Button(headerRect, type.Name, EditorStyles.popup))
|
||||
{
|
||||
ShowTypeMenu(property);
|
||||
}
|
||||
|
||||
var bodyRect = new Rect(
|
||||
position.x,
|
||||
position.y + EditorGUIUtility.singleLineHeight + 2,
|
||||
position.width,
|
||||
position.height - EditorGUIUtility.singleLineHeight - 2);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUI.PropertyField(bodyRect, property, GUIContent.none, true);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
private void ShowTypeMenu(SerializedProperty property)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes())
|
||||
.Where(t =>
|
||||
!t.IsAbstract &&
|
||||
typeof(BaseInteraction).IsAssignableFrom(t));
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
menu.AddItem(new GUIContent(type.Name), false, () =>
|
||||
{
|
||||
property.serializedObject.Update();
|
||||
property.managedReferenceValue = Activator.CreateInstance(type);
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (property.managedReferenceValue == null)
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
|
||||
return EditorGUI.GetPropertyHeight(property, true) + EditorGUIUtility.singleLineHeight + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 627cc55408bb4796839600a1516a5eba
|
||||
timeCreated: 1771172177
|
||||
3
Assets/Scripts/Editor/Drawers/Registries.meta
Normal file
3
Assets/Scripts/Editor/Drawers/Registries.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c40c1262cbd4128a9b3c3446304a845
|
||||
timeCreated: 1773921681
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Data.Assets;
|
||||
using BriarQueen.Framework.Registries;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Editor.Drawers.Registries
|
||||
{
|
||||
[CustomEditor(typeof(AssetRegistry))]
|
||||
public class AssetRegistryFill : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Discover AssetEntry Assets"))
|
||||
{
|
||||
Populate((AssetRegistry)target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Populate(AssetRegistry registry)
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("t:AssetEntry");
|
||||
|
||||
var scenes = new List<AssetEntry>();
|
||||
var levels = new List<AssetEntry>();
|
||||
var items = new List<AssetEntry>();
|
||||
var ui = new List<AssetEntry>();
|
||||
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var entry = AssetDatabase.LoadAssetAtPath<AssetEntry>(path);
|
||||
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
switch (entry.EntryType)
|
||||
{
|
||||
case AssetEntry.AssetEntryType.Scene:
|
||||
scenes.Add(entry);
|
||||
break;
|
||||
|
||||
case AssetEntry.AssetEntryType.Level:
|
||||
levels.Add(entry);
|
||||
break;
|
||||
|
||||
case AssetEntry.AssetEntryType.Item:
|
||||
items.Add(entry);
|
||||
break;
|
||||
|
||||
case AssetEntry.AssetEntryType.UI:
|
||||
ui.Add(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
scenes.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
levels.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
items.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
ui.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
|
||||
Undo.RecordObject(registry, "Discover AssetEntry Assets");
|
||||
registry.SetDiscoveredEntries(scenes, levels, items, ui);
|
||||
EditorUtility.SetDirty(registry);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
Debug.Log($"[AssetRegistry] Discovery complete. Scenes: {scenes.Count}, Levels: {levels.Count}, Items: {items.Count}, UI: {ui.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f49114100e741bb849cbdfb5fc457cc
|
||||
timeCreated: 1773602794
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Registries;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Editor.Drawers.Registries
|
||||
{
|
||||
[CustomEditor(typeof(CodexRegistry))]
|
||||
public class CodexRegistryFill : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Discover Codex Entry Assets"))
|
||||
{
|
||||
Populate((CodexRegistry)target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Populate(CodexRegistry registry)
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("t:CodexEntrySo");
|
||||
|
||||
var books = new List<CodexEntrySo>();
|
||||
var clues = new List<CodexEntrySo>();
|
||||
var photos = new List<CodexEntrySo>();
|
||||
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var entry = AssetDatabase.LoadAssetAtPath<CodexEntrySo>(path);
|
||||
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
switch (entry.EntryType)
|
||||
{
|
||||
case CodexType.BookEntry:
|
||||
books.Add(entry);
|
||||
break;
|
||||
|
||||
case CodexType.PuzzleClue:
|
||||
clues.Add(entry);
|
||||
break;
|
||||
|
||||
case CodexType.Photo:
|
||||
photos.Add(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
books.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
clues.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
photos.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
|
||||
Undo.RecordObject(registry, "Discover Codex Assets");
|
||||
registry.SetDiscoveredEntries(books, clues, photos);
|
||||
EditorUtility.SetDirty(registry);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
Debug.Log($"[AssetRegistry] Discovery complete. Books: {books.Count}, Clues: {clues.Count}, Photos: {photos.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04adf387d1e94429a6c320005150cb90
|
||||
timeCreated: 1773921705
|
||||
69
Assets/Scripts/Editor/Drawers/Registries/ItemRegistryFill.cs
Normal file
69
Assets/Scripts/Editor/Drawers/Registries/ItemRegistryFill.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Registries;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Editor.Drawers.Registries
|
||||
{
|
||||
[CustomEditor(typeof(ItemRegistry))]
|
||||
public class ItemRegistryFill : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Discover Item Assets"))
|
||||
{
|
||||
Populate((ItemRegistry)target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Populate(ItemRegistry registry)
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("t:ItemDataSo");
|
||||
|
||||
var puzzleSlots = new List<ItemDataSo>();
|
||||
var pickupItems = new List<ItemDataSo>();
|
||||
var environmentInteractables = new List<ItemDataSo>();
|
||||
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var entry = AssetDatabase.LoadAssetAtPath<ItemDataSo>(path);
|
||||
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
switch (entry.IdType)
|
||||
{
|
||||
case ItemDataSo.ItemIdType.PuzzleSlot:
|
||||
puzzleSlots.Add(entry);
|
||||
break;
|
||||
|
||||
case ItemDataSo.ItemIdType.Pickup:
|
||||
pickupItems.Add(entry);
|
||||
break;
|
||||
|
||||
case ItemDataSo.ItemIdType.Environment:
|
||||
environmentInteractables.Add(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
puzzleSlots.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
pickupItems.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
environmentInteractables.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
||||
|
||||
Undo.RecordObject(registry, "Discover Item Assets");
|
||||
registry.SetDiscoveredEntries(puzzleSlots, pickupItems, environmentInteractables);
|
||||
EditorUtility.SetDirty(registry);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
Debug.Log(
|
||||
$"[ItemRegistry] Discovery complete. Puzzle Slots: {puzzleSlots.Count}, Pickup Items: {pickupItems.Count}, Environment Interactables: {environmentInteractables.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9e6445d7af341b6995266514b666497
|
||||
timeCreated: 1773921699
|
||||
Reference in New Issue
Block a user