public void ConvertToSubgraphOperator(VFXView sourceView, IEnumerable <Controller> controllers, Rect rect, string path) { this.m_Rect = rect; Init(sourceView, controllers); if (path == null) { if (!CreateUniqueSubgraph("SubgraphOperator", VisualEffectSubgraphOperator.Extension, VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphOperator>)) { return; } } else { m_TargetSubgraph = VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphOperator>(path); m_TargetController = VFXViewController.GetController(m_TargetSubgraph.GetResource()); m_TargetController.useCount++; m_TargetControllers = new List <VFXNodeController>(); } CopyPasteNodes(); m_SourceNode = ScriptableObject.CreateInstance <VFXSubgraphOperator>(); PostSetupNode(); m_SourceControllersWithBlocks = m_SourceControllers.Concat(m_SourceControllers.OfType <VFXContextController>().SelectMany(t => t.blockControllers)); TransferEdges(); TransfertOperatorOutputEdges(); Uninit(); //The PrepareSubgraphs was initially in compilation //This change has been canceled to prevent creation of model in the wrong place //Be sure the newly created operator has expected slot var subGraphOperator = m_SourceNode as VFXSubgraphOperator; subGraphOperator.RecreateCopy(); subGraphOperator.ResyncSlots(true); }
static VisualEffectObject CreateUniquePath(VFXView sourceView, Type type) { string graphPath = AssetDatabase.GetAssetPath(sourceView.controller.model.asset); string graphName = Path.GetFileNameWithoutExtension(graphPath); string graphDirPath = Path.GetDirectoryName(graphPath); switch (type) { case Type.Operator: { string targetSubgraphPath = string.Format("{0}/{1}_SubgraphOperator.vfxoperator", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_SubgraphOperator_{2}.vfxoperator", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphOperator>(targetSubgraphPath)); } case Type.Context: { string targetSubgraphPath = string.Format("{0}/{1}_Subgraph.vfx", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_Subgraph_{2}.vfx", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNewAsset(targetSubgraphPath)); } case Type.Block: { string targetSubgraphPath = string.Format("{0}/{1}_SubgraphBlock.vfxblock", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_SubgraphBlock_{2}.vfxblock", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphBlock>(targetSubgraphPath)); } } return(null); }