public void GetAssetPathOnSubAssetDoesNotLoadMainAsset() { // Create asset file with two graph assets in it. GraphAssetCreationHelpers <TestGraphAssetModel> .CreateGraphAsset(typeof(ClassStencil), "test", k_GraphPath); var subAsset = GraphAssetCreationHelpers <OtherTestGraphAssetModel> .CreateGraphAsset(typeof(ClassStencil), "otherTest", null); AssetDatabase.AddObjectToAsset(subAsset as Object, k_GraphPath); AssetDatabase.SaveAssets(); AssetDatabase.TryGetGUIDAndLocalFileIdentifier(subAsset as Object, out var guid, out long localId); Resources.UnloadAsset(m_CommandDispatcher.State.WindowState.AssetModel as Object); // Load the second asset. m_CommandDispatcher.Dispatch(new LoadGraphAssetCommand(k_GraphPath, localId, null)); // Check that we loaded the second asset. Assert.AreEqual(guid, m_CommandDispatcher.State.WindowState.CurrentGraph.GraphModelAssetGUID); Assert.AreEqual(localId, m_CommandDispatcher.State.WindowState.CurrentGraph.AssetLocalId); // Call GetGraphAssetModelPath(), which was reloading the wrong asset (GTF-350). m_CommandDispatcher.State.WindowState.CurrentGraph.GetGraphAssetModelPath(); Assert.AreEqual(subAsset, m_CommandDispatcher.State.WindowState.CurrentGraph.m_GraphAssetModel); // Call GetGraphAssetModel(), which was reloading the wrong asset (GTF-350). m_CommandDispatcher.State.WindowState.CurrentGraph.GetGraphAssetModel(); Assert.AreEqual(subAsset, m_CommandDispatcher.State.WindowState.CurrentGraph.m_GraphAssetModel); AssetDatabase.DeleteAsset(k_GraphPath); }
public override void SetUp() { base.SetUp(); m_Asset1 = GraphAssetCreationHelpers <TestGraphAssetModel> .CreateGraphAsset(CreatedGraphType, "Test1", "Assets/test1.asset"); Window.CommandDispatcher.State.LoadGraphAsset(m_Asset1, null); }
public void LoadGraphCommandLoadsCorrectGraph() { GraphAssetCreationHelpers <TestGraphAssetModel> .CreateGraphAsset(typeof(ClassStencil), "test", k_GraphPath); AssumeIntegrity(); AssetDatabase.SaveAssets(); Resources.UnloadAsset(m_CommandDispatcher.State.WindowState.AssetModel as Object); m_CommandDispatcher.Dispatch(new LoadGraphAssetCommand(k_GraphPath, 0, null)); Assert.AreEqual(k_GraphPath, AssetDatabase.GetAssetPath((Object)GraphModel.AssetModel)); AssertIntegrity(); AssetDatabase.DeleteAsset(k_GraphPath); }
public void CreateTestGraphCanBeReloaded() { var graphTemplate = new TestGraph(); GraphAssetCreationHelpers <TestGraphAssetModel> .CreateGraphAsset(typeof(ClassStencil), graphTemplate.DefaultAssetName, k_GraphPath, graphTemplate); GraphModel graph = AssetDatabase.LoadAssetAtPath <GraphAssetModel>(k_GraphPath)?.GraphModel as GraphModel; Resources.UnloadAsset((Object)graph?.AssetModel); m_CommandDispatcher.Dispatch(new LoadGraphAssetCommand(k_GraphPath, 0, null)); AssertIntegrity(); AssetDatabase.DeleteAsset(k_GraphPath); }
public override void SetUp() { base.SetUp(); GraphViewSettings.UserSettings.EnableSnapToBorders = false; GraphViewSettings.UserSettings.EnableSnapToPort = false; m_AssetModel = GraphAssetCreationHelpers <TestAssetModel> .CreateGraphAsset(typeof(TestStencil), "TestFile", k_FilePath); CommandDispatcher.Dispatch(new LoadGraphAssetCommand(m_AssetModel)); m_NodeModel = CreateNode("Movable element", k_NodePos, 0, 1); // Add the minimap. var miniMap = new MiniMap(); miniMap.style.left = k_MinimapRect.x; miniMap.style.top = k_MinimapRect.y; miniMap.style.width = k_MinimapRect.width; miniMap.style.height = k_MinimapRect.height; graphView.Add(miniMap); }