public void ConvertToSubgraph() { //Create a new vfx based on the usual template var templateString = System.IO.File.ReadAllText(VisualEffectGraphPackageInfo.assetPackagePath + "/Editor/Templates/SimpleParticleSystem.vfx"); System.IO.File.WriteAllText(testSubgraphAssetName, templateString); VFXViewWindow window = VFXViewWindow.GetWindow <VFXViewWindow>(); window.LoadAsset(AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(testAssetName), null); VFXConvertSubgraph.ConvertToSubgraphContext(window.graphView, window.graphView.Query <VFXContextUI>().ToList().Where(t => !(t.controller.model is VFXBasicSpawner)).Select(t => t.controller).Cast <Controller>(), Rect.zero, testSubgraphSubAssetName); window.graphView.controller = null; }
protected override void AssetField(VisualEffectResource resource) { using (new GUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(m_VisualEffectAsset, Contents.assetPath); GUI.enabled = !m_VisualEffectAsset.hasMultipleDifferentValues && m_VisualEffectAsset.objectReferenceValue != null && resource != null; // Enabled state will be kept for all content until the end of the inspectorGUI. if (GUILayout.Button(Contents.openEditor, EditorStyles.miniButton, Styles.MiniButtonWidth)) { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); var asset = m_VisualEffectAsset.objectReferenceValue as VisualEffectAsset; window.LoadAsset(asset, targets.Length > 1 ? null : target as VisualEffect); } GUI.enabled = true; } }
protected override void AssetField() { var component = (VisualEffect)target; using (new GUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(m_VisualEffectAsset, Contents.assetPath); GUI.enabled = component.visualEffectAsset != null; // Enabled state will be kept for all content until the end of the inspectorGUI. if (GUILayout.Button(Contents.openEditor, EditorStyles.miniButton, Styles.MiniButtonWidth)) { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.LoadAsset(component.visualEffectAsset, component); } } }
public IEnumerator VFXViewWindow_Open_And_Render([ValueSource("allVisualEffectAsset")] string vfxAssetPath) { VFXGraph graph; string fullPath; LoadVFXGraph(vfxAssetPath, out fullPath, out graph); VFXViewWindow window = null; using (Measure.Scope("VFXViewWindow.Show")) { window = EditorWindow.GetWindow <VFXViewWindow>(); window.Show(); window.position = new UnityEngine.Rect(0, 0, 1600, 900); window.autoCompile = false; window.Repaint(); } yield return(null); using (Measure.Scope("VFXViewWindow.LoadAsset")) { var asset = k_fnGetAsset.Invoke(graph.visualEffectResource, new object[] { }) as VisualEffectAsset; window.LoadAsset(asset, null); window.graphView.FrameAll(); } for (int i = 0; i < 8; ++i) //Render n frames { var position = window.graphView.viewTransform.position; position.x += i % 2 == 1 ? 3.0f : -3.0f; window.graphView.viewTransform.position = position; window.Repaint(); yield return(Measure.Frames().SampleGroup("VFXViewWindow.Render").MeasurementCount(4).Run()); } using (Measure.Scope("VFXViewWindow.Close")) { window.Close(); yield return(null); //Ensure window is closed for next test } }
public void Subgraph_Event_Link_To_Spawn() { VFXViewWindow window = VFXViewWindow.GetWindow <VFXViewWindow>(); window.LoadAsset(AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(testAssetName), null); //Create Spawner in subgraph { var spawner = ScriptableObject.CreateInstance <VFXBasicSpawner>(); m_ViewController.graph.AddChild(spawner); m_ViewController.LightApplyChanges(); var controller = window.graphView.Query <VFXContextUI>().ToList().Select(t => t.controller).Cast <Controller>(); Assert.AreEqual(1, controller.Count()); VFXConvertSubgraph.ConvertToSubgraphContext(window.graphView, controller, Rect.zero, testSubgraphSubAssetName); } var subGraphController = m_ViewController.allChildren.OfType <VFXContextController>().FirstOrDefault(o => o.model is VFXSubgraphContext); Assert.IsNotNull(subGraphController); //Create Event Context & Link the two input flow var subGraphContext = subGraphController.model; var eventContext = ScriptableObject.CreateInstance <VFXBasicEvent>(); Assert.IsTrue(VFXContext.CanLink(eventContext, subGraphContext, 0, 0)); Assert.IsTrue(VFXContext.CanLink(eventContext, subGraphContext, 0, 1)); eventContext.LinkTo(subGraphContext, 0, 0); eventContext.LinkTo(subGraphContext, 0, 1); var flow = eventContext.outputFlowSlot.First().link; Assert.AreEqual(2, flow.Count()); Assert.IsTrue(flow.All(o => o.context == subGraphContext)); Assert.IsTrue(flow.Any(o => o.slotIndex == 0)); Assert.IsTrue(flow.Any(o => o.slotIndex == 1)); window.graphView.controller = null; }
protected override void AssetField(VisualEffectResource resource) { using (new GUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(m_VisualEffectAsset, Contents.assetPath); bool saveEnabled = GUI.enabled; if (m_VisualEffectAsset.objectReferenceValue == null && !m_VisualEffectAsset.hasMultipleDifferentValues) { GUI.enabled = saveEnabled; if (GUILayout.Button(Contents.createAsset, EditorStyles.miniButton, Styles.MiniButtonWidth)) { string filePath = EditorUtility.SaveFilePanelInProject("", "New Graph", "vfx", "Create new VisualEffect Graph"); if (!string.IsNullOrEmpty(filePath)) { VisualEffectAssetEditorUtility.CreateTemplateAsset(filePath); var asset = AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(filePath); m_VisualEffectAsset.objectReferenceValue = asset; serializedObject.ApplyModifiedProperties(); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.LoadAsset(asset, targets.Length > 1 ? null : target as VisualEffect); } } } else { GUI.enabled = saveEnabled && !m_VisualEffectAsset.hasMultipleDifferentValues && m_VisualEffectAsset.objectReferenceValue != null && resource != null; // Enabled state will be kept for all content until the end of the inspectorGUI. if (GUILayout.Button(Contents.openEditor, EditorStyles.miniButton, Styles.MiniButtonWidth)) { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); var asset = m_VisualEffectAsset.objectReferenceValue as VisualEffectAsset; window.LoadAsset(asset, targets.Length > 1 ? null : target as VisualEffect); } } GUI.enabled = saveEnabled; } }