Skip to content

Commit 6853934

Browse files
authored
Codegen dep (#155)
* remove dependency of essential package from codegen package to avoid circular dependency. * fix #152 Print error log if there's no `BehaviorNode` attribute on an `INodeData` structure.
1 parent 8e2909f commit 6853934

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Packages/codegen/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
{
22
"name": "com.quabug.entities-bt.codegen",
33
"description": "Behavior Tree for Unity Entities - ILCodeGen",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"unity": "2020.2",
66
"displayName": "EntitiesBT - IL CodeGen",
7-
"dependencies": {
8-
"com.quabug.entities-bt.essential": "1.1.0"
9-
},
107
"samples": [
118
{
129
"displayName": "[Test] tests",
1310
"description": "test cases of il codegen",
1411
"path": "Test~"
1512
}
1613
]
17-
}
14+
}

Packages/essential/Editor/BehaviorNodeValidator.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using EntitiesBT.Core;
66
using UnityEditor.Callbacks;
7+
using UnityEngine;
78
using static EntitiesBT.Core.Utilities;
89

910
namespace EntitiesBT.Editor
@@ -16,12 +17,25 @@ public static void OnReload()
1617
var dictionary = new Dictionary<int, (Type type, BehaviorNodeAttribute attribute)>(128);
1718
foreach (var type in BEHAVIOR_TREE_ASSEMBLY_TYPES.Value)
1819
{
20+
if (type.IsInterface
21+
|| type.IsAbstract
22+
|| type.IsGenericType
23+
|| !typeof(INodeData).IsAssignableFrom(type))
24+
continue;
25+
1926
var attributes = type.GetCustomAttributes(typeof(BehaviorNodeAttribute));
20-
if (!attributes.Any()) continue;
21-
27+
if (!attributes.Any())
28+
{
29+
Debug.LogError($"{type.FullName} must have a BehaviorNodeAttribute");
30+
continue;
31+
}
32+
2233
var behaviorNodeAttribute = attributes.First() as BehaviorNodeAttribute;
2334
if (dictionary.TryGetValue(behaviorNodeAttribute.Id, out var other))
24-
throw new Exception($"{other.type.FullName} has same id {behaviorNodeAttribute.Id} with {type.FullName}");
35+
{
36+
Debug.LogError($"{other.type.FullName} has same id {behaviorNodeAttribute.Id} with {type.FullName}");
37+
continue;
38+
}
2539
dictionary.Add(behaviorNodeAttribute.Id, (type, behaviorNodeAttribute));
2640
}
2741
}

Packages/essential/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "com.quabug.entities-bt.essential",
33
"description": "Behavior Tree for Unity Entities - Essential",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"unity": "2020.2",
66
"displayName": "EntitiesBT - Essential",
77
"dependencies": {
88
"com.unity.entities": "0.14.0-preview.19",
9-
"com.quabug.entities-bt.codegen": "1.0.0"
9+
"com.quabug.entities-bt.codegen": "1.0.1"
1010
}
11-
}
11+
}

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
m_EditorVersion: 2020.2.4f1
2-
m_EditorVersionWithRevision: 2020.2.4f1 (becced5a802b)
1+
m_EditorVersion: 2020.2.6f1
2+
m_EditorVersionWithRevision: 2020.2.6f1 (8a2143876886)

0 commit comments

Comments
 (0)