├── .gitignore ├── Assets ├── RedDot.meta ├── RedDot │ ├── Editor.meta │ ├── Editor │ │ ├── AssetsCallback.meta │ │ ├── AssetsCallback │ │ │ ├── CreateRedDotGraphAsset.cs │ │ │ ├── CreateRedDotGraphAsset.cs.meta │ │ │ ├── NewRedDotGraphAction.cs │ │ │ └── NewRedDotGraphAction.cs.meta │ │ ├── Config.meta │ │ ├── Config │ │ │ ├── RedDotEditorConfig.cs │ │ │ └── RedDotEditorConfig.cs.meta │ │ ├── Data.meta │ │ ├── Data │ │ │ ├── EditorRedDotGraph.cs │ │ │ ├── EditorRedDotGraph.cs.meta │ │ │ ├── EditorRedDotManager.cs │ │ │ ├── EditorRedDotManager.cs.meta │ │ │ ├── RedDotEnumDict.cs │ │ │ ├── RedDotEnumDict.cs.meta │ │ │ ├── RedDotGraphData.cs │ │ │ ├── RedDotGraphData.cs.meta │ │ │ ├── RedDotNodeContext.cs │ │ │ └── RedDotNodeContext.cs.meta │ │ ├── Importers.meta │ │ ├── Importers │ │ │ ├── RedDotGraphAssetPostProcessor.cs │ │ │ ├── RedDotGraphAssetPostProcessor.cs.meta │ │ │ ├── RedDotGraphImporter.cs │ │ │ ├── RedDotGraphImporter.cs.meta │ │ │ ├── RedDotGraphImporterEditor.cs │ │ │ └── RedDotGraphImporterEditor.cs.meta │ │ ├── RedDotEnumDictWindow.cs │ │ ├── RedDotEnumDictWindow.cs.meta │ │ ├── RedDotSearchWindowProvider.cs │ │ ├── RedDotSearchWindowProvider.cs.meta │ │ ├── RedDotWindow.cs │ │ ├── RedDotWindow.cs.meta │ │ ├── Resources.meta │ │ ├── Resources │ │ │ ├── Icons.meta │ │ │ ├── Icons │ │ │ │ ├── icon_full.png │ │ │ │ ├── icon_full.png.meta │ │ │ │ ├── icon_new.png │ │ │ │ ├── icon_new.png.meta │ │ │ │ ├── icon_normal.png │ │ │ │ ├── icon_normal.png.meta │ │ │ │ ├── icon_number.png │ │ │ │ ├── icon_number.png.meta │ │ │ │ ├── icon_reddot_title.png │ │ │ │ └── icon_reddot_title.png.meta │ │ │ ├── Styles.meta │ │ │ └── Styles │ │ │ │ ├── Label.uss │ │ │ │ ├── Label.uss.meta │ │ │ │ ├── ListView.uss │ │ │ │ ├── ListView.uss.meta │ │ │ │ ├── ListView.uxml │ │ │ │ ├── ListView.uxml.meta │ │ │ │ ├── Node.uss │ │ │ │ ├── Node.uss.meta │ │ │ │ ├── NodeIconItem.uxml │ │ │ │ ├── NodeIconItem.uxml.meta │ │ │ │ ├── NodeIconItemContainer.uxml │ │ │ │ ├── NodeIconItemContainer.uxml.meta │ │ │ │ ├── SettingItem.uxml │ │ │ │ └── SettingItem.uxml.meta │ │ ├── Util.meta │ │ ├── Util │ │ │ ├── FileUtilities.cs │ │ │ ├── FileUtilities.cs.meta │ │ │ ├── PathUtil.cs │ │ │ └── PathUtil.cs.meta │ │ ├── Views.meta │ │ └── Views │ │ │ ├── RedDotEnumSettingItem.cs │ │ │ ├── RedDotEnumSettingItem.cs.meta │ │ │ ├── RedDotGraphView.cs │ │ │ ├── RedDotGraphView.cs.meta │ │ │ ├── RedDotNodeStatusItem.cs │ │ │ ├── RedDotNodeStatusItem.cs.meta │ │ │ ├── RedDotNodeView.cs │ │ │ └── RedDotNodeView.cs.meta │ ├── Runtime.meta │ └── Runtime │ │ ├── Dag.meta │ │ ├── Dag │ │ ├── DAG.cs │ │ └── DAG.cs.meta │ │ ├── DigraphList.meta │ │ ├── DigraphList │ │ ├── DiGraphList.cs │ │ ├── DiGraphList.cs.meta │ │ ├── DiGraphList_arithmetic.cs │ │ ├── DiGraphList_arithmetic.cs.meta │ │ ├── DiGraphList_edge.cs │ │ ├── DiGraphList_edge.cs.meta │ │ ├── DiGraphList_private.cs │ │ ├── DiGraphList_private.cs.meta │ │ ├── DiGraphList_vertex.cs │ │ ├── DiGraphList_vertex.cs.meta │ │ ├── Edge.cs │ │ ├── Edge.cs.meta │ │ ├── Vertex.cs │ │ └── Vertex.cs.meta │ │ ├── RedDot.meta │ │ ├── RedDot │ │ ├── BaseRedDotGraph.cs │ │ ├── BaseRedDotGraph.cs.meta │ │ ├── RedDotConst.cs │ │ ├── RedDotConst.cs.meta │ │ ├── RedDotExportJson.cs │ │ ├── RedDotExportJson.cs.meta │ │ ├── RedDotExternalLogicVisitor.cs │ │ ├── RedDotExternalLogicVisitor.cs.meta │ │ ├── RedDotGraph.cs │ │ ├── RedDotGraph.cs.meta │ │ ├── RedDotManager.cs │ │ ├── RedDotManager.cs.meta │ │ ├── RedDotManager_config.cs │ │ ├── RedDotManager_config.cs.meta │ │ ├── RedDotManager_internal.cs │ │ ├── RedDotManager_internal.cs.meta │ │ ├── RedDotVertex.cs │ │ └── RedDotVertex.cs.meta │ │ ├── UI.meta │ │ └── UI │ │ ├── RedDotUIFrame.cs │ │ ├── RedDotUIFrame.cs.meta │ │ ├── RedDotUIFrameNode.cs │ │ └── RedDotUIFrameNode.cs.meta ├── Resources.meta ├── Resources │ ├── Icon.meta │ ├── Icon │ │ ├── RedDot.meta │ │ └── RedDot │ │ │ ├── redDotFull.png │ │ │ ├── redDotFull.png.meta │ │ │ ├── redDotNew.png │ │ │ ├── redDotNew.png.meta │ │ │ ├── redDotNormal.png │ │ │ └── redDotNormal.png.meta │ ├── Prefabs.meta │ ├── Prefabs │ │ ├── RedDotUIPrefab.prefab │ │ ├── RedDotUIPrefab.prefab.meta │ │ ├── TestPanel.prefab │ │ └── TestPanel.prefab.meta │ ├── test.json │ ├── test.json.meta │ ├── test.reddotgraph │ └── test.reddotgraph.meta ├── Scenes.meta ├── Scenes │ ├── TestRedDot.unity │ └── TestRedDot.unity.meta ├── Scripts.meta └── Scripts │ ├── RedDotExternalLogicEnum.cs │ ├── RedDotExternalLogicEnum.cs.meta │ ├── RedDotKeyEnum.cs │ ├── RedDotKeyEnum.cs.meta │ ├── RedDotUIMono.cs │ ├── RedDotUIMono.cs.meta │ ├── TestPanel.cs │ ├── TestPanel.cs.meta │ ├── TestProxy.cs │ ├── TestProxy.cs.meta │ ├── TestRedDot.cs │ └── TestRedDot.cs.meta ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset ├── README.md ├── UserSettings └── EditorUserSettings.asset └── images ├── image-2021101101.png ├── image-2021101102.png ├── image-2021101103.png └── image-2021101104.png /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | #fermsi add========================== 62 | obj/ 63 | #Unity generated 64 | Temp/ 65 | Library/ 66 | Logs/ 67 | 68 | # rider cache directory 69 | .idea/ 70 | -------------------------------------------------------------------------------- /Assets/RedDot.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ef5883eeb2f08140bf161fa832644dd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0032403a08dfd334cbffda793568e2c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/AssetsCallback.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecdf74bc402f47ea981b71be9751f01c 3 | timeCreated: 1631061579 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/AssetsCallback/CreateRedDotGraphAsset.cs: -------------------------------------------------------------------------------- 1 | using RedDot.Editor.Config; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace RedDot.Editor.AssetsCallback 6 | { 7 | public static class CreateRedDotGraphAsset 8 | { 9 | [MenuItem("Assets/Create/Red Dot Graph", false, 9999)] 10 | public static void CreateRedDotGraph() 11 | { 12 | var graphItem = ScriptableObject.CreateInstance(); 13 | ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, graphItem, 14 | $"New Red Dot Graph.{RedDotEditorConfig.EXTENSION}", null, null); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/AssetsCallback/CreateRedDotGraphAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34b84ea0cb2e406286ccae7875d79661 3 | timeCreated: 1631061415 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/AssetsCallback/NewRedDotGraphAction.cs: -------------------------------------------------------------------------------- 1 | using RedDot.Editor.Data; 2 | using UnityEditor.ProjectWindowCallback; 3 | 4 | namespace RedDot.Editor.AssetsCallback 5 | { 6 | public class NewRedDotGraphAction: EndNameEditAction 7 | { 8 | public override void Action(int instanceId, string pathName, string resourceFile) 9 | { 10 | var redDotGraphData = new RedDotGraphData(); 11 | redDotGraphData.SaveTo(pathName); 12 | 13 | // UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(pathName); 14 | // Selection.activeObject = obj; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/AssetsCallback/NewRedDotGraphAction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08c2c87c43ae442c8a96c7da7357567a 3 | timeCreated: 1631061626 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Config.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 768d16bf2dc74168829891aeeff85096 3 | timeCreated: 1631146579 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Config/RedDotEditorConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RedDot.Editor.Config 4 | { 5 | public enum RedDotNodeContextStatus 6 | { 7 | Normal = 1, 8 | Number = 2, 9 | New = 4, 10 | Full = 8, 11 | } 12 | 13 | public class RedDotStatusConfig 14 | { 15 | public readonly string StatusDesc; 16 | public readonly string Icon; 17 | 18 | public RedDotStatusConfig(string statusDesc, string icon) 19 | { 20 | StatusDesc = statusDesc; 21 | Icon = icon; 22 | } 23 | } 24 | 25 | public class RedDotEditorConfig 26 | { 27 | public const string EXTENSION = "reddotgraph"; 28 | public const string EXPORT_EXTENSION = "json"; 29 | public const string KEY_WINDOW_TITLE = "Key设置"; 30 | public const string EXTERNAL_ID_WINDOW_TITLE = "逻辑ID设置"; 31 | 32 | private static Dictionary s_statusConfig; 33 | 34 | private static void InitConfig() 35 | { 36 | if (s_statusConfig != null) return; 37 | s_statusConfig = new Dictionary(); 38 | s_statusConfig.Add(RedDotNodeContextStatus.Normal, new RedDotStatusConfig( 39 | "红点", 40 | "Icons/icon_normal" 41 | )); 42 | s_statusConfig.Add(RedDotNodeContextStatus.Full, new RedDotStatusConfig( 43 | "满", 44 | "Icons/icon_full" 45 | )); 46 | s_statusConfig.Add(RedDotNodeContextStatus.New, new RedDotStatusConfig( 47 | "新", 48 | "Icons/icon_new" 49 | )); 50 | s_statusConfig.Add(RedDotNodeContextStatus.Number, new RedDotStatusConfig( 51 | "数字", 52 | "Icons/icon_number" 53 | )); 54 | } 55 | 56 | public static RedDotStatusConfig GetStatusConfig(RedDotNodeContextStatus status) 57 | { 58 | InitConfig(); 59 | return s_statusConfig[status]; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Config/RedDotEditorConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c1a6f425dbf5fa4f8ab209b490d99c5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 149ccb1d4d484efbb9d1e79ac943180d 3 | timeCreated: 1631062106 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/EditorRedDotGraph.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using RedDot.Runtime.RedDot; 3 | using UnityEngine; 4 | 5 | namespace RedDot.Editor.Data 6 | { 7 | public class EditorRedDotGraph : BaseRedDotGraph 8 | { 9 | /// 10 | /// 修改红点类型 11 | /// 12 | /// 13 | /// 14 | /// 15 | public bool ChangeRedDotType(string key, int redDotType) 16 | { 17 | var v = GetRedDotByKey(key); 18 | if (v == null) 19 | { 20 | // Debug.Log($"没有找到对应名字的红点节点:{key}"); 21 | return false; 22 | } 23 | 24 | v.RedDotType = redDotType; 25 | 26 | return true; 27 | } 28 | 29 | public int RemoveEdge(string vex1, string vex2) 30 | { 31 | if (!VertexDict.TryGetValue(vex1, out int v)) 32 | { 33 | Debug.Log($"没找到顶点:{vex1}"); 34 | return -1; 35 | } 36 | if (!VertexDict.TryGetValue(vex2, out int u)) 37 | { 38 | Debug.Log($"没找到顶点:{vex2}"); 39 | return -1; 40 | } 41 | 42 | return Remove(v, u); 43 | } 44 | 45 | /// 46 | /// 修改红点的key,key不能重名 47 | /// 48 | /// 49 | /// 50 | public bool ChangeRedDotKey(string oldStr, string newStr) 51 | { 52 | if (CheckHasRedDotByKey(newStr)) 53 | { 54 | Debug.Log($"新名字已经被占用:{newStr}"); 55 | return false; 56 | } 57 | var v = GetRedDotByKey(oldStr); 58 | if (v != null) 59 | { 60 | v.Key = newStr; 61 | VertexDict[newStr] = VertexDict[oldStr]; 62 | VertexDict.Remove(oldStr); 63 | return true; 64 | } 65 | 66 | Debug.Log($"没有找到对应名字的红点节点:{newStr}"); 67 | return false; 68 | } 69 | 70 | /// 71 | /// 删除顶点及其关联边,返回该顶点信息 72 | /// 73 | /// 74 | /// 75 | public override RedDotVertex Remove(int r) 76 | { 77 | var vertex = GetVertex(r); 78 | var temp = VertexDict.Keys.ToList(); 79 | //需要更新vertexDict中的其他key对应的index 80 | foreach (var key in temp) 81 | { 82 | if (VertexDict[key] > r) 83 | { 84 | VertexDict[key] = VertexDict[key] - 1; 85 | } 86 | } 87 | VertexDict.Remove(vertex.Key); 88 | return base.Remove(r); 89 | } 90 | 91 | /// 92 | /// 通过key删除顶点 93 | /// 94 | /// 95 | /// 96 | public RedDotVertex RemoveByKey(string key) 97 | { 98 | if (VertexDict.TryGetValue(key, out int index)) 99 | { 100 | return Remove(index); 101 | } 102 | Debug.Log($"没有找到对应名字的红点节点:{key}"); 103 | return null; 104 | } 105 | 106 | /// 107 | /// 获取顶点所在的秩,-1为返回失败 108 | /// 109 | /// 110 | /// 111 | public int GetVertexRank(string vexKey) 112 | { 113 | if (!VertexDict.TryGetValue(vexKey, out int v)) 114 | { 115 | Debug.Log($"没找到顶点:{vexKey}"); 116 | return -1; 117 | } 118 | 119 | return v; 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/EditorRedDotGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59d6e816010d8874eabbf6228a50e992 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/EditorRedDotManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RedDot.Runtime.RedDot; 3 | 4 | namespace RedDot.Editor.Data 5 | { 6 | public class EditorRedDotManager 7 | { 8 | private static EditorRedDotManager s_ins = null; 9 | public static EditorRedDotManager Ins() 10 | { 11 | if (s_ins == null) 12 | { 13 | s_ins = new EditorRedDotManager(); 14 | } 15 | return s_ins; 16 | } 17 | 18 | private EditorRedDotGraph _redDotGraph = new EditorRedDotGraph(); 19 | 20 | private EditorRedDotManager() 21 | { 22 | 23 | } 24 | 25 | /// 26 | /// 添加红点顶点 27 | /// 28 | /// 29 | /// 30 | /// 31 | /// 32 | public int AddRedDotVertex(string key, int redDotType, int externalId = -1) 33 | { 34 | return _redDotGraph.Insert(new RedDotVertex(key, redDotType, externalId)); 35 | } 36 | 37 | /// 38 | /// 添加边 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | public bool AddRedDotEdge(string vex1, string vex2, int weight = 0) 45 | { 46 | return _redDotGraph.InsertEdge(vex1, vex2, weight); 47 | } 48 | 49 | /// 50 | /// 修改红点的key,key不能重名 51 | /// 52 | /// 53 | /// 54 | /// 55 | public bool ChangeRedDotKey(string oldStr, string newStr) 56 | { 57 | return _redDotGraph.ChangeRedDotKey(oldStr, newStr); 58 | } 59 | 60 | /// 61 | /// 把边的结束顶点oldEndVex,修改到newEndVex 62 | /// 63 | /// 64 | /// 65 | /// 66 | /// 67 | public bool ChangeEdgeTo(string startVex, string oldEndVex, string newEndVex) 68 | { 69 | int r1 = _redDotGraph.GetVertexRank(startVex); 70 | int r2 = _redDotGraph.GetVertexRank(oldEndVex); 71 | if (r1 == -1 || r2 == -1) return false; 72 | var weight = _redDotGraph.GetWeight(r1, r2); 73 | //要修改的那条边并不会影响新添加边的回路 74 | //意思就是说:新添加的边,不会因为有边(startVex->oldEndVex)而影响其构成回路 75 | //所以先添加边即可 76 | if (AddRedDotEdge(startVex, newEndVex, weight)) 77 | { 78 | _redDotGraph.Remove(r1, r2); 79 | return true; 80 | } 81 | return false; 82 | } 83 | 84 | /// 85 | /// 修改边的权重 86 | /// 87 | /// 88 | /// 89 | /// 90 | /// 91 | public bool ChangeWeight(string vex1, string vex2, int weight) 92 | { 93 | int r1 = _redDotGraph.GetVertexRank(vex1); 94 | int r2 = _redDotGraph.GetVertexRank(vex2); 95 | if (r1 == -1 || r2 == -1) 96 | { 97 | Console.WriteLine("修改权重失败,节点没有获取到"); 98 | return false; 99 | } 100 | _redDotGraph.SetWeight(r1, r2, weight); 101 | return true; 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/EditorRedDotManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e73386a4fa9e5049a3d53725f7a853c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotEnumDict.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using RedDot.Editor.Util; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | namespace RedDot.Editor.Data 9 | { 10 | [Serializable] 11 | public class RedDotEnumInfo 12 | { 13 | public int id; 14 | public string key; 15 | public string desc; 16 | } 17 | [Serializable] 18 | public class RedDotEnumDict 19 | { 20 | private Dictionary _enumDict; 21 | private Dictionary _descDict; 22 | public List enumInfos = new List(); 23 | 24 | public string classTemplate = 25 | "namespace RedDotDemo\n{\n\tpublic enum RedDotKeyEnum\n\t{\n[[key&values]]\n\t}\n}"; 26 | public string keyValueReg = "\t\t[[key]] = [[value]],//[[desc]]"; 27 | public string exportFileName = "RedDotKeyEnum.cs"; 28 | private int _maxId = 0; 29 | [NonSerialized] 30 | private RedDotGraphData _graphData; 31 | private bool _isChanged = false; 32 | public bool IsChanged => _isChanged; 33 | private bool _isCached = true; 34 | public bool IsCached => _isCached; 35 | public void ClearChangedTag() 36 | { 37 | _isChanged = false; 38 | } 39 | 40 | public List GetIds() 41 | { 42 | return _enumDict.Keys.ToList(); 43 | } 44 | 45 | public List GetNodeKeys() 46 | { 47 | var keys = new List(); 48 | keys.Add("null"); 49 | foreach (var info in _enumDict) 50 | { 51 | keys.Add($"{info.Key}:{info.Value}"); 52 | } 53 | return keys; 54 | } 55 | 56 | public string GetNodeKey(int id) 57 | { 58 | string key; 59 | if (_enumDict.TryGetValue(id, out key)) 60 | { 61 | key = $"{id}:{key}"; 62 | } 63 | else 64 | { 65 | key = "null"; 66 | } 67 | 68 | return key; 69 | } 70 | 71 | public int GetIdByNodeKey(string key) 72 | { 73 | if (key == "null") return 0; 74 | return Convert.ToInt32(key.Split(':')[0]); 75 | } 76 | 77 | public void PrepareExport() 78 | { 79 | enumInfos.Clear(); 80 | _isCached = true; 81 | if (_enumDict == null) 82 | { 83 | _enumDict = new Dictionary(); 84 | } 85 | if (_descDict == null) 86 | { 87 | _descDict = new Dictionary(); 88 | } 89 | foreach (var info in _enumDict) 90 | { 91 | enumInfos.Add(new RedDotEnumInfo(){desc = GetDesc(info.Key), id = info.Key, key = info.Value}); 92 | } 93 | } 94 | 95 | public void ValidateData(RedDotGraphData graphData) 96 | { 97 | _graphData = graphData; 98 | _enumDict = new Dictionary(); 99 | _descDict = new Dictionary(); 100 | _maxId = 0; 101 | foreach (var info in enumInfos) 102 | { 103 | var id = info.id; 104 | _enumDict[id] = info.key; 105 | _descDict[id] = info.desc; 106 | if (id > _maxId) 107 | { 108 | _maxId = id; 109 | } 110 | } 111 | } 112 | 113 | public int Add() 114 | { 115 | var id = ++_maxId; 116 | _enumDict[id] = "Default"; 117 | _descDict[id] = "加一点描述吧"; 118 | _graphData.Dirty(); 119 | _isChanged = true; 120 | _isCached = false; 121 | return id; 122 | } 123 | 124 | public void Remove(int id) 125 | { 126 | _enumDict.Remove(id); 127 | _descDict.Remove(id); 128 | _isChanged = true; 129 | _isCached = false; 130 | _graphData.Dirty(); 131 | } 132 | 133 | public void ChangeKey(int id, string info) 134 | { 135 | if (_enumDict.ContainsKey(id)) 136 | { 137 | _enumDict[id] = info; 138 | _graphData.Dirty(); 139 | _isCached = false; 140 | } 141 | } 142 | 143 | public string GetKey(int id) 144 | { 145 | string key; 146 | if (!_enumDict.TryGetValue(id, out key)) 147 | { 148 | key = "null"; 149 | } 150 | 151 | return key; 152 | } 153 | 154 | public void ChangeDesc(int id, string info) 155 | { 156 | if (_descDict.ContainsKey(id)) 157 | { 158 | _descDict[id] = info; 159 | _graphData.Dirty(); 160 | _isCached = false; 161 | } 162 | } 163 | 164 | public string GetDesc(int id) 165 | { 166 | string key; 167 | if (!_descDict.TryGetValue(id, out key)) 168 | { 169 | key = "null"; 170 | } 171 | 172 | return key; 173 | } 174 | 175 | public void ChangeKeyAndValueReg(string newReg) 176 | { 177 | keyValueReg = newReg; 178 | _isChanged = true; 179 | _graphData.Dirty(); 180 | } 181 | 182 | public void ChangeClassTemplate(string newTemplate) 183 | { 184 | classTemplate = newTemplate; 185 | _isChanged = true; 186 | _graphData.Dirty(); 187 | } 188 | 189 | public void ChangeExportFileName(string fileName) 190 | { 191 | exportFileName = fileName; 192 | _isChanged = true; 193 | _graphData.Dirty(); 194 | } 195 | 196 | public void ExportTo(string filePath) 197 | { 198 | //[[key]] = [[value]];//[[desc]] 199 | var keyAndValuesStr = ""; 200 | var endingSymble = ""; 201 | foreach (var info in _enumDict) 202 | { 203 | var id = info.Key; 204 | var desc = GetDesc(id); 205 | keyAndValuesStr += endingSymble + keyValueReg.Replace("[[key]]", info.Value). 206 | Replace("[[value]]", id.ToString()). 207 | Replace("[[desc]]", desc); 208 | endingSymble = "\n"; 209 | } 210 | //[[key&values]] 211 | var code = classTemplate.Replace("[[key&values]]", keyAndValuesStr); 212 | Debug.Log(code); 213 | FileUtilities.WriteToDisk(filePath, code); 214 | AssetDatabase.Refresh(); 215 | } 216 | } 217 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotEnumDict.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da84cbaa1a6d42f3b955addf7beffb52 3 | timeCreated: 1632874227 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotGraphData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using RedDot.Editor.Util; 4 | using RedDot.Runtime.RedDot; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using Object = UnityEngine.Object; 8 | 9 | namespace RedDot.Editor.Data 10 | { 11 | [Serializable] 12 | public class RedDotGraphData 13 | { 14 | private static int s_curCount = 0; 15 | public List nodeContexts = new List(); 16 | public RedDotEnumDict keyEnumDict = new RedDotEnumDict(); 17 | public RedDotEnumDict externalIdEnumDict = new RedDotEnumDict(); 18 | private EditorRedDotGraph _editorRedDotGraph = new EditorRedDotGraph(); 19 | 20 | public RedDotNodeContext CreateNodeContext(Vector2 position) 21 | { 22 | var context = new RedDotNodeContext(); 23 | context.id = ++s_curCount; 24 | var key = context.id.ToString(); 25 | context.position = position; 26 | nodeContexts.Add(context); 27 | var vertex = new RedDotVertex(key, 0, -1); 28 | _editorRedDotGraph.Insert(vertex); 29 | Dirty(); 30 | return context; 31 | } 32 | 33 | public void ValidateGraph() 34 | { 35 | s_curCount = 0; 36 | 37 | keyEnumDict.ValidateData(this); 38 | externalIdEnumDict.ValidateData(this); 39 | 40 | foreach (var context in nodeContexts) 41 | { 42 | if (context.id > s_curCount) 43 | { 44 | s_curCount = context.id; 45 | } 46 | var key = context.id.ToString(); 47 | var vertex = new RedDotVertex(key, 0, -1); 48 | _editorRedDotGraph.Insert(vertex); 49 | } 50 | 51 | foreach (var context in nodeContexts) 52 | { 53 | foreach (var outId in context.outNodeIds) 54 | { 55 | if (!_editorRedDotGraph.InsertEdge(context.id.ToString(), outId.ToString())) 56 | { 57 | Debug.Log($"out:{context.id}, in:{outId} insert edge fail"); 58 | } 59 | else 60 | { 61 | Debug.Log($"out:{context.id}, in:{outId} insert edge success"); 62 | 63 | } 64 | } 65 | } 66 | } 67 | 68 | public bool RemoveNodeContext(RedDotNodeContext nodeContext) 69 | { 70 | // Debug.Log($"==========RemoveNodeContext:{nodeContext}"); 71 | if (nodeContext != null) 72 | { 73 | if (_editorRedDotGraph.RemoveByKey(nodeContext.id.ToString()) != null) 74 | { 75 | // Debug.Log($"==========RemoveNodeContext:RemoveByKey"); 76 | Dirty(); 77 | return nodeContexts.Remove(nodeContext); 78 | } 79 | // Debug.Log($"==========RemoveNodeContext:fail"); 80 | } 81 | return false; 82 | } 83 | 84 | public bool RemoveEdge(RedDotNodeContext inNodeContext, RedDotNodeContext outNodeContext) 85 | { 86 | if (_editorRedDotGraph.RemoveEdge(outNodeContext.id.ToString(), inNodeContext.id.ToString()) != -1) 87 | { 88 | outNodeContext.RemoveOutNode(inNodeContext.id); 89 | Dirty(); 90 | return true; 91 | } 92 | 93 | return false; 94 | } 95 | 96 | public bool AddEdge(RedDotNodeContext inNodeContext, RedDotNodeContext outNodeContext) 97 | { 98 | var success = _editorRedDotGraph.InsertEdge(outNodeContext.id.ToString(), inNodeContext.id.ToString()); 99 | if (success) 100 | { 101 | outNodeContext.AddOutNode(inNodeContext.id); 102 | Dirty(); 103 | } 104 | 105 | return success; 106 | } 107 | 108 | private bool _dirty = false; 109 | public void Dirty() 110 | { 111 | _dirty = true; 112 | } 113 | 114 | public bool IsDirty => _dirty; 115 | 116 | public bool SaveTo(string pathName) 117 | { 118 | CacheData(); 119 | FileUtilities.WriteRedDotGraphDataToDisk(pathName, this); 120 | AssetDatabase.Refresh(); 121 | _dirty = false; 122 | return true; 123 | } 124 | 125 | public void CacheData() 126 | { 127 | keyEnumDict.PrepareExport(); 128 | externalIdEnumDict.PrepareExport(); 129 | } 130 | 131 | public bool IsDataCached() 132 | { 133 | return keyEnumDict.IsCached && externalIdEnumDict.IsCached; 134 | } 135 | 136 | public void ExportTo(string pathName) 137 | { 138 | var exportJson = new RedDotExportJson(); 139 | var nodeContextDict = new Dictionary(); 140 | foreach (var nodeContext in nodeContexts) 141 | { 142 | nodeContextDict[nodeContext.id] = nodeContext; 143 | var node = new RedDotNodeJson(); 144 | node.key = keyEnumDict.GetKey(nodeContext.keyId); 145 | node.redDotType = nodeContext.redDotType; 146 | node.externalId = nodeContext.funcId; 147 | exportJson.vertexs.Add(node); 148 | } 149 | 150 | foreach (var nodeContext in nodeContexts) 151 | { 152 | var edge = new RedDotEdgeJson(); 153 | edge.key = keyEnumDict.GetKey(nodeContext.keyId); 154 | foreach (var id in nodeContext.outNodeIds) 155 | { 156 | edge.outKeys.Add(keyEnumDict.GetKey(nodeContextDict[id].keyId)); 157 | } 158 | exportJson.edges.Add(edge); 159 | } 160 | FileUtilities.WriteRedDotGraphDataToDisk(pathName, exportJson); 161 | AssetDatabase.Refresh(); 162 | } 163 | } 164 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotGraphData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78c48309fefc4929ba3a21c97f5a0e39 3 | timeCreated: 1631062126 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotNodeContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using RedDot.Editor.Config; 4 | using UnityEngine; 5 | 6 | namespace RedDot.Editor.Data 7 | { 8 | [Serializable] 9 | public class RedDotNodeContext 10 | { 11 | public int id; 12 | public Vector2 position; 13 | public List outNodeIds = new List(); 14 | public int keyId; 15 | public int funcId; 16 | public int redDotType; 17 | 18 | public void RemoveOutNode(int id) 19 | { 20 | outNodeIds.Remove(id); 21 | } 22 | 23 | public void AddOutNode(int id) 24 | { 25 | outNodeIds.Add(id); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Data/RedDotNodeContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f11f4c37ef6b454bbe402ac13a8f1491 3 | timeCreated: 1631147121 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63378d6879b64b149ecb79e94be0e474 3 | timeCreated: 1631060357 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphAssetPostProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using RedDot.Editor.Config; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace RedDot.Editor.Importers 8 | { 9 | class RedDotGraphAssetPostProcessor : AssetPostprocessor 10 | { 11 | static void UpdateAfterAssetChange(string[] newNames) 12 | { 13 | // This will change the title of the window. 14 | RedDotWindow[] windows = Resources.FindObjectsOfTypeAll(); 15 | foreach (var matGraphEditWindow in windows) 16 | { 17 | for (int i = 0; i < newNames.Length; ++i) 18 | { 19 | if (matGraphEditWindow.curGuid == AssetDatabase.AssetPathToGUID(newNames[i])) 20 | matGraphEditWindow.UpdateTitle(); 21 | } 22 | } 23 | } 24 | 25 | static void DisplayDeletionDialog(string[] deletedAssets) 26 | { 27 | RedDotWindow[] windows = Resources.FindObjectsOfTypeAll(); 28 | foreach (var matGraphEditWindow in windows) 29 | { 30 | for (int i = 0; i < deletedAssets.Length; ++i) 31 | { 32 | if (matGraphEditWindow.curGuid == AssetDatabase.AssetPathToGUID(deletedAssets[i])) 33 | matGraphEditWindow.AssetWasDeleted(); 34 | } 35 | } 36 | } 37 | 38 | static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) 39 | { 40 | // RegisterShaders(importedAssets); 41 | 42 | // Moved assets 43 | bool anyMovedShaders = movedAssets.Any(val => val.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase)); 44 | anyMovedShaders |= movedAssets.Any(val => val.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase)); 45 | if (anyMovedShaders) 46 | UpdateAfterAssetChange(movedAssets); 47 | 48 | // Deleted assets 49 | bool anyRemovedShaders = deletedAssets.Any(val => val.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase)); 50 | anyRemovedShaders |= deletedAssets.Any(val => val.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase)); 51 | if (anyRemovedShaders) 52 | DisplayDeletionDialog(deletedAssets); 53 | 54 | var windows = Resources.FindObjectsOfTypeAll(); 55 | 56 | var changedGraphGuids = importedAssets 57 | .Where(x => x.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase) 58 | || x.EndsWith(RedDotEditorConfig.EXTENSION, StringComparison.InvariantCultureIgnoreCase)) 59 | .Select(AssetDatabase.AssetPathToGUID) 60 | .ToList(); 61 | foreach (var window in windows) 62 | { 63 | if (changedGraphGuids.Contains(window.curGuid)) 64 | { 65 | window.CheckForChanges(); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphAssetPostProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2311d9ca065541d2a7dfafa195291150 3 | timeCreated: 1631837457 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphImporter.cs: -------------------------------------------------------------------------------- 1 | using RedDot.Editor.Config; 2 | using UnityEditor.AssetImporters; 3 | using UnityEngine; 4 | 5 | namespace RedDot.Editor.Importers 6 | { 7 | [ScriptedImporter(1, RedDotEditorConfig.EXTENSION)] 8 | public class RedDotGraphImporter : ScriptedImporter 9 | { 10 | public override void OnImportAsset(AssetImportContext ctx) 11 | { 12 | var mainObject = new GameObject("RedDotImportAsset"); 13 | Texture2D texture = Resources.Load("Icons/icon_reddot_title"); 14 | ctx.AddObjectToAsset("RedDotImportAsset", mainObject, texture); 15 | ctx.SetMainObject(mainObject); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphImporter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b19e962da19c49f9ae56d5705e8a8ff3 3 | timeCreated: 1631060429 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphImporterEditor.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using RedDot.Editor.Config; 3 | using UnityEditor; 4 | using UnityEditor.AssetImporters; 5 | using UnityEditor.Callbacks; 6 | using UnityEngine; 7 | 8 | namespace RedDot.Editor.Importers 9 | { 10 | [CustomEditor(typeof(RedDotGraphImporter))] 11 | public class RedDotGraphImporterEditor : ScriptedImporterEditor 12 | { 13 | public override void OnInspectorGUI() 14 | { 15 | if (GUILayout.Button("Open Red Dot Editor")) 16 | { 17 | AssetImporter importer = target as AssetImporter; 18 | ShowGraphEditWindow(importer.assetPath); 19 | } 20 | 21 | ApplyRevertGUI(); 22 | } 23 | 24 | [OnOpenAsset(0)] 25 | public static bool OnOpenAsset(int instanceID, int line) 26 | { 27 | var path = AssetDatabase.GetAssetPath(instanceID); 28 | return ShowGraphEditWindow(path); 29 | } 30 | 31 | internal static bool ShowGraphEditWindow(string path) 32 | { 33 | var guid = AssetDatabase.AssetPathToGUID(path); 34 | var extension = Path.GetExtension(path); 35 | if (string.IsNullOrEmpty(extension)) 36 | return false; 37 | extension = extension.Substring(1).ToLowerInvariant(); 38 | if (extension != RedDotEditorConfig.EXTENSION) 39 | return false; 40 | 41 | foreach (var w in Resources.FindObjectsOfTypeAll()) 42 | { 43 | if (w.curGuid == guid) 44 | { 45 | w.Focus(); 46 | return true; 47 | } 48 | } 49 | 50 | var window = EditorWindow.CreateWindow(typeof(RedDotWindow)); 51 | window.Initialize(guid); 52 | // window.Initialize(guid); 53 | window.Focus(); 54 | return true; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Importers/RedDotGraphImporterEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b79a4c0ba9e44193817688c625191210 3 | timeCreated: 1631060865 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/RedDotEnumDictWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using RedDot.Editor.Data; 5 | using RedDot.Editor.Util; 6 | using RedDot.Editor.Views; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using UnityEngine.UIElements; 10 | 11 | namespace RedDot.Editor 12 | { 13 | public class RedDotEnumDictWindow : EditorWindow 14 | { 15 | private RedDotEnumDict _enumDict; 16 | private List _ids; 17 | private ListView _listView; 18 | public void Initialize(RedDotEnumDict enumDict, string titleStr) 19 | { 20 | _enumDict = enumDict; 21 | rootVisualElement.Clear(); 22 | titleContent = new GUIContent(titleStr); 23 | var toolbar = new IMGUIContainer(() => 24 | { 25 | GUILayout.BeginHorizontal(EditorStyles.toolbar); 26 | if (GUILayout.Button("增加Key & Value条目", EditorStyles.toolbarButton)) 27 | { 28 | enumDict.Add(); 29 | } 30 | GUILayout.Space(6); 31 | if (GUILayout.Button("生成代码", EditorStyles.toolbarButton)) 32 | {; 33 | ExportTo(); 34 | } 35 | 36 | GUILayout.EndHorizontal(); 37 | }); 38 | rootVisualElement.Add(toolbar); 39 | InitListView(); 40 | 41 | var exportFileNameField = new TextField("生成文件名"); 42 | exportFileNameField.value = _enumDict.exportFileName; 43 | exportFileNameField.RegisterValueChangedCallback(evt => 44 | { 45 | _enumDict.ChangeExportFileName(exportFileNameField.value); 46 | }); 47 | rootVisualElement.Add(exportFileNameField); 48 | 49 | var keyValueRegField = new TextField("Key & Value生成规则"); 50 | keyValueRegField.multiline = true; 51 | keyValueRegField.value = _enumDict.keyValueReg; 52 | keyValueRegField.RegisterValueChangedCallback(evt => 53 | { 54 | _enumDict.ChangeKeyAndValueReg(keyValueRegField.value); 55 | }); 56 | rootVisualElement.Add(keyValueRegField); 57 | 58 | var templateField = new TextField("代码模板"); 59 | templateField.multiline = true; 60 | templateField.value = _enumDict.classTemplate; 61 | templateField.RegisterValueChangedCallback(evt => 62 | { 63 | _enumDict.ChangeClassTemplate(templateField.value); 64 | }); 65 | rootVisualElement.Add(templateField); 66 | 67 | RefreshData(); 68 | } 69 | 70 | public void RefreshData() 71 | { 72 | if (_enumDict == null) return; 73 | _ids = _enumDict.GetIds(); 74 | _listView.itemsSource = _ids; 75 | _listView.ScrollToItem(_ids.Count - 1); 76 | } 77 | 78 | private void InitListView() 79 | { 80 | Func makeItem = () => 81 | { 82 | return new RedDotEnumSettingItem(_enumDict); 83 | }; 84 | 85 | Action bindItem = (e, i) => (e as RedDotEnumSettingItem).SetId(_ids[i]); 86 | 87 | var visualTree = AssetDatabase.LoadAssetAtPath(PathUtil.GetEditorFilePath("Resources/Styles/ListView.uxml")); 88 | var styleSheet = AssetDatabase.LoadAssetAtPath(PathUtil.GetEditorFilePath("Resources/Styles/ListView.uss")); 89 | VisualElement container = visualTree.Instantiate(); 90 | rootVisualElement.Add(container); 91 | container.styleSheets.Add(styleSheet); 92 | _listView = container.Q(); 93 | _listView.makeItem = makeItem; 94 | _listView.bindItem = bindItem; 95 | _listView.selectionType = SelectionType.None; 96 | _listView.showBorder = true; 97 | } 98 | 99 | // void OnEnable() 100 | // { 101 | // RefreshData(); 102 | // } 103 | 104 | private void Update() 105 | { 106 | if (_enumDict.IsChanged) 107 | { 108 | _enumDict.ClearChangedTag(); 109 | RefreshData(); 110 | } 111 | } 112 | 113 | public void ExportTo() 114 | { 115 | if (_enumDict != null) 116 | { 117 | var oldFilePath = Application.dataPath; 118 | var extension = Path.GetExtension(_enumDict.exportFileName); 119 | extension = extension.Replace(".", ""); 120 | Debug.Log($"{_enumDict.exportFileName}, {Path.GetFileNameWithoutExtension(_enumDict.exportFileName)}, {Path.GetExtension(_enumDict.exportFileName)}"); 121 | var newFilePath = EditorUtility.SaveFilePanelInProject("Export Red Dot Graph to Json", Path.GetFileNameWithoutExtension(_enumDict.exportFileName), extension, "", oldFilePath); 122 | newFilePath = newFilePath.Replace(Application.dataPath, "Assets"); 123 | 124 | if (!string.IsNullOrEmpty(newFilePath)) 125 | { 126 | _enumDict.ExportTo(newFilePath); 127 | } 128 | } 129 | } 130 | } 131 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/RedDotEnumDictWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bec75f58bf145538d16f082ec6a00eb 3 | timeCreated: 1632875889 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/RedDotSearchWindowProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using RedDot.Editor.Views; 3 | using UnityEditor.Experimental.GraphView; 4 | using UnityEngine; 5 | 6 | namespace RedDot.Editor 7 | { 8 | public class RedDotSearchWindowProvider:ScriptableObject, ISearchWindowProvider 9 | { 10 | public delegate bool SerchMenuWindowOnSelectEntryDelegate(SearchTreeEntry searchTreeEntry, //声明一个delegate类 11 | SearchWindowContext context); 12 | 13 | public SerchMenuWindowOnSelectEntryDelegate OnSelectEntryHandler; //delegate回调方法 14 | 15 | public bool OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context) 16 | { 17 | if (OnSelectEntryHandler == null) 18 | { 19 | return false; 20 | } 21 | return OnSelectEntryHandler(searchTreeEntry, context); 22 | } 23 | 24 | public List CreateSearchTree(SearchWindowContext context) 25 | { 26 | var entries = new List(); 27 | entries.Add(new SearchTreeGroupEntry(new GUIContent("Create RedDot Node"))); //添加了一个一级菜单 28 | 29 | // entries.Add(new SearchTreeGroupEntry(new GUIContent("Example")) { level = 1 }); //添加了一个二级菜单 30 | entries.Add(new SearchTreeEntry(new GUIContent("RedDot Node")) { level = 1, userData = typeof(RedDotNodeView) }); 31 | return entries; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/RedDotSearchWindowProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03e227ce12684238a8cfa90321607c61 3 | timeCreated: 1630247843 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/RedDotWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c55ef5d9218826a47a4e47a6741a6487 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35dde7e64dd74108bf30c7cecb8b7a22 3 | timeCreated: 1631806252 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2135086692a54d288676ed58933a8209 3 | timeCreated: 1631806275 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermsi/RedDotGraph/9cee78b1ab21bddf659ef959d211098c5603ec23/Assets/RedDot/Editor/Resources/Icons/icon_full.png -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_full.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f39994e53a067b44a05be06b59b9fc7 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermsi/RedDotGraph/9cee78b1ab21bddf659ef959d211098c5603ec23/Assets/RedDot/Editor/Resources/Icons/icon_new.png -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_new.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ae27d4b0e6bce34b9596daf997d542a 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermsi/RedDotGraph/9cee78b1ab21bddf659ef959d211098c5603ec23/Assets/RedDot/Editor/Resources/Icons/icon_normal.png -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 065d61340db3f8e4882ce8fd37e88808 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_number.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermsi/RedDotGraph/9cee78b1ab21bddf659ef959d211098c5603ec23/Assets/RedDot/Editor/Resources/Icons/icon_number.png -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_number.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76be616187a49e24780c9811ee109c40 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_reddot_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermsi/RedDotGraph/9cee78b1ab21bddf659ef959d211098c5603ec23/Assets/RedDot/Editor/Resources/Icons/icon_reddot_title.png -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Icons/icon_reddot_title.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9020bed3df21b04dba2fd57895bd8c8 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8313edc2425e10b4ebd2fd7a5e02bad9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/Label.uss: -------------------------------------------------------------------------------- 1 | Label { 2 | color: rgb(255, 255, 255); 3 | } 4 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/Label.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e0cbdfedd67a6a47947030348f73112 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/ListView.uss: -------------------------------------------------------------------------------- 1 | .the-uxml-listview { 2 | /* Provide the list view with an explict height for every row 3 | so it can calculate how many items to actually display */ 4 | --unity-item-height: 20; 5 | height: 500px; 6 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/ListView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c75860e688b45f59f6d9ed14da17add 3 | timeCreated: 1632928664 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/ListView.uxml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/ListView.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cb303904dbc45bdafe723ff7bb8b230 3 | timeCreated: 1632928766 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/Node.uss: -------------------------------------------------------------------------------- 1 | VisualElement { 2 | background-color: rgba(0, 0, 0, 0.55); 3 | } 4 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/Node.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3b731897a598ca4ea6340a6fb563424 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/NodeIconItem.uxml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/NodeIconItem.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5884f50e98e744de885f3594244f5b13 3 | timeCreated: 1633686908 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/NodeIconItemContainer.uxml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/NodeIconItemContainer.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cef8970949c4c009bf4881743c59f1d 3 | timeCreated: 1633689463 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/SettingItem.uxml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Resources/Styles/SettingItem.uxml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fccacc5f768c4012ab2f75cd66c33b90 3 | timeCreated: 1632930762 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Util.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc9adb8cd2d84447a5b1b020d7fd1a6a 3 | timeCreated: 1631062022 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Util/FileUtilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using Debug = UnityEngine.Debug; 7 | 8 | namespace RedDot.Editor.Util 9 | { 10 | static class FileUtilities 11 | { 12 | public static string WriteRedDotGraphDataToDisk(string path, object data) 13 | { 14 | if (data == null) 15 | { 16 | throw new ArgumentNullException(nameof(data)); 17 | } 18 | 19 | var text = JsonUtility.ToJson(data, true); 20 | if (WriteToDisk(path, text)) 21 | return text; 22 | else 23 | return null; 24 | } 25 | 26 | // returns true if successfully written to disk 27 | public static bool WriteToDisk(string path, string text) 28 | { 29 | while (true) 30 | { 31 | try 32 | { 33 | File.WriteAllText(path, text); 34 | } 35 | catch (Exception e) 36 | { 37 | if (e.GetBaseException() is UnauthorizedAccessException && 38 | (File.GetAttributes(path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) 39 | { 40 | if (EditorUtility.DisplayDialog("File is Read-Only", path, "Make Writeable", "Cancel Save")) 41 | { 42 | // make writeable 43 | FileInfo fileInfo = new FileInfo(path); 44 | fileInfo.IsReadOnly = false; 45 | continue; // retry save 46 | } 47 | else 48 | return false; 49 | } 50 | 51 | Debug.LogException(e); 52 | 53 | if (EditorUtility.DisplayDialog("Exception While Saving", e.ToString(), "Retry", "Cancel")) 54 | continue; // retry save 55 | else 56 | return false; 57 | } 58 | break; // no exception, file save success! 59 | } 60 | 61 | return true; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Util/FileUtilities.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb35fb533c724088833075be5ee0fa73 3 | timeCreated: 1631061977 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Util/PathUtil.cs: -------------------------------------------------------------------------------- 1 | namespace RedDot.Editor.Util 2 | { 3 | public static class PathUtil 4 | { 5 | public static string CurEditorPath; 6 | 7 | public static string GetEditorFilePath(string fileName) 8 | { 9 | return $"{CurEditorPath}{fileName}"; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Util/PathUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32efd74abce8430eadd98e592d251aec 3 | timeCreated: 1633737688 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Views.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dd9b420e9e64f7fbc20aa2366452e81 3 | timeCreated: 1631146362 -------------------------------------------------------------------------------- /Assets/RedDot/Editor/Views/RedDotEnumSettingItem.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using RedDot.Editor.Data; 3 | using RedDot.Editor.Util; 4 | using UnityEditor; 5 | using UnityEngine.UIElements; 6 | using Debug = UnityEngine.Debug; 7 | 8 | namespace RedDot.Editor.Views 9 | { 10 | public class RedDotEnumSettingItem : VisualElement 11 | { 12 | private RedDotEnumDict _enumDict; 13 | private int _id; 14 | 15 | private VisualElement _otherContainer; 16 | private TextField _keyTextField; 17 | private Label _valueLabel; 18 | private TextField _descTextField; 19 | 20 | public RedDotEnumSettingItem(RedDotEnumDict enumDict) 21 | { 22 | _enumDict = enumDict; 23 | // AssetDatabase.asset 24 | var visualTree = 25 | AssetDatabase.LoadAssetAtPath( 26 | PathUtil.GetEditorFilePath("Resources/Styles/SettingItem.uxml")); 27 | VisualElement container = visualTree.Instantiate(); 28 | Add(container); 29 | var deleteBtn = container.Q