From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Editor/Object Drawers/FloatSliderDrawer.cs | 22 ++++++++++++++++++++++ .../Object Drawers/FloatSliderDrawer.cs.meta | 8 ++++++++ .../Editor/Object Drawers/IntSliderDrawer.cs | 22 ++++++++++++++++++++++ .../Editor/Object Drawers/IntSliderDrawer.cs.meta | 8 ++++++++ 4 files changed, 60 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs create mode 100644 Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs.meta create mode 100644 Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs create mode 100644 Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs.meta (limited to 'Client/Assets/Behavior Designer/Editor/Object Drawers') diff --git a/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs b/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs new file mode 100644 index 00000000..ada9607b --- /dev/null +++ b/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using UnityEditor; +using BehaviorDesigner.Runtime; +using BehaviorDesigner.Runtime.ObjectDrawers; + +namespace BehaviorDesigner.Editor.ObjectDrawers +{ + [CustomObjectDrawer(typeof(FloatSliderAttribute))] + public class FloatSliderDrawer : ObjectDrawer + { + public override void OnGUI(GUIContent label) + { + var floatSliderAttribute = (FloatSliderAttribute)attribute; + if (value is SharedFloat) { + var sharedFloat = value as SharedFloat; + sharedFloat.Value = EditorGUILayout.Slider(label, sharedFloat.Value, floatSliderAttribute.min, floatSliderAttribute.max); + } else { + value = EditorGUILayout.Slider(label, (float)value, floatSliderAttribute.min, floatSliderAttribute.max); + } + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs.meta b/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs.meta new file mode 100644 index 00000000..9fd520f8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f0987c6ff37141458ff776277e2b65a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs b/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs new file mode 100644 index 00000000..53a532ff --- /dev/null +++ b/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using UnityEditor; +using BehaviorDesigner.Runtime; +using BehaviorDesigner.Runtime.ObjectDrawers; + +namespace BehaviorDesigner.Editor.ObjectDrawers +{ + [CustomObjectDrawer(typeof(IntSliderAttribute))] + public class IntSliderDrawer : ObjectDrawer + { + public override void OnGUI(GUIContent label) + { + var intSliderAttribute = (IntSliderAttribute)attribute; + if (value is SharedInt) { + var sharedFloat = value as SharedInt; + sharedFloat.Value = EditorGUILayout.IntSlider(label, sharedFloat.Value, intSliderAttribute.min, intSliderAttribute.max); + } else { + value = EditorGUILayout.IntSlider(label, (int)value, intSliderAttribute.min, intSliderAttribute.max); + } + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs.meta b/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs.meta new file mode 100644 index 00000000..8c3203a0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Editor/Object Drawers/IntSliderDrawer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed5dac524fa5f61468bb6ca49a556b3b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0