diff --git a/Source/Editor/Scripting/ScriptType.cs b/Source/Editor/Scripting/ScriptType.cs
index 11fdd5fb7..41f7540ed 100644
--- a/Source/Editor/Scripting/ScriptType.cs
+++ b/Source/Editor/Scripting/ScriptType.cs
@@ -714,7 +714,7 @@ namespace FlaxEditor.Scripting
public IScriptType IScriptType => _custom;
///
- /// Gets a type name (eg. name of the class or enum without leading namespace).
+ /// Gets a type display name (eg. name of the class or enum without leading namespace).
///
public string Name
{
@@ -724,19 +724,7 @@ namespace FlaxEditor.Scripting
return _custom.Name;
if (_managed == null)
return string.Empty;
- if (_managed == typeof(float))
- return "Float";
- if (_managed == typeof(int))
- return "Int";
- if (_managed == typeof(uint))
- return "Uint";
- if (_managed == typeof(short))
- return "Int16";
- if (_managed == typeof(ushort))
- return "Uint16";
- if (_managed == typeof(bool))
- return "Bool";
- return _managed.Name;
+ return _managed.GetTypeDisplayName();
}
}
@@ -790,6 +778,11 @@ namespace FlaxEditor.Scripting
///
public bool IsArray => _managed != null ? _managed.IsArray : _custom != null && _custom.IsArray;
+ ///
+ /// Gets a value indicating whether the type is a dictionary.
+ ///
+ public bool IsDictionary => IsGenericType && GetGenericTypeDefinition() == typeof(Dictionary<,>);
+
///
/// Gets a value indicating whether the type is a value type (basic type, enumeration or a structure).
///
@@ -981,7 +974,7 @@ namespace FlaxEditor.Scripting
public override string ToString()
{
if (_managed != null)
- return _managed.FullName ?? string.Empty;
+ return _managed.GetTypeDisplayName() ?? string.Empty;
if (_custom != null)
return _custom.TypeName;
return "";
@@ -1122,6 +1115,15 @@ namespace FlaxEditor.Scripting
throw new NotImplementedException("TODO: Script.Type.MakeArrayType for custom types");
}
+ ///
+ /// Returns a type object that represents a dictionary of the key and value types.
+ ///
+ /// A type object representing a dictionary of the key and value types.
+ public static ScriptType MakeDictionaryType(ScriptType keyType, ScriptType valueType)
+ {
+ return new ScriptType(typeof(Dictionary<,>).MakeGenericType(TypeUtils.GetType(keyType), TypeUtils.GetType(valueType)));
+ }
+
///
/// Searches for the specified members of the specified member type, using the specified binding constraints.
///
diff --git a/Source/Editor/Scripting/TypeUtils.cs b/Source/Editor/Scripting/TypeUtils.cs
index b2b71d370..4bf02911c 100644
--- a/Source/Editor/Scripting/TypeUtils.cs
+++ b/Source/Editor/Scripting/TypeUtils.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Text;
using FlaxEngine;
namespace FlaxEditor.Scripting
@@ -33,6 +34,74 @@ namespace FlaxEditor.Scripting
return o != null ? new ScriptType(o.GetType()) : ScriptType.Null;
}
+ ///
+ /// Gets the typename full name.
+ ///
+ /// The type.
+ /// The full typename of the type.
+ public static string GetTypeName(this Type type)
+ {
+ if (type.IsGenericType)
+ {
+ // For generic types (eg. Dictionary) FullName returns generic parameter types with fully qualified name so simplify it manually
+ var sb = new StringBuilder();
+ sb.Append(type.Namespace);
+ sb.Append('.');
+ sb.Append(type.Name);
+ sb.Append('[');
+ var genericArgs = type.GetGenericArguments();
+ for (var i = 0; i < genericArgs.Length; i++)
+ {
+ if (i != 0)
+ sb.Append(',');
+ sb.Append(genericArgs[i].GetTypeName());
+ }
+ sb.Append(']');
+ return sb.ToString();
+ }
+ return type.FullName;
+ }
+
+ ///
+ /// Gets the typename name for UI.
+ ///
+ /// The type.
+ /// The display of the type.
+ public static string GetTypeDisplayName(this Type type)
+ {
+ // Special display for in-built basic types
+ if (type == typeof(bool))
+ return "Bool";
+ if (type == typeof(float))
+ return "Float";
+ if (type == typeof(int))
+ return "Int";
+ if (type == typeof(uint))
+ return "Uint";
+
+ // For generic types (eg. Dictionary) Name returns generic parameter types with fully qualified name so simplify it manually
+ if (type.IsGenericType)
+ {
+ var sb = new StringBuilder();
+ var name = type.Name;
+ var idx = name.IndexOf('`');
+ sb.Append(idx != -1 ? name.Substring(0, idx) : name);
+ sb.Append('<');
+ var genericArgs = type.GetGenericArguments();
+ for (var i = 0; i < genericArgs.Length; i++)
+ {
+ if (i != 0)
+ sb.Append(", ");
+ sb.Append(genericArgs[i].GetTypeDisplayName());
+ }
+ sb.Append('>');
+ return sb.ToString();
+ }
+
+ // Default name
+ return type.Name;
+ }
+
///
/// Gets the default value for the given type (can be value type or reference type).
///
diff --git a/Source/Editor/Surface/Archetypes/Collections.cs b/Source/Editor/Surface/Archetypes/Collections.cs
index d09b02a69..3880d0975 100644
--- a/Source/Editor/Surface/Archetypes/Collections.cs
+++ b/Source/Editor/Surface/Archetypes/Collections.cs
@@ -19,6 +19,15 @@ namespace FlaxEditor.Surface.Archetypes
return box.DefaultType != null ? new ScriptType(type.GetElementType()) : type;
}
+ internal static ScriptType GetDictionaryItemType(Box box, ScriptType type)
+ {
+ if (type == ScriptType.Null)
+ return box.DefaultType;
+ // BoxID = 1 is Key
+ // BoxID = 2 is Value
+ return box.DefaultType != null ? new ScriptType(type.GetGenericArguments()[box.ID == 1 ? 0 : 1]) : type;
+ }
+
///
/// The nodes for that group.
///
@@ -28,7 +37,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 1,
Title = "Array Length",
- Description = "Gets the length of the arary (amount of the items).",
+ Description = "Gets the length of the array (amount of the items).",
AlternativeTitles = new[] { "Count" },
Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
Size = new Vector2(150, 20),
@@ -44,7 +53,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 2,
Title = "Array Contains",
- Description = "Returns the true if arrayt contains a given item, otherwise false.",
+ Description = "Returns the true if array contains a given item, otherwise false.",
AlternativeTitles = new[] { "Contains" },
Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
Size = new Vector2(150, 40),
@@ -277,6 +286,138 @@ namespace FlaxEditor.Surface.Archetypes
}
},
// first 100 IDs reserved for arrays
+
+ new NodeArchetype
+ {
+ TypeID = 101,
+ Title = "Dictionary Count",
+ Description = "Gets the size of the dictionary (amount of the items).",
+ AlternativeTitles = new[] { "size" },
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(180, 20),
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, typeof(int), 1)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 102,
+ Title = "Dictionary Contains Key",
+ Description = "Returns the true if dictionary contains a given key, otherwise false.",
+ AlternativeTitles = new[] { "Contains" },
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(240, 40),
+ DefaultValues = new object[] { 0 },
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 1 },
+ DependentBoxFilter = GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Input(1, "Key", true, typeof(object), 1, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, typeof(bool), 3)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 103,
+ Title = "Dictionary Contains Value",
+ Description = "Returns the true if dictionary contains a given value, otherwise false.",
+ AlternativeTitles = new[] { "Contains" },
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(240, 40),
+ DefaultValues = new object[] { 0 },
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 2 },
+ DependentBoxFilter = GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Input(1, "Value", true, typeof(object), 2, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, typeof(bool), 3)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 104,
+ Title = "Dictionary Clear",
+ Description = "Clears dictionary.",
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(180, 20),
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 1 },
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, null, 1)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 105,
+ Title = "Dictionary Remove",
+ Description = "Removes the given item from the dictionary (by key).",
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(180, 40),
+ DefaultValues = new object[] { 0 },
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 1, 3 },
+ DependentBoxFilter = GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Input(1, "Key", true, typeof(object), 1, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, null, 3)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 106,
+ Title = "Dictionary Set",
+ Description = "Set the item in the dictionary (a pair of key and value). Adds or updates the pair.",
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(180, 60),
+ DefaultValues = new object[] { 0, 0 },
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 1, 2, 3 },
+ DependentBoxFilter = GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Input(1, "Key", true, typeof(object), 1, 0),
+ NodeElementArchetype.Factory.Input(2, "Value", true, typeof(object), 2, 1),
+ NodeElementArchetype.Factory.Output(0, string.Empty, null, 3)
+ }
+ },
+ new NodeArchetype
+ {
+ TypeID = 107,
+ Title = "Dictionary Get",
+ Description = "Gets the item from the dictionary (a pair of key and value).",
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(180, 40),
+ DefaultValues = new object[] { 0 },
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 0 },
+ DependentBoxes = new int[] { 1, 3 },
+ DependentBoxFilter = GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, "Dictionary", true, null, 0),
+ NodeElementArchetype.Factory.Input(1, "Key", true, typeof(object), 1, 0),
+ NodeElementArchetype.Factory.Output(0, string.Empty, typeof(object), 3)
+ }
+ },
+ // second 100 IDs reserved for dictionaries
};
}
}
diff --git a/Source/Editor/Surface/Archetypes/Constants.cs b/Source/Editor/Surface/Archetypes/Constants.cs
index 8e1d98e1f..9d4a30459 100644
--- a/Source/Editor/Surface/Archetypes/Constants.cs
+++ b/Source/Editor/Surface/Archetypes/Constants.cs
@@ -132,7 +132,7 @@ namespace FlaxEditor.Surface.Archetypes
Array.Copy(prev, next, Mathf.Min(prev.Length, next.Length));
SetValue(0, next);
}
-
+
public override void OnSurfaceCanEditChanged(bool canEdit)
{
base.OnSurfaceCanEditChanged(canEdit);
@@ -141,7 +141,7 @@ namespace FlaxEditor.Surface.Archetypes
_addButton.Enabled = canEdit;
_removeButton.Enabled = canEdit;
}
-
+
public override void OnDestroy()
{
_output = null;
@@ -179,7 +179,7 @@ namespace FlaxEditor.Surface.Archetypes
break;
RemoveElement(box);
}
-
+
var canEdit = Surface.CanEdit;
_typePicker.Enabled = canEdit;
_addButton.Enabled = count < countMax && canEdit;
@@ -212,6 +212,132 @@ namespace FlaxEditor.Surface.Archetypes
}
}
+ private class DictionaryNode : SurfaceNode
+ {
+ private OutputBox _output;
+ private TypePickerControl _keyTypePicker;
+ private TypePickerControl _valueTypePicker;
+ private bool _isUpdatingUI;
+
+ public DictionaryNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
+ : base(id, context, nodeArch, groupArch)
+ {
+ }
+
+ public override void OnValuesChanged()
+ {
+ UpdateUI();
+
+ base.OnValuesChanged();
+ }
+
+ public override void OnLoaded()
+ {
+ base.OnLoaded();
+
+ _output = (OutputBox)Elements[0];
+ _keyTypePicker = new TypePickerControl
+ {
+ Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
+ Parent = this,
+ };
+ _keyTypePicker.ValueChanged += OnKeyTypeChanged;
+ _valueTypePicker = new TypePickerControl
+ {
+ Bounds = new Rectangle(_keyTypePicker.X, _keyTypePicker.Y + FlaxEditor.Surface.Constants.LayoutOffsetY, _keyTypePicker.Width, _keyTypePicker.Height),
+ Parent = this,
+ };
+ _valueTypePicker.ValueChanged += OnValueTypeChanged;
+
+ UpdateUI();
+ }
+
+ private void OnKeyTypeChanged()
+ {
+ if (_isUpdatingUI)
+ return;
+ SetValue(0, _keyTypePicker.ValueTypeName);
+ }
+
+ private void OnValueTypeChanged()
+ {
+ if (_isUpdatingUI)
+ return;
+ SetValue(1, _valueTypePicker.ValueTypeName);
+ }
+
+ public override void OnSurfaceCanEditChanged(bool canEdit)
+ {
+ base.OnSurfaceCanEditChanged(canEdit);
+
+ _keyTypePicker.Enabled = canEdit;
+ _valueTypePicker.Enabled = canEdit;
+ }
+
+ public override void OnDestroy()
+ {
+ _output = null;
+ _keyTypePicker = null;
+ _valueTypePicker = null;
+
+ base.OnDestroy();
+ }
+
+ private void UpdateUI()
+ {
+ if (_isUpdatingUI)
+ return;
+ var keyTypeName = (string)Values[0];
+ var valueTypeName = (string)Values[1];
+ var keyType = TypeUtils.GetType(keyTypeName);
+ var valueType = TypeUtils.GetType(valueTypeName);
+ if (keyType == ScriptType.Null)
+ {
+ Editor.LogError("Missing type " + keyTypeName);
+ keyType = ScriptType.Object;
+ }
+ if (valueType == ScriptType.Null)
+ {
+ Editor.LogError("Missing type " + valueTypeName);
+ valueType = ScriptType.Object;
+ }
+ var dictionaryType = ScriptType.MakeDictionaryType(keyType, valueType);
+
+ _isUpdatingUI = true;
+ _keyTypePicker.Value = keyType;
+ _valueTypePicker.Value = valueType;
+ _output.CurrentType = dictionaryType;
+ _isUpdatingUI = false;
+
+ var canEdit = Surface.CanEdit;
+ _keyTypePicker.Enabled = canEdit;
+ _valueTypePicker.Enabled = canEdit;
+
+ Title = Surface.GetTypeName(dictionaryType);
+ _keyTypePicker.Width = 160.0f;
+ _valueTypePicker.Width = 160.0f;
+ ResizeAuto();
+ _keyTypePicker.Width = Width - 30;
+ _valueTypePicker.Width = Width - 30;
+ }
+
+ private object GetBoxValue(InputBox box)
+ {
+ var array = (Array)Values[0];
+ return array.GetValue(box.ID - 1);
+ }
+
+ private void SetBoxValue(InputBox box, object value)
+ {
+ if (_isDuringValuesEditing || !Surface.CanEdit)
+ return;
+ var array = (Array)Values[0];
+ array = (Array)array.Clone();
+ array.SetValue(value, box.ID - 1);
+ SetValue(0, array);
+ }
+ }
+
///
/// The nodes for that group.
///
@@ -236,12 +362,12 @@ namespace FlaxEditor.Surface.Archetypes
TryParseText = (string filterText, out object[] data) =>
{
data = null;
- if (filterText == "true")
+ if (string.Equals(filterText, bool.TrueString, StringComparison.OrdinalIgnoreCase))
{
data = new object[] { true };
return true;
}
- if (filterText == "false")
+ if (string.Equals(filterText, bool.FalseString, StringComparison.OrdinalIgnoreCase))
{
data = new object[] { false };
return true;
@@ -544,6 +670,17 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[] { new int[] { 0, 1, 2 } },
Elements = new[] { NodeElementArchetype.Factory.Output(0, string.Empty, null, 0) }
},
+ new NodeArchetype
+ {
+ TypeID = 14,
+ Title = "Dictionary",
+ Create = (id, context, arch, groupArch) => new DictionaryNode(id, context, arch, groupArch),
+ Description = "Creates an empty dictionary.",
+ Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
+ Size = new Vector2(150, 40),
+ DefaultValues = new object[] { typeof(int).FullName, typeof(string).FullName },
+ Elements = new[] { NodeElementArchetype.Factory.Output(0, string.Empty, null, 0) }
+ },
};
///
diff --git a/Source/Editor/Surface/Archetypes/Flow.cs b/Source/Editor/Surface/Archetypes/Flow.cs
index f955a0197..787975625 100644
--- a/Source/Editor/Surface/Archetypes/Flow.cs
+++ b/Source/Editor/Surface/Archetypes/Flow.cs
@@ -331,6 +331,29 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Output(3, "Done", typeof(void), 6, true),
}
},
+ new NodeArchetype
+ {
+ TypeID = 8,
+ Title = "Dictionary For Each",
+ AlternativeTitles = new[] { "foreach" },
+ Description = "Iterates over the dictionary items.",
+ Flags = NodeFlags.VisualScriptGraph,
+ Size = new Vector2(180, 80),
+ ConnectionsHints = ConnectionsHint.Dictionary,
+ IndependentBoxes = new int[] { 4 },
+ DependentBoxes = new int[] { 1, 2, },
+ DependentBoxFilter = Collections.GetDictionaryItemType,
+ Elements = new[]
+ {
+ NodeElementArchetype.Factory.Input(0, string.Empty, false, typeof(void), 0),
+ NodeElementArchetype.Factory.Input(1, "Dictionary", true, null, 4),
+ NodeElementArchetype.Factory.Input(2, "Break", false, typeof(void), 5),
+ NodeElementArchetype.Factory.Output(0, "Loop", typeof(void), 3, true),
+ NodeElementArchetype.Factory.Output(1, "Key", typeof(object), 1),
+ NodeElementArchetype.Factory.Output(2, "Value", typeof(object), 2),
+ NodeElementArchetype.Factory.Output(3, "Done", typeof(void), 6, true),
+ }
+ },
};
}
}
diff --git a/Source/Editor/Surface/Elements/Box.cs b/Source/Editor/Surface/Elements/Box.cs
index 19c936063..cf133d4c9 100644
--- a/Source/Editor/Surface/Elements/Box.cs
+++ b/Source/Editor/Surface/Elements/Box.cs
@@ -202,6 +202,8 @@ namespace FlaxEditor.Surface.Elements
return "Scalar";
if ((hint & ConnectionsHint.Array) == ConnectionsHint.Array)
return "Array";
+ if ((hint & ConnectionsHint.Dictionary) == ConnectionsHint.Dictionary)
+ return "Dictionary";
return null;
}
@@ -215,7 +217,6 @@ namespace FlaxEditor.Surface.Elements
// Check direct connection
if (Surface.CanUseDirectCast(type, _currentType))
{
- // Can
return true;
}
@@ -224,25 +225,15 @@ namespace FlaxEditor.Surface.Elements
if (Archetype.ConnectionsType == ScriptType.Null && connectionsHints != ConnectionsHint.None)
{
if ((connectionsHints & ConnectionsHint.Anything) == ConnectionsHint.Anything)
- {
- // Can
return true;
- }
if ((connectionsHints & ConnectionsHint.Value) == ConnectionsHint.Value && type.Type != typeof(void))
- {
- // Can
return true;
- }
if ((connectionsHints & ConnectionsHint.Enum) == ConnectionsHint.Enum && type.IsEnum)
- {
- // Can
return true;
- }
if ((connectionsHints & ConnectionsHint.Array) == ConnectionsHint.Array && type.IsArray)
- {
- // Can
return true;
- }
+ if ((connectionsHints & ConnectionsHint.Dictionary) == ConnectionsHint.Dictionary && type.IsDictionary)
+ return true;
if ((connectionsHints & ConnectionsHint.Vector) == ConnectionsHint.Vector)
{
var t = type.Type;
@@ -251,7 +242,6 @@ namespace FlaxEditor.Surface.Elements
t == typeof(Vector4) ||
t == typeof(Color))
{
- // Can
return true;
}
}
@@ -270,7 +260,6 @@ namespace FlaxEditor.Surface.Elements
t == typeof(float) ||
t == typeof(double))
{
- // Can
return true;
}
}
diff --git a/Source/Editor/Surface/NodeArchetype.cs b/Source/Editor/Surface/NodeArchetype.cs
index b28bef8f0..5ecffe957 100644
--- a/Source/Editor/Surface/NodeArchetype.cs
+++ b/Source/Editor/Surface/NodeArchetype.cs
@@ -57,6 +57,11 @@ namespace FlaxEditor.Surface
///
Array = 32,
+ ///
+ /// Allow any dictionary types connections.
+ ///
+ Dictionary = 64,
+
///
/// Allow any scalar or vector numeric value types connections (bool, int, float, vector2, color..).
///
@@ -65,7 +70,7 @@ namespace FlaxEditor.Surface
///
/// All flags.
///
- All = Scalar | Vector | Enum | Anything | Value | Array,
+ All = Scalar | Vector | Enum | Anything | Value | Array | Dictionary,
}
///
diff --git a/Source/Editor/Surface/SurfaceUtils.cs b/Source/Editor/Surface/SurfaceUtils.cs
index d53049b16..5718e68ab 100644
--- a/Source/Editor/Surface/SurfaceUtils.cs
+++ b/Source/Editor/Surface/SurfaceUtils.cs
@@ -415,8 +415,13 @@ namespace FlaxEditor.Surface
internal static bool IsValidVisualScriptType(ScriptType scriptType)
{
- if (scriptType.IsGenericType || !scriptType.IsPublic || scriptType.HasAttribute(typeof(HideInEditorAttribute), true))
+ if (!scriptType.IsPublic || scriptType.HasAttribute(typeof(HideInEditorAttribute), true))
return false;
+ if (scriptType.IsGenericType)
+ {
+ // Only Dictionary generic type is valid
+ return scriptType.GetGenericTypeDefinition() == typeof(Dictionary<,>);
+ }
var managedType = TypeUtils.GetType(scriptType);
return !TypeUtils.IsDelegate(managedType);
}
diff --git a/Source/Editor/Surface/VisjectSurface.cs b/Source/Editor/Surface/VisjectSurface.cs
index 8ad91d588..8fd9042ea 100644
--- a/Source/Editor/Surface/VisjectSurface.cs
+++ b/Source/Editor/Surface/VisjectSurface.cs
@@ -387,17 +387,7 @@ namespace FlaxEditor.Surface
/// The display name (for UI).
public virtual string GetTypeName(ScriptType type)
{
- if (type == ScriptType.Null)
- return null;
- if (type.Type == typeof(float))
- return "Float";
- if (type.Type == typeof(int))
- return "Int";
- if (type.Type == typeof(uint))
- return "Uint";
- if (type.Type == typeof(bool))
- return "Bool";
- return type.Name;
+ return type == ScriptType.Null ? null : type.Name;
}
///
diff --git a/Source/Editor/Utilities/VariantUtils.cs b/Source/Editor/Utilities/VariantUtils.cs
index 85f055ec8..98e4a6730 100644
--- a/Source/Editor/Utilities/VariantUtils.cs
+++ b/Source/Editor/Utilities/VariantUtils.cs
@@ -1,6 +1,7 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System;
+using System.Collections;
using System.Collections.Generic;
using System.IO;
using FlaxEditor.Scripting;
@@ -134,7 +135,7 @@ namespace FlaxEditor.Utilities
variantType = VariantType.Blob;
else if (type.IsArray)
variantType = VariantType.Array;
- else if (type == typeof(Dictionary