提交 1e011287 编写于 作者: T tanghai

修复行为树编辑器一些错误

上级 bf5a32b6
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Base;
using UnityEditor;
using UnityEngine;
......@@ -12,15 +14,23 @@ namespace MyEditor
public static Texture2D GetTexture(string imageName)
{
if (!mTextureDict.ContainsKey(imageName))
try
{
Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>(ImagePathName + imageName + ".png");
if (tex != null)
if (!mTextureDict.ContainsKey(imageName))
{
mTextureDict.Add(imageName, tex);
Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>(ImagePathName + imageName + ".png");
if (tex != null)
{
mTextureDict.Add(imageName, tex);
}
}
return mTextureDict[imageName];
}
return mTextureDict[imageName];
catch (Exception e)
{
throw new Exception($"无法找到资源: {imageName}", e);
}
}
public static void DrawConnection(Vector2 src, Vector2 dst)
......
......@@ -48,9 +48,10 @@ namespace MyEditor
}
public static void ShowWindow()
{
BehaviorDesignerWindow target = GetWindow<BehaviorDesignerWindow>("行为树编辑器", false);
BehaviorDesignerWindow target = GetWindow<BehaviorDesignerWindow>("行为树编辑器", false);
target.minSize = new Vector2(600f, 500f);
}
public void ShowSubWin(Vector2 pos,SubWinType subWinType)
{
mShowSubWin = true;
......
......@@ -101,7 +101,9 @@ namespace MyEditor
public void NewLoadData()
{
LoadNodeTypeProto();
Game.EntityEventManager.Register("Controller", DllHelper.GetController());
LoadNodeTypeProto();
NewLoadPrefabTree();
FilterClassify();
}
......@@ -426,7 +428,6 @@ namespace MyEditor
return;
}
selectNodeName = "";
ExportNodeTypeConfig.LoadAssembly();
CurTreeGO = go;
NewLoadData();
BehaviorDesignerWindow.ShowWindow();
......
......@@ -34,14 +34,13 @@ namespace Model
}
private static BehaviorNodeConfig CreateNodeConfig(this BehaviorTreeConfig treeConfig, string name)
{
ExportNodeTypeConfig.LoadAssembly();
ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
GameObject go = new GameObject();
go.name = name;
go.transform.parent = treeConfig.gameObject.transform;
BehaviorNodeConfig node = go.AddComponent<BehaviorNodeConfig>();
((UnityEngine.Object) node).name = name;
//node.describe = proto.describe;
node.name = name;
node.describe = proto.describe;
foreach (var args in proto.new_args_desc)
{
......
......@@ -103,7 +103,9 @@ namespace MyEditor
GameObject prefab = null;
try
{
GameObject go = new GameObject();
Game.EntityEventManager.Register("Controller", DllHelper.GetController());
GameObject go = new GameObject();
BehaviorTreeConfig newConfig = go.AddComponent<BehaviorTreeConfig>();
BehaviorNodeConfig root = newConfig.AddRootNode(rootNodeName);
......
......@@ -51,15 +51,6 @@ namespace MyEditor
return Game.EntityEventManager.GetAssembly("Controller");
}
public static Assembly LoadAssembly()
{
AssetDatabase.Refresh();
Assembly assembly = DllHelper.GetController();
Game.EntityEventManager.Register("Controller", assembly);
return assembly;
}
public static ClientNodeTypeProto GetNodeTypeProtoFromDll(string name)
{
Type type = GetNodeType(name);
......@@ -281,7 +272,7 @@ namespace MyEditor
Type nodeType = assembly.GetType("Controller." + nodeName);
if (nodeType == null)
{
Log.Error(string.Format("不存在此节点:{0}", nodeName));
Log.Error($"不存在此节点:{nodeName}");
return null;
}
return nodeType;
......
......@@ -11,6 +11,8 @@ namespace MyEditor
{
static EditorInit()
{
Game.EntityEventManager.Register("Model", typeof(Game).Assembly);
Game.EntityEventManager.Register("Editor", typeof(EditorInit).Assembly);
}
}
}
......@@ -12,22 +12,15 @@ namespace Model
private static Scene scene;
static Game()
{
disposers = new HashSet<Disposer>();
entityEventManager = new EntityEventManager();
entityEventManager.Register("Model", typeof(Game).Assembly);
entityEventManager.Register("Controller", DllHelper.GetController());
scene = new Scene();
scene.AddComponent<EventComponent>();
}
public static Scene Scene
{
get
{
if (scene == null)
{
scene = new Scene();
scene.AddComponent<EventComponent>();
}
return scene;
}
}
......@@ -36,6 +29,10 @@ namespace Model
{
get
{
if (disposers == null)
{
disposers = new HashSet<Disposer>();
}
return disposers;
}
}
......@@ -60,6 +57,10 @@ namespace Model
{
get
{
if (entityEventManager == null)
{
entityEventManager = new EntityEventManager();
}
return entityEventManager;
}
set
......
using System.Reflection;
using Base;
using UnityEngine;
namespace Model
......
......@@ -106,15 +106,6 @@ public class ReferenceCollector: MonoBehaviour, ISerializationCallbackReceiver
{
return null;
}
if (typeof(T) == typeof(GameObject))
{
return dictGo as T;
}
var go = dictGo as GameObject;
if (go != null)
{
return (dictGo as GameObject).GetComponent<T>();
}
return dictGo as T;
}
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -13,11 +13,13 @@
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Unity Full v3.5</TargetFrameworkProfile>
<CompilerResponseFile></CompilerResponseFile>
<CompilerResponseFile>
</CompilerResponseFile>
<UnityProjectType>Editor:5</UnityProjectType>
<UnityBuildTarget>StandaloneWindows:5</UnityBuildTarget>
<UnityVersion>5.4.3f1</UnityVersion>
<RootNamespace></RootNamespace>
<RootNamespace>
</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -157,6 +159,9 @@
<None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\AsyncBridge.Net35.xml" />
<None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\System.Threading.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Assets\Editor\MenuEditor\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="GenerateTargetFrameworkMonikerAttribute" />
</Project>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册