Skip to content

Commit 3e5ee27

Browse files
authored
Refac evolution condition system (#14)
* serializereference-extensionをインストール * 進化条件のエディタ拡張を簡略化 * proFolderを追加 * 倍速機能を追加 * 敵の進化処理 * scriptのディレクトリ構造を整理 * カード画像を更新 * Update CLAUDE.md * Update build.yml * Update build.yml * Update build.yml * serialize-reference-extensionsをPluginsにインストール * Update EvolutionConditionGroup.cs * Update build.yml
1 parent 632ccd5 commit 3e5ee27

223 files changed

Lines changed: 7828 additions & 639 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,39 @@ jobs:
5050
Library-${{ runner.os }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}-
5151
Library-${{ runner.os }}-
5252
53+
- name: Verify Assets-based SerializeReferenceExtensions 📦
54+
run: |
55+
echo "🔍 Verifying Assets-based SerializeReferenceExtensions..."
56+
57+
# Assets配置の確認
58+
echo "📁 Checking Assets/Plugins directory:"
59+
ls -la Assets/Plugins/ || echo "❌ No Plugins directory"
60+
61+
if [ -d "Assets/Plugins/MackySoft.SerializeReferenceExtensions" ]; then
62+
echo "✅ SerializeReferenceExtensions found in Assets"
63+
echo "📁 Runtime directory:"
64+
ls -la Assets/Plugins/MackySoft.SerializeReferenceExtensions/Runtime/
65+
echo "📁 Editor directory:"
66+
ls -la Assets/Plugins/MackySoft.SerializeReferenceExtensions/Editor/
67+
68+
# 重要なファイルの存在確認
69+
if [ -f "Assets/Plugins/MackySoft.SerializeReferenceExtensions/Runtime/SubclassSelectorAttribute.cs" ]; then
70+
echo "✅ SubclassSelectorAttribute.cs found"
71+
else
72+
echo "❌ SubclassSelectorAttribute.cs NOT found"
73+
fi
74+
else
75+
echo "❌ SerializeReferenceExtensions NOT found in Assets"
76+
fi
77+
78+
# manifest.jsonの確認(Gitパッケージが削除されているか)
79+
echo "📄 Checking manifest.json (should not contain serializereference-extensions):"
80+
if grep -q "serializereference-extensions" Packages/manifest.json; then
81+
echo "❌ Git package reference still exists in manifest.json"
82+
else
83+
echo "✅ Git package reference removed from manifest.json"
84+
fi
85+
5386
- name: Build project 🏗️
5487
uses: game-ci/unity-builder@v4
5588
env:

Assets/Plugins.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/MackySoft.SerializeReferenceExtensions.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/MackySoft.SerializeReferenceExtensions/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
using System;
2+
using System.Linq;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
using UnityEditor;
6+
using UnityEditor.IMGUI.Controls;
7+
8+
namespace MackySoft.SerializeReferenceExtensions.Editor {
9+
10+
public class AdvancedTypePopupItem : AdvancedDropdownItem {
11+
12+
public Type Type { get; }
13+
14+
public AdvancedTypePopupItem (Type type,string name) : base(name) {
15+
Type = type;
16+
}
17+
18+
}
19+
20+
/// <summary>
21+
/// A type popup with a fuzzy finder.
22+
/// </summary>
23+
public class AdvancedTypePopup : AdvancedDropdown {
24+
25+
const int kMaxNamespaceNestCount = 16;
26+
27+
public static void AddTo (AdvancedDropdownItem root,IEnumerable<Type> types) {
28+
int itemCount = 0;
29+
30+
// Add null item.
31+
var nullItem = new AdvancedTypePopupItem(null,TypeMenuUtility.k_NullDisplayName) {
32+
id = itemCount++
33+
};
34+
root.AddChild(nullItem);
35+
36+
Type[] typeArray = types.OrderByType().ToArray();
37+
38+
// Single namespace if the root has one namespace and the nest is unbranched.
39+
bool isSingleNamespace = true;
40+
string[] namespaces = new string[kMaxNamespaceNestCount];
41+
foreach (Type type in typeArray) {
42+
string[] splittedTypePath = TypeMenuUtility.GetSplittedTypePath(type);
43+
if (splittedTypePath.Length <= 1) {
44+
continue;
45+
}
46+
// If they explicitly want sub category, let them do.
47+
if (TypeMenuUtility.GetAttribute(type) != null) {
48+
isSingleNamespace = false;
49+
break;
50+
}
51+
for (int k = 0;(splittedTypePath.Length - 1) > k;k++) {
52+
string ns = namespaces[k];
53+
if (ns == null) {
54+
namespaces[k] = splittedTypePath[k];
55+
}
56+
else if (ns != splittedTypePath[k]) {
57+
isSingleNamespace = false;
58+
break;
59+
}
60+
}
61+
62+
if (!isSingleNamespace) {
63+
break;
64+
}
65+
}
66+
67+
// Add type items.
68+
foreach (Type type in typeArray) {
69+
string[] splittedTypePath = TypeMenuUtility.GetSplittedTypePath(type);
70+
if (splittedTypePath.Length == 0) {
71+
continue;
72+
}
73+
74+
AdvancedDropdownItem parent = root;
75+
76+
// Add namespace items.
77+
if (!isSingleNamespace) {
78+
for (int k = 0;(splittedTypePath.Length - 1) > k;k++) {
79+
AdvancedDropdownItem foundItem = GetItem(parent,splittedTypePath[k]);
80+
if (foundItem != null) {
81+
parent = foundItem;
82+
}
83+
else {
84+
var newItem = new AdvancedDropdownItem(splittedTypePath[k]) {
85+
id = itemCount++,
86+
};
87+
parent.AddChild(newItem);
88+
parent = newItem;
89+
}
90+
}
91+
}
92+
93+
// Add type item.
94+
var item = new AdvancedTypePopupItem(type,ObjectNames.NicifyVariableName(splittedTypePath[splittedTypePath.Length - 1])) {
95+
id = itemCount++
96+
};
97+
parent.AddChild(item);
98+
}
99+
}
100+
101+
static AdvancedDropdownItem GetItem (AdvancedDropdownItem parent,string name) {
102+
foreach (AdvancedDropdownItem item in parent.children) {
103+
if (item.name == name) {
104+
return item;
105+
}
106+
}
107+
return null;
108+
}
109+
110+
static readonly float k_HeaderHeight = EditorGUIUtility.singleLineHeight * 2f;
111+
112+
Type[] m_Types;
113+
114+
public event Action<AdvancedTypePopupItem> OnItemSelected;
115+
116+
public AdvancedTypePopup (IEnumerable<Type> types,int maxLineCount,AdvancedDropdownState state) : base(state) {
117+
SetTypes(types);
118+
minimumSize = new Vector2(minimumSize.x,EditorGUIUtility.singleLineHeight * maxLineCount + k_HeaderHeight);
119+
}
120+
121+
public void SetTypes (IEnumerable<Type> types) {
122+
m_Types = types.ToArray();
123+
}
124+
125+
protected override AdvancedDropdownItem BuildRoot () {
126+
var root = new AdvancedDropdownItem("Select Type");
127+
AddTo(root,m_Types);
128+
return root;
129+
}
130+
131+
protected override void ItemSelected (AdvancedDropdownItem item) {
132+
base.ItemSelected(item);
133+
if (item is AdvancedTypePopupItem typePopupItem) {
134+
OnItemSelected?.Invoke(typePopupItem);
135+
}
136+
}
137+
138+
}
139+
}

Assets/Plugins/MackySoft.SerializeReferenceExtensions/Editor/AdvancedTypePopup.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "MackySoft.SerializeReferenceExtensions.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
6+
],
7+
"includePlatforms": [
8+
"Editor"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}

