fix:move to 2020 to develop,alter scripts to c# 8.0

main
taoria 3 years ago
parent 7831c8571e
commit 2105bd2042
  1. 12
      TNode/Samples/New HelloGraph.asset
  2. 49
      TNode/TNodeCore/Editor/DeveloperHelper/CleanMissingTypeHelper.cs
  3. 6
      TNode/TNodeCore/Editor/Inspector/INodeDataBinding.cs
  4. 3
      TNode/TNodeCore/Editor/Models.meta
  5. 9
      TNode/TNodeCore/Editor/Models/EditorModel.cs
  6. 3
      TNode/TNodeCore/Editor/Models/EditorModel.cs.meta
  7. 12
      TNode/TNodeCore/Editor/Models/Placemat.cs
  8. 3
      TNode/TNodeCore/Editor/Models/Placemat.cs.meta
  9. 2
      TNode/TNodeCore/Editor/Resources/GraphEditor.uxml
  10. 2
      TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.cs
  11. 2
      TNode/TNodeCore/Editor/Tools/GraphEditorCreator/GraphEditorCreator.uxml
  12. 3
      TNode/TNodeCore/Placemat.meta
  13. 8
      TNode/TNodeCore/Placemat/IPlacemat.cs
  14. 3
      TNode/TNodeCore/Placemat/IPlacemat.cs.meta
  15. 2
      TNode/TNodeCore/Runtime/Components/RuntimeDataSaver.cs
  16. 8
      TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs
  17. 2
      TNode/TNodeCore/Runtime/DataWrapper.cs
  18. 2
      TNode/TNodeCore/Runtime/Logger/NodeLogger.cs
  19. 2
      TNode/TNodeCore/Runtime/Models/BlackboardDragNodeData.cs
  20. 8
      TNode/TNodeCore/Runtime/Models/GraphData.cs
  21. 10
      TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs
  22. 2
      TNode/TNodeGraphViewImpl/Editor/Cache/NodeEditorExtensions.cs
  23. 2
      TNode/TNodeGraphViewImpl/Editor/GraphBlackboard/BlackboardDataEntry.cs
  24. 2
      TNode/TNodeGraphViewImpl/Editor/Inspector/NodeInspectorInNode.cs
  25. 45
      TNode/TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs
  26. 9
      TNode/TNodeGraphViewImpl/Editor/NodeViews/DragNodeView.cs
  27. 3
      TNode/TNodeGraphViewImpl/Editor/Placemats.meta
  28. 7
      TNode/TNodeGraphViewImpl/Editor/Placemats/PlacematView.cs
  29. 3
      TNode/TNodeGraphViewImpl/Editor/Placemats/PlacematView.cs.meta
  30. 6
      TNode/TNodeGtfImpl/Editor/BaseView.cs
  31. 3
      TNode/TNodeGtfImpl/Editor/BaseView.cs.meta
  32. 1
      TNode/package.json

@ -76,8 +76,8 @@ MonoBehaviour:
data:
positionInView:
serializedVersion: 2
x: 1021.58136
y: 228.81656
x: 973.3707
y: 189.23111
width: 0
height: 0
id: 6ceba867-fe0d-40c3-9d30-2d5d12803b52
@ -89,8 +89,8 @@ MonoBehaviour:
data:
positionInView:
serializedVersion: 2
x: 758.5814
y: 309.81662
x: 748.0001
y: 291
width: 0
height: 0
id: b2ab4a52-e65d-4104-8891-dc316af217d9
@ -104,8 +104,8 @@ MonoBehaviour:
data:
positionInView:
serializedVersion: 2
x: 758.5814
y: 195.81656
x: 747
y: 179
width: 0
height: 0
id: ac84573e-638d-45fa-b4e2-1a81c31fa9e7

