Esempio n. 1
0
        public void LoadGraph(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            int assetIndex = path.IndexOf("/Assets/");

            path = path.Substring(assetIndex + 1);

            var graph = AssetDatabase.LoadAssetAtPath <OSM_Graph>(path);

            _window.SetGraph(graph);
        }
        private static bool OpenGraphAsset(int instanceID, int line)
        {
            Debug.Log(instanceID);
            var graphSelected = EditorUtility.InstanceIDToObject(instanceID) as OSM_Graph;

            if (graphSelected != null)
            {
                OSM_EditorWindow windowToUse = null;

                // Try to find an editor window without a graph...
                var windows = Resources.FindObjectsOfTypeAll <OSM_EditorWindow>();
                foreach (var w in windows)
                {
                    // The canvas is already opened
                    if (w.Graph == graphSelected)
                    {
                        return(false);
                    }

                    // Found a window with no active canvas.
                    if (w.Graph == null)
                    {
                        windowToUse = w;
                        break;
                    }
                }

                // No windows available...just make a new one.
                if (!windowToUse)
                {
                    windowToUse = EditorWindow.CreateInstance <OSM_EditorWindow>();
                    windowToUse.titleContent = new GUIContent("Node Editor");
                    windowToUse.Show();
                }

                windowToUse.SetGraph(graphSelected);
                // windowToUse._saveManager.InitState();
                windowToUse.Repaint();

                return(true);
            }

            return(false);
        }