Assets/Plugins/MackySoft.SerializeReferenceExtensions/Editor/MackySoft.SerializeReferenceExtensions.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
2+
#if UNITY_2021_3_OR_NEWER
3+
using System;
4+
using UnityEditor;
5+
using UnityEngine;
6+
7+
namespace MackySoft.SerializeReferenceExtensions.Editor
8+
{
9+
public static class ManagedReferenceContextualPropertyMenu
10+
{
11+
12+
const string kCopiedPropertyPathKey = "SerializeReferenceExtensions.CopiedPropertyPath";
13+
const string kClipboardKey = "SerializeReferenceExtensions.CopyAndPasteProperty";
14+
15+
static readonly GUIContent kPasteContent = new GUIContent("Paste Property");
16+
static readonly GUIContent kNewInstanceContent = new GUIContent("New Instance");
17+
static readonly GUIContent kResetAndNewInstanceContent = new GUIContent("Reset and New Instance");
18+
19+
[InitializeOnLoadMethod]
20+
static void Initialize ()
21+
{
22+
EditorApplication.contextualPropertyMenu += OnContextualPropertyMenu;
23+
}
24+
25+
static void OnContextualPropertyMenu (GenericMenu menu, SerializedProperty property)
26+
{
27+
if (property.propertyType == SerializedPropertyType.ManagedReference)
28+
{
29+
// NOTE: When the callback function is called, the SerializedProperty is rewritten to the property that was being moused over at the time,
30+
// so a new SerializedProperty instance must be created.
31+
SerializedProperty clonedProperty = property.Copy();
32+
33+
menu.AddItem(new GUIContent($"Copy \"{property.propertyPath}\" property"), false, Copy, clonedProperty);
34+
35+
string copiedPropertyPath = SessionState.GetString(kCopiedPropertyPathKey, string.Empty);
36+
if (!string.IsNullOrEmpty(copiedPropertyPath))
37+
{
38+
menu.AddItem(new GUIContent($"Paste \"{copiedPropertyPath}\" property"), false, Paste, clonedProperty);
39+
}
40+
else
41+
{
42+
menu.AddDisabledItem(kPasteContent);
43+
}
44+
45+
menu.AddSeparator("");
46+
47+
bool hasInstance = clonedProperty.managedReferenceValue != null;
48+
if (hasInstance)
49+
{
50+
menu.AddItem(kNewInstanceContent, false, NewInstance, clonedProperty);
51+
menu.AddItem(kResetAndNewInstanceContent, false, ResetAndNewInstance, clonedProperty);
52+
}
53+
else
54+
{
55+
menu.AddDisabledItem(kNewInstanceContent);
56+
menu.AddDisabledItem(kResetAndNewInstanceContent);
57+
}
58+
}
59+
}
60+
61+
static void Copy (object customData)
62+
{
63+
SerializedProperty property = (SerializedProperty)customData;
64+
string json = JsonUtility.ToJson(property.managedReferenceValue);
65+
SessionState.SetString(kCopiedPropertyPathKey, property.propertyPath);
66+
SessionState.SetString(kClipboardKey, json);
67+
}
68+
69+
static void Paste (object customData)
70+
{
71+
SerializedProperty property = (SerializedProperty)customData;
72+
string json = SessionState.GetString(kClipboardKey, string.Empty);
73+
if (string.IsNullOrEmpty(json))
74+
{
75+
return;
76+
}
77+
78+
Undo.RecordObject(property.serializedObject.targetObject, "Paste Property");
79+
JsonUtility.FromJsonOverwrite(json, property.managedReferenceValue);
80+
property.serializedObject.ApplyModifiedProperties();
81+
}
82+
83+
static void NewInstance (object customData)
84+
{
85+
SerializedProperty property = (SerializedProperty)customData;
86+
string json = JsonUtility.ToJson(property.managedReferenceValue);
87+
88+
Undo.RecordObject(property.serializedObject.targetObject, "New Instance");
89+
property.managedReferenceValue = JsonUtility.FromJson(json, property.managedReferenceValue.GetType());
90+
property.serializedObject.ApplyModifiedProperties();
91+
92+
Debug.Log($"Create new instance of \"{property.propertyPath}\".");
93+
}
94+
95+
static void ResetAndNewInstance (object customData)
96+
{
97+
SerializedProperty property = (SerializedProperty)customData;
98+
99+
Undo.RecordObject(property.serializedObject.targetObject, "Reset and New Instance");
100+
property.managedReferenceValue = Activator.CreateInstance(property.managedReferenceValue.GetType());
101+
property.serializedObject.ApplyModifiedProperties();
102+
103+
Debug.Log($"Reset property and created new instance of \"{property.propertyPath}\".");
104+
}
105+
}
106+
}
107+
#endif

Assets/Plugins/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceContextualPropertyMenu.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)