Add support for loading Visject surfaces without Surface UI

This commit is contained in:
Wojtek Figat
2022-05-06 18:45:12 +02:00
parent 78d6fe6b50
commit 1acac3845e
16 changed files with 171 additions and 88 deletions

View File

@@ -91,7 +91,7 @@ namespace FlaxEditor.Surface.Elements
_currentType = value;
// Check if will need to update box connections due to type change
if (Surface._isUpdatingBoxTypes == 0 && HasAnyConnection && !CanCast(prev, _currentType))
if ((Surface == null || Surface._isUpdatingBoxTypes == 0) && HasAnyConnection && !CanCast(prev, _currentType))
{
// Remove all invalid connections and update those which still can be valid
var connections = Connections.ToArray();
@@ -181,9 +181,12 @@ namespace FlaxEditor.Surface.Elements
{
_currentType = DefaultType;
Text = Archetype.Text;
var hints = parentNode.Archetype.ConnectionsHints;
Surface.Style.GetConnectionColor(_currentType, hints, out _currentTypeColor);
TooltipText = Surface.GetTypeName(CurrentType) ?? GetConnectionHintTypeName(hints);
if (Surface != null)
{
var hints = parentNode.Archetype.ConnectionsHints;
Surface.Style.GetConnectionColor(_currentType, hints, out _currentTypeColor);
TooltipText = Surface.GetTypeName(CurrentType) ?? GetConnectionHintTypeName(hints);
}
}
private static string GetConnectionHintTypeName(ConnectionsHint hint)
@@ -215,9 +218,15 @@ namespace FlaxEditor.Surface.Elements
public bool CanUseType(ScriptType type)
{
// Check direct connection
if (Surface.CanUseDirectCast(type, _currentType))
if (Surface != null)
{
return true;
if (Surface.CanUseDirectCast(type, _currentType))
return true;
}
else
{
if (VisjectSurface.CanUseDirectCastStatic(type, _currentType))
return true;
}
// Check using connection hints
@@ -464,9 +473,12 @@ namespace FlaxEditor.Surface.Elements
/// </summary>
protected virtual void OnCurrentTypeChanged()
{
var hints = ParentNode.Archetype.ConnectionsHints;
Surface.Style.GetConnectionColor(_currentType, hints, out _currentTypeColor);
TooltipText = Surface.GetTypeName(CurrentType) ?? GetConnectionHintTypeName(hints);
if (Surface != null)
{
var hints = ParentNode.Archetype.ConnectionsHints;
Surface.Style.GetConnectionColor(_currentType, hints, out _currentTypeColor);
TooltipText = Surface.GetTypeName(CurrentType) ?? GetConnectionHintTypeName(hints);
}
CurrentTypeChanged?.Invoke(this);
}

View File

@@ -18,6 +18,8 @@ namespace FlaxEditor.Surface.Elements
{
_isAutoSelect = true;
if (Surface == null)
return;
UpdateComboBox();
// Select saved value

View File

@@ -45,6 +45,8 @@ namespace FlaxEditor.Surface.Elements
{
_isAutoSelect = true;
if (Surface == null)
return;
UpdateComboBox();
// Select saved value