From 4bfaad2004dded29c082e3b225b511743230774d Mon Sep 17 00:00:00 2001 From: Chris Gregan Date: Thu, 12 May 2016 22:14:01 +0100 Subject: [PATCH] Added pr changes to new branch --- .../Flowchart/Editor/CommandListAdaptor.cs | 37 +-------------- .../Fungus/Flowchart/Editor/Extensions.meta | 9 ++++ .../SerializedPropertyExtensions.cs | 45 +++++++++++++++++++ .../SerializedPropertyExtensions.cs.meta | 12 +++++ .../Flowchart/Editor/VariableListAdaptor.cs | 41 +---------------- 5 files changed, 69 insertions(+), 75 deletions(-) create mode 100644 Assets/Fungus/Flowchart/Editor/Extensions.meta create mode 100644 Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs create mode 100644 Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs.meta diff --git a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs index 86469212..105759be 100644 --- a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs @@ -465,41 +465,6 @@ namespace Fungus ; } - private void ResetValue(SerializedProperty element) { - switch (element.type) { - case "string": - element.stringValue = ""; - break; - case "Vector2f": - element.vector2Value = Vector2.zero; - break; - case "Vector3f": - element.vector3Value = Vector3.zero; - break; - case "Rectf": - element.rectValue = new Rect(); - break; - case "Quaternionf": - element.quaternionValue = Quaternion.identity; - break; - case "int": - element.intValue = 0; - break; - case "float": - element.floatValue = 0f; - break; - case "UInt8": - element.boolValue = false; - break; - case "ColorRGBA": - element.colorValue = Color.black; - break; - - default: - if (element.type.StartsWith("PPtr")) - element.objectReferenceValue = null; - break; - } - } + } } diff --git a/Assets/Fungus/Flowchart/Editor/Extensions.meta b/Assets/Fungus/Flowchart/Editor/Extensions.meta new file mode 100644 index 00000000..24881c44 --- /dev/null +++ b/Assets/Fungus/Flowchart/Editor/Extensions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 895ead76bb3488c4481a5ae7d88c03df +folderAsset: yes +timeCreated: 1462775995 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs b/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs new file mode 100644 index 00000000..cbe4c793 --- /dev/null +++ b/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs @@ -0,0 +1,45 @@ +using UnityEditor; +using UnityEngine; + +namespace Fungus +{ + public static class SerializedPropertyExtensions + { + public static void ResetValue(this SerializedProperty element) { + switch (element.type) { + case "string": + element.stringValue = ""; + break; + case "Vector2f": + element.vector2Value = Vector2.zero; + break; + case "Vector3f": + element.vector3Value = Vector3.zero; + break; + case "Rectf": + element.rectValue = new Rect(); + break; + case "Quaternionf": + element.quaternionValue = Quaternion.identity; + break; + case "int": + element.intValue = 0; + break; + case "float": + element.floatValue = 0f; + break; + case "UInt8": + element.boolValue = false; + break; + case "ColorRGBA": + element.colorValue = Color.black; + break; + + default: + if (element.type.StartsWith("PPtr")) + element.objectReferenceValue = null; + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs.meta b/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs.meta new file mode 100644 index 00000000..eaf842fe --- /dev/null +++ b/Assets/Fungus/Flowchart/Editor/Extensions/SerializedPropertyExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ffbc18a30fa1a6547a0ef5fc3389c9c0 +timeCreated: 1462775995 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs index 61c34b9f..09e9c5b0 100644 --- a/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs @@ -51,12 +51,12 @@ namespace Fungus public void Add() { int newIndex = _arrayProperty.arraySize; ++_arrayProperty.arraySize; - ResetValue(_arrayProperty.GetArrayElementAtIndex(newIndex)); + _arrayProperty.GetArrayElementAtIndex(newIndex).ResetValue(); } public void Insert(int index) { _arrayProperty.InsertArrayElementAtIndex(index); - ResetValue(_arrayProperty.GetArrayElementAtIndex(index)); + _arrayProperty.GetArrayElementAtIndex(index).ResetValue(); } public void Duplicate(int index) { @@ -191,43 +191,6 @@ namespace Fungus : EditorGUI.GetPropertyHeight(this[index], GUIContent.none, false) ; } - - private void ResetValue(SerializedProperty element) { - switch (element.type) { - case "string": - element.stringValue = ""; - break; - case "Vector2f": - element.vector2Value = Vector2.zero; - break; - case "Vector3f": - element.vector3Value = Vector3.zero; - break; - case "Rectf": - element.rectValue = new Rect(); - break; - case "Quaternionf": - element.quaternionValue = Quaternion.identity; - break; - case "int": - element.intValue = 0; - break; - case "float": - element.floatValue = 0f; - break; - case "UInt8": - element.boolValue = false; - break; - case "ColorRGBA": - element.colorValue = Color.black; - break; - - default: - if (element.type.StartsWith("PPtr")) - element.objectReferenceValue = null; - break; - } - } } }