@ -18,14 +18,15 @@ namespace TNodeCore.Editor.DeveloperHelper{
Object obj = AssetDatabase.LoadMainAssetAtPath(path);
if (obj != null)
{
if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(obj))
{
report.Append("Cleared missing types from ").Append(path).AppendLine();
}
else
{
report.Append("No missing types to clear on ").Append(path).AppendLine();
}
// if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(obj))
// {
//
// report.Append("Cleared missing types from ").Append(path).AppendLine();
// }
// else
// {
// report.Append("No missing types to clear on ").Append(path).AppendLine();
// }
}
}
Debug.Log(report.ToString());
@ -38,25 +39,25 @@ namespace TNodeCore.Editor.DeveloperHelper{
SceneManager.GetActiveScene().GetRootGameObjects();
foreach (GameObject root in SceneManager.GetActiveScene().GetRootGameObjects()){
foreach (var o in root.transform){
if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(o as Object))
{
report.Append("Cleared missing types from ").Append(root.name).AppendLine();
}
else
{
report.Append("No missing types to clear on ").Append(root.name).AppendLine();
}
// if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(o as Object))
// {
// report.Append("Cleared missing types from ").Append(root.name).AppendLine();
// }
// else
// {
// report.Append("No missing types to clear on ").Append(root.name).AppendLine();
// }
}
if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(root))
{
report.Append("Cleared missing types from ").Append(root.name).AppendLine();
}
else
{
report.Append("No missing types to clear on ").Append(root.name).AppendLine();
}
// if (SerializationUtility.ClearAllManagedReferencesWithMissingTypes(root))
// {
// report.Append("Cleared missing types from ").Append(root.name).AppendLine();
// }
// else
// {
// report.Append("No missing types to clear on ").Append(root.name).AppendLine();
// }
}
Debug.Log(report.ToString());

