public static VisualEffectResource GetResource(this VisualEffectObject asset) { string assetPath = AssetDatabase.GetAssetPath(asset); VisualEffectResource resource = VisualEffectResource.GetResourceAtPath(assetPath); if (resource == null && !string.IsNullOrEmpty(assetPath)) { throw new NullReferenceException($"VFX resource does not exist for this asset at path: {assetPath}"); } return(resource); }
public static VisualEffectResource GetOrCreateResource(this VisualEffectObject asset) { string assetPath = AssetDatabase.GetAssetPath(asset); VisualEffectResource resource = VisualEffectResource.GetResourceAtPath(assetPath); if (resource == null && !string.IsNullOrEmpty(assetPath)) { resource = new VisualEffectResource(); resource.SetAssetPath(assetPath); } return(resource); }
void SubgraphDirty(VisualEffectObject subgraph, bool expressionsChanged) { if (m_SubgraphDependencies != null && m_SubgraphDependencies.Contains(subgraph)) { if (expressionsChanged) { RecurseSubgraphRecreateCopy(this); compiledData.Compile(m_CompilationMode, m_ForceShaderValidation); m_ExpressionGraphDirty = false; } m_ExpressionValuesDirty = false; } }
void CreateUniqueSubgraph(string typeName, string extension, Func <string, VisualEffectObject> createFunc) { string graphPath = AssetDatabase.GetAssetPath(m_SourceView.controller.model); string graphName; string graphDirPath; if (string.IsNullOrEmpty(graphPath)) { graphName = m_SourceView.controller.model.name; if (string.IsNullOrEmpty(graphName)) { graphName = "New VFX"; } graphDirPath = "Assets"; } else { graphName = Path.GetFileNameWithoutExtension(graphPath); graphDirPath = Path.GetDirectoryName(graphPath).Replace('\\', '/'); } string fileName = $"{graphName}_{typeName}"; string targetSubgraphPath = string.Format("{0}/{1}{2}", graphDirPath, fileName, extension); int cpt = 1; while (File.Exists(targetSubgraphPath)) { fileName = $"{graphName}_{typeName}_{cpt++}"; targetSubgraphPath = string.Format("{0}/{1}{2}", graphDirPath, fileName, extension); } targetSubgraphPath = EditorUtility.SaveFilePanelInProject("Create Subgraph", fileName, extension.Substring(1), "Select where you want to save your subgraph."); if (Path.GetExtension(targetSubgraphPath) != extension) { targetSubgraphPath += extension; } m_TargetSubgraph = createFunc(targetSubgraphPath); m_TargetController = VFXViewController.GetController(m_TargetSubgraph.GetResource()); m_TargetController.useCount++; m_TargetControllers = new List <VFXNodeController>(); }
void CreateUniqueSubgraph(string typeName, string extension, Func <string, VisualEffectObject> createFunc) { string graphPath = AssetDatabase.GetAssetPath(m_SourceView.controller.model); string graphName; string graphDirPath; if (string.IsNullOrEmpty(graphPath)) { graphName = m_SourceView.controller.model.name; if (string.IsNullOrEmpty(graphName)) { graphName = "New VFX"; } graphDirPath = "Assets"; } else { graphName = Path.GetFileNameWithoutExtension(graphPath); graphDirPath = Path.GetDirectoryName(graphPath).Replace('\\', '/'); } string targetSubgraphPath = string.Format("{0}/{1}{2}{3}", graphDirPath, graphName, typeName, extension); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_{3}_{2}{4}", graphDirPath, graphName, cpt++, typeName, extension); } m_TargetSubgraph = createFunc(targetSubgraphPath); m_TargetController = VFXViewController.GetController(m_TargetSubgraph.GetResource()); m_TargetController.useCount++; m_TargetControllers = new List <VFXNodeController>(); }