Пример #1
0
 public void OnBeforeSerialize()
 {
     if (Graph != null)
     {
         _serializedGraph = GraphSerializer.Serialize(Graph);
     }
 }
        private string SerializeGraphElements(IEnumerable <GraphElement> elements)
        {
            var nodes       = elements.OfType <BaseNodeView>().ToDictionary(node => node.Node.Id, node => node);
            var connections = elements.OfType <BaseConnectionView>().Where(view => nodes.ContainsKey(view.Connection.FromNodeId) &&
                                                                           nodes.ContainsKey(view.Connection.ToNodeId));

            return(GraphSerializer.Serialize(CreateGraphToSerialize(nodes.Values, connections)));
        }
Пример #3
0
            public override void Action(int instanceId, string pathName, string resourceFile)
            {
                File.WriteAllText(pathName, GraphSerializer.Serialize(Graph));
                AssetDatabase.Refresh();

                UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <GraphAsset>(pathName);
                Selection.activeObject = obj;
            }
        /// <summary>
        /// Saves current <see cref="GraphAsset"/>
        /// </summary>
        public void SaveGraph()
        {
            if (_graphAssetGuid != null && _graph != null)
            {
                var path = AssetDatabase.GUIDToAssetPath(_graphAssetGuid);

                if (!string.IsNullOrEmpty(path))
                {
                    File.WriteAllText(path, GraphSerializer.Serialize(_graph));
                }
            }
        }