1.fix some bug for creation tools

main
taoria 3 years ago
parent 5a2c5e7e96
commit 3f8daf5be9
  1. 8
      TNode/Editor/Resources/ScriptTemplates/NewGraph.cs.txt
  2. 6
      TNode/Editor/Tools/GraphEditorCreator/SourceGeneratorForGraphEditor.cs
  3. 8
      Usage.meta

@ -1,10 +1,4 @@
using TNode.Editor; using TNode.Models;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.UIElements;
public class $GraphClassName$ : GraphData{ public class $GraphClassName$ : GraphData{
} }

@ -23,14 +23,14 @@ namespace TNode.Editor.Tools.GraphEditorCreator{
var source = template.text.Replace("$EditorClassName$",editorClassName).Replace("$GraphClassName$",graphClassName); var source = template.text.Replace("$EditorClassName$",editorClassName).Replace("$GraphClassName$",graphClassName);
return source; return source;
} }
public string GenerateGraph(string graphClassName,string templatePath){ public string GenerateGraph(string graphClassName,string templateName="NewGraph.cs"){
TextAsset template = Resources.Load<TextAsset>("ScriptTemplates/"+templateName);
//Check if graph class name is valid //Check if graph class name is valid
var regex = new System.Text.RegularExpressions.Regex("^[a-zA-Z0-9_]+$"); var regex = new System.Text.RegularExpressions.Regex("^[a-zA-Z0-9_]+$");
if(!Regex.IsMatch(graphClassName)){ if(!Regex.IsMatch(graphClassName)){
Debug.LogError("The graph class name is invalid. It must be a valid C# identifier."); Debug.LogError("The graph class name is invalid. It must be a valid C# identifier.");
} }
var template = File.ReadAllText(templatePath); var source = template.text.Replace("$GraphClassName$",graphClassName);
var source = template.Replace("$GraphClassName$",graphClassName);
return source; return source;
} }
} }

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 18f38c39496afae47ab40fb512c3ce7c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save