Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.9.0] - 2023-08-01
### Fixed
- Fixed code for custom nodes being stripped in AOT builds when Managed Stripping Level is set to High [UVSB-2439](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2437)
- Fixed OnInputSystemEvent doesn't trigger until Input Vector variates from 0.5 [UVSB-2435](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2435)
- Fixed assembly disappearing from Node Library after domain reload. [UVSB-2459](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2459)
- Fixed custom inspectors not being generated [UVSB-2466](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2466)
- Fixed error when trying to load exceptions for TryCatch node dropdown [2463] (https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2463)
- Fixed infinite amount of GameObjects created in Prefab mode when performing a null check of a scene variable in editor with an "OnDrawGizmos" event [UVSB-2453](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2453)
- Removed corrupt mdb which caused the ScriptUpdater to fail [UVSB-2360](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2360)
- Fixed Gradient graph variables resetting when entering PlayMode [UVSB-2334](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2334)
- Fixed Memory leak after destroying object [UVSB-2427] (https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2427)
  • Loading branch information
Unity Technologies committed Aug 1, 2023
1 parent db591b9 commit e890b3c
Show file tree
Hide file tree
Showing 57 changed files with 930 additions and 118 deletions.
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,34 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [1.9.0] - 2023-08-01
### Fixed
- Fixed code for custom nodes being stripped in AOT builds when Managed Stripping Level is set to High [UVSB-2439](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2437)
- Fixed OnInputSystemEvent doesn't trigger until Input Vector variates from 0.5 [UVSB-2435](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2435)
- Fixed assembly disappearing from Node Library after domain reload. [UVSB-2459](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2459)
- Fixed custom inspectors not being generated [UVSB-2466](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2466)
- Fixed error when trying to load exceptions for TryCatch node dropdown [2463] (https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2463)
- Fixed infinite amount of GameObjects created in Prefab mode when performing a null check of a scene variable in editor with an "OnDrawGizmos" event [UVSB-2453](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2453)
- Removed corrupt mdb which caused the ScriptUpdater to fail [UVSB-2360](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2360)
- Fixed Gradient graph variables resetting when entering PlayMode [UVSB-2334](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2334)
- Fixed Memory leak after destroying object [UVSB-2427] (https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2427)
- Fixed migration deserialization bug introduced in 1.8.0 [UVSB-2492](https://issuetracker.unity3d.com/issues/deserialization-error-when-upgrading-to-1-dot-8-0)

### Added
- Added a warning icon next to assemblies in Project Settings that reference Editor assemblies [UVSB-2382](https://issuetracker.unity3d.com/issues/nodes-from-runtime-assemblies-that-reference-unity-editor-are-not-visible-in-the-fuzzy-finder)

### Changed
- Script Graph Asset string data is unloaded after deserialization [UVSB-2367](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2366)
- AOT Prebuild should take less memory and be faster (Added an optimization to AssetUtility.GetAllAssetsOfType<T>)

## [1.8.0] - 2022-11-03
### Fixed
- Fixed graphs being corrupted on deserialization if containing a node whose type cannot be found. [UVSB-2332](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2332)
- For nodes that support a default parameter for each of their inputs, detect and fix parameter renames [UVSB-1885](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-1885)
- Fixed the problem that was preventing link.xml creation when building for Mono backend [UVSB-2348](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2348)
- Moved Events/MessageListeners files to a Listeners folder to avoid to exceed some OS path limit
- Fixed Grandient.mode serialization. Fix available for Unity 2021.3.9f1 or newer [UVSB-2356](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2356)
- Fixed Visual Scripting settings now only save to disk when modified
- Fixed Visual Scripting settings now only save to disk when modified
- Fixed sub graphs being shown with broken connections on first load as of Unity 2021.2 [UVSB-2345](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2345)
- Fixed documentation links for Script Graph and State Graphs assets [UVSB-2422](https://issuetracker.unity3d.com/product/unity/issues/guid/UVSB-2422)

Expand Down Expand Up @@ -39,6 +59,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed a performance issue when using lots of Get/Set Scene variable nodes in an open graph
- Fixed default inspectors for nodes not appearing in the correct position after a connected node is deleted [BOLT-1457](https://issuetracker.unity3d.com/product/unity/issues/guid/BOLT-1457)
- Fixed Scene variables drag and drop in graph having wrong scope [BOLT-2247](https://issuetracker.unity3d.com/product/unity/issues/guid/BOLT-2247)
- OnDestroy events are now properly triggered in script graphs [BOLT-1783](https://issuetracker.unity3d.com/issues/visual-scripting-ondestroy-unit-does-not-trigger-when-a-game-object-is-deleted)


### Changed
- Small optimization of load times involving generic types.
Expand Down
1 change: 1 addition & 0 deletions Documentation~/TableOfContents.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@

* [Developer's guide](vs-developers-guide.md)

* [Known Issues](vs-editor-script-issues.md)
Binary file added Documentation~/images/vs-flagged-assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Documentation~/vs-editor-script-issues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Known Issues: Unity Editor script functions

If you use nodes that use Unity Editor script functions in any of the Visual Scripting graphs in your project, it causes errors when you try to build your project.

## Cause of the build errors

Unity Visual Scripting (UVS) doesn't support preprocessor directives, so the use of Unity Editor script functions within graphs isn't possible. However, these functions can appear as node options within UVS because UVS uses C# reflection to generate nodes for your project based on your included assemblies. If you add one of these Unity Editor script nodes to a graph that's used in a build of your project, Unity generates an error when it attempts to build the project. An error message of the following format is displayed in the Unity Console:

`/<ProjectPath>/<CSharpFile>.cs: error CS0103: The name '<MissingApiName>' does not exist in the current context.`

The following code sample is an example of preprocessor directives for Unity Editor scripts :
```
#if UNITY_EDITOR
public static List<Type> GetAllVolumeComponents()
{
// TypeCache is only accessible in UnityEditor.
// If you instantiate a GetAllVolumeComponents node in a graph
// it prevents the project from being built.
return TypeCache.GetTypesDerivedFrom<VolumeComponent>().ToList();
}
#endif
```

## Find flagged packages

Packages that contain editor scripts are flagged with a warning icon in the Node Library section of the Visual Scripting tab in the Project Settings window.

To find the affected packages, do the following:

1. Go to **Edit** > **Project Settings**.
1. In the Project Settings window, select the **Visual Scripting** tab.
1. On the Visual Scripting tab expand the **Node Library** section. </br>
A yellow warning flag is displayed next to any affected packages as shown in the following screenshot.
![An example of a flagged package in the Visual Scripting project settings tab](images/vs-flagged-assembly.png)

## Resolution

To resolve this issue, go through your graphs and replace nodes that correspond to the API mentioned in the error message until you find the error no longer occurs.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ public class AssemblyOptionsSettings
+ "By default, all project and Unity assemblies are included.\n"
+ "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";

private ProjectAssemblyOptionsListInspector _assemblyOptionsInspector;

public AssemblyOptionsSettings(BoltCoreConfiguration coreConfig)
{
_assemblyOptionsMetadata = coreConfig.GetMetadata(nameof(coreConfig.assemblyOptions));
_assemblyOptionsInspector = new ProjectAssemblyOptionsListInspector(_assemblyOptionsMetadata);
}

private static class Styles
Expand All @@ -43,24 +46,24 @@ public void OnGUI()
{
GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

float height = LudiqGUI.GetInspectorHeight(null, _assemblyOptionsMetadata, Styles.OptionsWidth, GUIContent.none);
var height = _assemblyOptionsInspector.GetCachedHeight(Styles.OptionsWidth, GUIContent.none, null);

EditorGUI.BeginChangeCheck();

var position = GUILayoutUtility.GetRect(Styles.OptionsWidth, height);

LudiqGUI.Inspector(_assemblyOptionsMetadata, position, GUIContent.none);
_assemblyOptionsInspector.Draw(position, GUIContent.none);

if (EditorGUI.EndChangeCheck())
{
_assemblyOptionsMetadata.Save();
_assemblyOptionsMetadata.SaveImmediately(true);
Codebase.UpdateSettings();
}

if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton) && EditorUtility.DisplayDialog("Reset the Node Library", "Reset the Node Library to its default state?", "Reset to Default", "Cancel"))
{
_assemblyOptionsMetadata.Reset(true);
_assemblyOptionsMetadata.Save();
_assemblyOptionsMetadata.SaveImmediately(true);
}

LudiqGUI.EndVertical();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace Unity.VisualScripting
{
internal class LinkerPropertyProviderSettings
{
private readonly PluginConfigurationItemMetadata _linkerSettings;

private const string Title = "Linker generation settings";

private readonly GUIContent[] _toggleTargetsLabel =
{
new GUIContent("Scan graph assets"),
new GUIContent("Scan scenes"),
new GUIContent("Scan prefabs")
};

private Array _options = Enum.GetValues(typeof(BoltCoreConfiguration.LinkerScanTarget));
private List<bool> _settings;

public LinkerPropertyProviderSettings(BoltCoreConfiguration coreConfig)
{
_linkerSettings = coreConfig.GetMetadata(nameof(LinkerPropertyProviderSettings));

_settings = new List<bool>((List<bool>)_linkerSettings.value);
}

private void SaveIfNeeded()
{
var settings = (List<bool>)_linkerSettings.value;

if (!_settings.SequenceEqual(settings))
{
_linkerSettings.value = new List<bool>(_settings);

_linkerSettings.SaveImmediately();
}
}

public void OnGUI()
{
GUILayout.Space(5f);

GUILayout.Label(Title, EditorStyles.boldLabel);

GUILayout.Space(5f);

var label = "Scan for types to be added to link.xml";

GUILayout.BeginHorizontal(EditorStyles.helpBox);
GUILayout.Label(EditorGUIUtility.IconContent("console.infoicon"), GUILayout.ExpandWidth(true));
GUILayout.Box(label, EditorStyles.wordWrappedLabel);
GUILayout.EndHorizontal();

GUILayout.Space(5f);

foreach (var option in _options)
{
_settings[(int)option] = GUILayout.Toggle(_settings[(int)option], _toggleTargetsLabel[(int)option]);
GUILayout.Space(5f);
}

SaveIfNeeded();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Editor/SettingsProvider/ProjectSettingsProviderView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class ProjectSettingsProviderView : SettingsProvider
private AssemblyOptionsSettings _assemblyOptionsSettings;
private TypeOptionsSettings _typeOptionsSettings;
private CustomPropertyProviderSettings _customPropertyProviderSettings;
private LinkerPropertyProviderSettings _linkerPropertyProviderSettings;
private BackupSettings _backupSettings;
private ScriptReferenceResolverSettings _scriptReferenceResolverSettings;

Expand All @@ -29,6 +30,7 @@ private void CreateOptionsIfNeeded()
_assemblyOptionsSettings ??= new AssemblyOptionsSettings(_vsCoreConfig);
_typeOptionsSettings ??= new TypeOptionsSettings(_vsCoreConfig);
_customPropertyProviderSettings ??= new CustomPropertyProviderSettings();
_linkerPropertyProviderSettings ??= new LinkerPropertyProviderSettings(_vsCoreConfig);
_backupSettings ??= new BackupSettings();
_scriptReferenceResolverSettings ??= new ScriptReferenceResolverSettings();
}
Expand Down Expand Up @@ -82,6 +84,10 @@ public override void OnGUI(string searchContext)

GUILayout.Space(10f);

_linkerPropertyProviderSettings.OnGUI();

GUILayout.Space(10f);

_backupSettings.OnGUI();

GUILayout.Space(10f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class GraphDebugDataProvider
static GraphDebugDataProvider()
{
GraphPointer.fetchRootDebugDataBinding = FetchRootDebugData;
GraphPointer.releaseDebugDataBinding = ReleaseRootDebugData;
}

private static IGraphDebugData FetchRootDebugData(IGraphRoot root)
Expand All @@ -21,6 +22,11 @@ private static IGraphDebugData FetchRootDebugData(IGraphRoot root)
return rootData;
}

private static void ReleaseRootDebugData(IGraphRoot root)
{
rootDatas.Remove(root);
}

private static Dictionary<IGraphRoot, IGraphDebugData> rootDatas = new Dictionary<IGraphRoot, IGraphDebugData>();
}
}
Binary file not shown.
36 changes: 36 additions & 0 deletions Editor/VisualScripting.Core/Inspection/MetadataListAdaptor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Linq;
using Unity.VisualScripting.ReorderableList;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -286,4 +287,39 @@ public override void DrawItemBackground(Rect position, int index)

#endregion
}

public class ProjectAssemblyOptionsListAdaptor : MetadataListAdaptor
{
public ProjectAssemblyOptionsListAdaptor(Metadata metadata, Inspector parentInspector) : base((Metadata)metadata,
parentInspector)
{ }

public override void DrawItem(Rect position, int index)
{
base.DrawItem(position, index);

var assemblyName = ((LooseAssemblyName)metadata[index].value).name;
if (assemblyName == null) // Can be null when we're adding new items to the list (the last entry is empty)
return;
var shouldShowWarning =
!assemblyName.StartsWith("Unity.VisualScripting.") &&
Codebase.editorAssemblies.FirstOrDefault(a => a.GetName().Name == assemblyName) != null;
if (shouldShowWarning)
{
DrawAssemblyReferencingEditorWarning(position, assemblyName);
}
}

void DrawAssemblyReferencingEditorWarning(Rect position, string assemblyName)
{
var warningIcon = EditorGUIUtility.IconContent("console.warnicon");
warningIcon.tooltip =
"Nodes from this assembly can use editor-only APIs. Using them might cause errors in builds.";
var warningIconRect = position;
warningIconRect.width = 20;
warningIconRect.x -= 45;

GUI.Button(warningIconRect, warningIcon, GUIStyle.none);
}
}
}
27 changes: 26 additions & 1 deletion Editor/VisualScripting.Core/Inspection/Special/ListInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,32 @@ public ListInspector(Metadata metadata) : base(metadata)
adaptor = new MetadataListAdaptor(metadata, this);
}

protected MetadataListAdaptor adaptor { get; private set; }
protected MetadataListAdaptor adaptor { get; set; }

protected override float GetHeight(float width, GUIContent label)
{
return adaptor.GetHeight(width, label);
}

protected override void OnGUI(Rect position, GUIContent label)
{
adaptor.Field(position, label);
}

public override float GetAdaptiveWidth()
{
return adaptor.GetAdaptiveWidth();
}
}

internal class ProjectAssemblyOptionsListInspector : Inspector
{
public ProjectAssemblyOptionsListInspector(Metadata metadata) : base(metadata)
{
adaptor = new ProjectAssemblyOptionsListAdaptor(metadata, this);
}

ProjectAssemblyOptionsListAdaptor adaptor { get; set; }

protected override float GetHeight(float width, GUIContent label)
{
Expand Down
Loading

0 comments on commit e890b3c

Please sign in to comment.