From 6ee18886c8af3858de5e97599b23086823d9f320 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:30:19 +0800 Subject: =?UTF-8?q?*=E6=9B=B4=E6=96=B0Behaviour=20Designer=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=9C=A8=E6=9C=80=E4=B8=8B=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=89BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Basic Tasks/Debug/DrawLine.cs | 8 ++- .../Runtime/Basic Tasks/Debug/DrawLine.cs.meta | 16 ++--- .../Runtime/Basic Tasks/Debug/DrawRay.cs.meta | 16 ++--- .../Runtime/Basic Tasks/Debug/LogFormat.cs | 76 ++++++++++++++++++++++ .../Runtime/Basic Tasks/Debug/LogFormat.cs.meta | 8 +++ .../Runtime/Basic Tasks/Debug/LogValue.cs.meta | 16 ++--- 6 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs index 2c5429fa..c4bc3464 100644 --- a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs @@ -12,10 +12,14 @@ namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityDebug public SharedVector3 end; [Tooltip("The color")] public SharedColor color = Color.white; + [Tooltip("Duration the line will be visible for in seconds.\nDefault: 0 means 1 frame.")] + public SharedFloat duration; + [Tooltip("Whether the line should show through world geometry.")] + public SharedBool depthTest = true; public override TaskStatus OnUpdate() { - Debug.DrawLine(start.Value, end.Value, color.Value); + Debug.DrawLine(start.Value, end.Value, color.Value, duration.Value, depthTest.Value); return TaskStatus.Success; } @@ -25,6 +29,8 @@ namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityDebug start = Vector3.zero; end = Vector3.zero; color = Color.white; + duration = 0f; + depthTest = true; } } } \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs.meta index 224373d4..f7d43801 100644 --- a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs.meta +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawLine.cs.meta @@ -1,8 +1,8 @@ -fileFormatVersion: 2 -guid: 66a533f4f027ab44bb35e498d761ce50 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: +fileFormatVersion: 2 +guid: 66a533f4f027ab44bb35e498d761ce50 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawRay.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawRay.cs.meta index 8490bb34..63a767b3 100644 --- a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawRay.cs.meta +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/DrawRay.cs.meta @@ -1,8 +1,8 @@ -fileFormatVersion: 2 -guid: 786ac0c09ce982e43b444670fdfe4c74 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: +fileFormatVersion: 2 +guid: 786ac0c09ce982e43b444670fdfe4c74 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs new file mode 100644 index 00000000..939031fc --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs @@ -0,0 +1,76 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityDebug +{ + [TaskDescription("LogFormat is analgous to Debug.LogFormat().\n" + + "It takes format string, substitutes arguments supplied a '{0-4}' and returns success.\n" + + "Any fields or arguments not supplied are ignored." + + "It can be used for debugging.")] + [TaskIcon("{SkinColor}LogIcon.png")] + public class LogFormat : Action + { + [Tooltip("Text format with {0}, {1}, etc")] + public SharedString textFormat; + + [Tooltip("Is this text an error?")] + public SharedBool logError; + + public SharedVariable arg0; + public SharedVariable arg1; + public SharedVariable arg2; + public SharedVariable arg3; + + public override TaskStatus OnUpdate() + { + var paramsArray = buildParamsArray(); + // Log the text and return success + if (logError.Value) { + Debug.LogErrorFormat(textFormat.Value, paramsArray); + } else { + Debug.LogFormat(textFormat.Value, paramsArray); + } + return TaskStatus.Success; + } + + private object[] buildParamsArray() { + object[] paramsArray; + if (isValid(arg3)) { + paramsArray = new object[4]; + paramsArray[3] = arg3.GetValue(); + paramsArray[2] = arg2.GetValue(); + paramsArray[1] = arg1.GetValue(); + paramsArray[0] = arg0.GetValue(); + } else if (isValid(arg2)) { + paramsArray = new object[3]; + paramsArray[2] = arg2.GetValue(); + paramsArray[1] = arg1.GetValue(); + paramsArray[0] = arg0.GetValue(); + } else if (isValid(arg1)) { + paramsArray = new object[2]; + paramsArray[1] = arg1.GetValue(); + paramsArray[0] = arg0.GetValue(); + } else if (isValid(arg0)) { + paramsArray = new object[1]; + paramsArray[0] = arg0.GetValue(); + } else { + return null; + } + return paramsArray; + } + + private bool isValid(SharedVariable sv) { + return null != sv && !sv.IsNone; + } + + public override void OnReset() + { + // Reset the properties back to their original values + textFormat = string.Empty; + logError = false; + arg0 = null; + arg1 = null; + arg2 = null; + arg3 = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs.meta new file mode 100644 index 00000000..07abe00b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogFormat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70765819b419e8a45b326e92edf17ef5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogValue.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogValue.cs.meta index 03ab4247..75817e53 100644 --- a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogValue.cs.meta +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Debug/LogValue.cs.meta @@ -1,8 +1,8 @@ -fileFormatVersion: 2 -guid: c50983a88995f4f4197f7b39ca796667 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: +fileFormatVersion: 2 +guid: c50983a88995f4f4197f7b39ca796667 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0