@ -1,10 +1,8 @@
namespace TNodeCore.Editor.Inspector{
public interface INodeDataBinding<out T>:INodeDataBindingBase{
public void OnBindingDataUpdate(){
}
public void OnBindingDataUpdate();
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2b8a5fc83b994049a14d896a23e4c59d
timeCreated: 1659871327

@ -0,0 +1,9 @@
using TNodeCore.Runtime.Models;
using UnityEngine;
namespace TNodeCore.Editor.Models{
//This models are editor only
public abstract class EditorModel:Model{
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ba4122b0f63040ee81b618cc58135555
timeCreated: 1659871344

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using TNodeCore.Runtime.Models;
using UnityEngine;
namespace TNodeCore.Editor.Models{
[Serializable]
public class Placemat:EditorModel{
[SerializeReference]
public List<Model> hostModels = new List<Model>();
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c1d451ebc814415b9ce41219088b1875
timeCreated: 1659871435

@ -1,3 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<Style src="project://database/Assets/TNode/Editor/GraphEditor.uss?fileID=7433441132597879392&amp;guid=695180bcb9ddc3b47bbf70fe1f5dd651&amp;type=3#TGraphView" />
</ui:UXML>

@ -26,7 +26,7 @@ namespace TNodeCore.Editor.Tools.GraphEditorCreator{
GraphEditorCreator wnd = GetWindow<GraphEditorCreator>();
wnd.titleContent = new GUIContent("GraphEditorCreator");
//Set position to the center of the screen
wnd.position = new(Screen.width / 2.0f, Screen.height / 2.0f, 500, 300);
wnd.position = new Rect(Screen.width / 2.0f, Screen.height / 2.0f, 500, 300);
//set this window non resizable
wnd.minSize = new Vector2(500, 300);
wnd.maxSize = new Vector2(500, 300);

@ -1,5 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<Style src="project://database/Assets/TNode/Editor/Tools/GraphEditorCreator/GraphEditorCreator.uss?fileID=7433441132597879392&amp;guid=7cf956c2afedd274db0f9b45392e90f5&amp;type=3#GraphEditorCreator" />
<ui:VisualElement name="Root">
<ui:VisualElement name="EditorName" style="flex-direction: row;">
<ui:TextField picking-mode="Ignore" label="Your Editor Class Name" value="filler text" text="filler text" name="EditorClassNameTextField" style="width: 306px;" />

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6dbc9136434544f1b339c618729e0422
timeCreated: 1659774798

@ -1,8 +0,0 @@
using System.Collections.Generic;
using TNodeCore.Runtime.Models;
namespace TNodeCore.Placemat{
public interface IPlacemat{
public List<Model> HoldModels{get;set;}
}
}

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 5e52755cad2a44d3bc705de2bbbca544
timeCreated: 1659774811

@ -6,7 +6,7 @@ namespace TNodeCore.Runtime.Components{
public class RuntimeDataSaver:MonoBehaviour{
public string saveName;
public string saveExtension = "tng";
public Dictionary<string, object> savedData = new();
public Dictionary<string, object> savedData = new Dictionary<string, object>();
public void Load(){
string path = Application.persistentDataPath + "/"+ saveName + "." + saveExtension;
if(!File.Exists(path)){

@ -275,7 +275,7 @@ namespace TNodeCore.Runtime.Components{
}
public void BuildSceneNode(){
var fetchedSceneNode = graphData.NodeDictionary.Values.Where(x => x is SceneNodeData and not BlackboardDragNodeData).ToArray();
var fetchedSceneNode = graphData.NodeDictionary.Values.Where(x => x is SceneNodeData && x is BlackboardDragNodeData == false).ToArray();
if (!fetchedSceneNode.Any()) return;
var scenePersistent = transform.Find("PersistentData")?.GetComponent<SceneDataPersistent>();
@ -303,7 +303,7 @@ namespace TNodeCore.Runtime.Components{
if (persistentData == null) return;
var fetchedSceneNode =
RuntimeNodes
.Where(x => x.Value.NodeData is SceneNodeData and not BlackboardDragNodeData)
.Where(x => x.Value.NodeData is SceneNodeData & x.Value.NodeData is BlackboardDragNodeData == false)
.Select(x=>x.Value.NodeData).ToArray();
var dic = persistentData.SceneNodeDataDictionary;
@ -412,10 +412,10 @@ namespace TNodeCore.Runtime.Components{
public class SceneDataPersistent:MonoBehaviour,ISerializationCallbackReceiver{
[NonSerialized]
public readonly Dictionary<string,SceneNodeData> SceneNodeDataDictionary = new();
public readonly Dictionary<string,SceneNodeData> SceneNodeDataDictionary = new Dictionary<string,SceneNodeData>();
[SerializeReference]
public List<SceneNodeData> sceneNodeData=new ();
public List<SceneNodeData> sceneNodeData=new List<SceneNodeData>();
public void OnBeforeSerialize(){

@ -8,7 +8,7 @@ namespace TNodeCore.Runtime{
public const string DataPath = "data";
[SerializeReference]
public TData data;
protected static readonly Dictionary<TData,TWrapper> Cache = new ();
protected static readonly Dictionary<TData,TWrapper> Cache = new Dictionary<TData,TWrapper> ();
public static TWrapper Get(TData data){
if (data.GetType().IsGenericType){
return CreateInstance<TWrapper>();

@ -4,7 +4,7 @@ using UnityEngine;
namespace TNodeCore.Runtime{
public static class NodeLogger{
public static Dictionary<string, INodeLoggerImpl> Loggers = new ();
public static Dictionary<string, INodeLoggerImpl> Loggers = new Dictionary<string, INodeLoggerImpl>();
public static void Log(this NodeData t,string message){
if (!Loggers.ContainsKey(t.id)) return;

@ -12,7 +12,7 @@ namespace TNodeCore.Runtime.Models{
get => blackDragData;
set{
blackDragData = value;
if (blackDragData.Contains('.')){
if (blackDragData.Contains(".")){
isListElement = true;
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using TNodeCore.Editor.Models;
using UnityEditor;
using UnityEngine;
@ -42,5 +43,12 @@ namespace TNodeCore.Runtime.Models{
}
}
#if UNITY_EDITOR
[SerializeReference] public List<EditorModel> EditorModels = new List<EditorModel>();
#endif
}
}

@ -82,16 +82,16 @@ namespace TNodeCore.Runtime.RuntimeCache{
public readonly Dictionary<Type, Dictionary<string,GetValueDelegate>> CachedDelegatesForGettingValue =
new ();
new Dictionary<Type, Dictionary<string,GetValueDelegate>>();
public readonly Dictionary<Type,Dictionary<string,SetValueDelegate>> CachedDelegatesForSettingValue =
new ();
new Dictionary<Type,Dictionary<string,SetValueDelegate>>();
public readonly Dictionary<Type,Dictionary<string,IModelPropertyAccessor>> CachedPropertyAccessors =
new ();
new Dictionary<Type,Dictionary<string,IModelPropertyAccessor>> ();
/// <summary>
/// TODO: Converters now work globally, but it should be possible to specify a converter for a specific graph.but it will be too nested.so in current implementation, we will use a global converter.
/// </summary>
private readonly Dictionary<Type,Dictionary<Type,IPortConverterHelper>> CachedPortConverters =
new ();
new Dictionary<Type,Dictionary<Type,IPortConverterHelper>> ();
private readonly Dictionary<Type, Type> _graphBlackboardDictionary = new Dictionary<Type, Type>();
@ -174,7 +174,7 @@ namespace TNodeCore.Runtime.RuntimeCache{
CachedPortConverters[type2].Add(type1,instanceReverse);
}
}
private readonly Dictionary<Tuple<Type,Type>,bool> _possibleImplicitConversions = new ();
private readonly Dictionary<Tuple<Type,Type>,bool> _possibleImplicitConversions = new Dictionary<Tuple<Type,Type>,bool> ();
public bool HasImplicitConversion(Type baseType, Type targetType){
var tuple = new Tuple<Type, Type>(baseType, targetType);
if (_possibleImplicitConversions.ContainsKey(tuple)){

@ -37,7 +37,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.Cache{
private static NodeEditorSingleton _instance;
public readonly Dictionary<Type,Type> FromGenericToSpecific = new NodeEditorTypeDictionary();
public readonly Dictionary<Type, List<Type>> GraphDataUsage = new Dictionary<Type, List<Type>>();
public Dictionary<Type, Type> GraphBlackboard = new();
public Dictionary<Type, Type> GraphBlackboard = new Dictionary<Type, Type> ();
public static NodeEditorSingleton Instance{
get{ return _instance ??= new NodeEditorSingleton(); }
}

@ -34,7 +34,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.GraphBlackboard{
});
this.RegisterCallback<MouseLeaveEvent>((evt) => {
style.borderBottomColor = style.borderRightColor =
style.borderLeftColor = style.borderTopColor = _convertedColor==default?StyleKeyword.Null:_convertedColor;
style.borderLeftColor = style.borderTopColor = _convertedColor==default?StyleKeyword.Null:new StyleColor(_convertedColor);
});
}

@ -55,7 +55,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.Inspector{
serializedObject.ApplyModifiedProperties();
((NodeDataWrapper)_data).ForceNotify();
});
if (_data is SceneNodeData and not BlackboardDragNodeData){
if (_data is SceneNodeData && _data is BlackboardDragNodeData==false){
}
else{

@ -12,12 +12,12 @@ using TNodeCore.Editor;
using TNodeCore.Editor.Blackboard;
using TNodeCore.Editor.EditorPersistence;
using TNodeCore.Editor.NodeGraphView;
using TNodeCore.Editor.Serialization;
using TNodeCore.Editor.Tools.NodeCreator;
using TNodeCore.Runtime.Components;
using TNodeCore.Runtime.Models;
using TNodeCore.Runtime.RuntimeCache;
using Unity.VisualScripting;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
@ -36,7 +36,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
private bool _isInspectorOn;
private NodeSearchWindowProvider _nodeSearchWindowProvider;
private NodeInspector _nodeInspector;
private Dictionary<string,Node> _nodeDict = new();
private Dictionary<string,Node> _nodeDict = new Dictionary<string,Node>();
private IBlackboardView _blackboard;
private bool _loaded;
public T Data{
@ -214,19 +214,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
var dmaPos = dma.eventInfo.mousePosition+editorPosition;
var dmaPosRect = new Rect(dmaPos,new Vector2(500,500));
placematContainer.CreatePlacemat<Placemat>(dmaPosRect,1,"Title");
// Placemat placemat = new Placemat{
// Collapsed = false,
// title = "Placemat",
// visible = true
// };
// placemat.style.minWidth = 500;
// placemat.style.minHeight = 500;
// var dmaPos = dma.eventInfo.mousePosition+editorPosition;
// placemat.SetPosition(new Rect(dmaPos,new Vector2(500,500)));
// AddElement(placemat);
// Debug.Log(placemat);
});
});
}
@ -326,7 +314,10 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
private void OnDragPerform(DragPerformEvent evt){
if (DragAndDrop.GetGenericData("DragSelection") is List<ISelectable>{Count: > 0} data){
if (DragAndDrop.GetGenericData("DragSelection") is List<ISelectable> data){
if (data.Count == 0){
return;
}
var blackboardFields = data.OfType<BlackboardField >();
foreach (var selectable in blackboardFields){
if(selectable is { } field) {
@ -348,13 +339,15 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
AddTNode(dragNodeData,new Rect(evt.mousePosition,new Vector2(200,200)));
}
}
}
}
private void OnDragUpdated(DragUpdatedEvent evt){
//check if the drag data is BlackboardField
if (DragAndDrop.GetGenericData("DragSelection") is List<ISelectable>{Count: > 0} data){
if (DragAndDrop.GetGenericData("DragSelection") is List<ISelectable> data){
if (data.Count <= 0) return;
DragAndDrop.visualMode = DragAndDropVisualMode.Move;
//high light the
}
@ -365,10 +358,10 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
public void ResetGraphView(){
//Clear all nodes
foreach (var node in nodes){
foreach (var node in nodes.ToList()){
RemoveElement(node);
}
foreach (var edge in edges){
foreach (var edge in edges.ToList()){
RemoveElement(edge);
}
if (_nodeDict == null) throw new ArgumentNullException(nameof(_nodeDict));
@ -486,7 +479,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
private void SaveNode(){
foreach (var node in nodes){
foreach (var node in nodes.ToList()){
if (node is IBaseNodeView nodeView){
var nodeData = nodeView.GetNodeData();
if (!_data.NodeDictionary.ContainsKey(nodeData.id)){
@ -497,7 +490,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
}
private void SaveEdge(){
var links = new List<NodeLink>();
foreach (var edge in edges){
foreach (var edge in edges.ToList()){
var inputNode = edge.input.node as IBaseNodeView;
var outputNode = edge.output.node as IBaseNodeView;
if (inputNode != null && outputNode != null){
@ -545,13 +538,13 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
public override List<Port> GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter){
var compatiblePorts = ports.Where(x => startPort != x &&
var compatiblePorts = ports.ToList().Where(x => startPort != x &&
(x.portType == startPort.portType ||
x.portType.IsAssignableFrom(startPort.portType)
)).ToList();
if(startPort.direction==Direction.Input){
//Search output to find ports with type that have implicit conversion or define converter that convert to type of the startPort
var outputPorts = ports.Where(x => x.direction == Direction.Output).ToList();
var outputPorts = ports.ToList().Where(x => x.direction == Direction.Output).ToList();
foreach (var outputPort in outputPorts){
//Want a port type that can convert to to the type of the startPort
if (HasImplicitConversion(outputPort.portType,startPort.portType)){
@ -563,7 +556,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
}
}
else{
var inputPorts = ports.Where(x => x.direction == Direction.Input).ToList();
var inputPorts = ports.ToList().Where(x => x.direction == Direction.Input).ToList();
foreach (var inputPort in inputPorts){
//check if start port could implicitly convert to input port type
@ -651,7 +644,7 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeGraphView{
var nodeView = _nodeDict[nodeData.id];
_nodeDict.Remove(nodeData.id);
//Break all edges connected to this node
foreach (var edge in edges){
foreach (var edge in edges.ToList()){
if (edge.input.node == nodeView || edge.output.node == nodeView){
RemoveElement(edge);
}

@ -1,4 +1,5 @@
using TNodeCore.Editor.Serialization;
using TilemapGenerator.ThirdParty.Extensions;
using TNodeCore.Editor.Serialization;
using TNodeCore.Runtime.Attributes;
using TNodeCore.Runtime.Models;
using UnityEditor;
@ -36,14 +37,14 @@ namespace TNode.TNodeGraphViewImpl.Editor.NodeViews{
//Get serialized property's icon
Texture2D icon = null;
if (serializedProperty == null) return;
if (serializedProperty.boxedValue is Object value){
if (serializedProperty.BoxedValue() is Object value){
icon = AssetPreview.GetMiniThumbnail(value);
}
else{
if (serializedProperty.boxedValue == null){
if (serializedProperty.BoxedValue() == null){
return;
}
icon = AssetPreview.GetMiniTypeThumbnail(serializedProperty.boxedValue.GetType());
icon = AssetPreview.GetMiniTypeThumbnail(serializedProperty.BoxedValue().GetType());
}
label.parent.Add(new Image(){

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 38d289d37c214a2abe473c41194c2f5f
timeCreated: 1659871592

@ -0,0 +1,7 @@
using UnityEditor.Experimental.GraphView;
namespace TNode.TNodeGraphViewImpl.Editor.Placemats{
public class PlacematView:Placemat{
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 523d39ad825643e6bc00799b71976d16
timeCreated: 1659871634

@ -0,0 +1,6 @@
#define UNITY_2020_1_OR_NEWER
namespace TNode.TNodeGtfImpl.Editor{
public class BaseView{
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8e3311d9fc994805bb6580cf29074bcb
timeCreated: 1659876051

@ -6,6 +6,7 @@
"unity": "2022.1",
"unityRelease": "0b5",
"dependencies": {
"com.unity.graphtools.foundation": "0.11.2-preview"
},
"keywords": [
"graph",

Loading…
Cancel
Save