private void EditTestAsset(int assetIndex) { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.Close(); window = EditorWindow.GetWindow <VFXViewWindow>(); m_ViewController = VFXViewController.GetController(m_GuiTestAssets[assetIndex].GetResource(), true); window.graphView.controller = m_ViewController; }
void DestroyTestAsset(string name) { var filePath = string.Format(testAssetName, name); AssetDatabase.DeleteAsset(filePath); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.Close(); }
public void DestroyTestAssets() { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.Close(); for (int i = 0; i < testAssetCount; ++i) { DestroyTestAsset("GUITest" + i); } }
public void DestroyTestAssets() { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.Close(); for (int i = 0; i < testAssetCount; ++i) { DestroyTestAsset("GUITest" + i); } VFXTestCommon.DeleteAllTemporaryGraph(); }
public void CreateTestAsset(string name) { var filePath = string.Format(testAssetName, name); var directoryPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } m_Asset = VisualEffectResource.CreateNewAsset(filePath); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); window.Close(); window = EditorWindow.GetWindow <VFXViewWindow>(); m_ViewController = VFXViewController.GetController(m_Asset.GetResource(), true); window.graphView.controller = m_ViewController; }
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 IEnumerator TestBoundsHelperResults([ValueSource(nameof(availableSpaces))] object systemSpace) { string kSourceAsset = "Assets/AllTests/Editor/Tests/VFXBoundsHelperTest.vfx"; var graph = VFXTestCommon.CopyTemporaryGraph(kSourceAsset); VFXCoordinateSpace space = (VFXCoordinateSpace)systemSpace; graph.children.OfType <VFXBasicInitialize>().First().space = space; var gameObj = new GameObject("GameObjectToCheck"); gameObj.transform.position = m_Translation; gameObj.transform.rotation = m_Rotation; gameObj.transform.localScale = m_Scale; var vfxComponent = gameObj.AddComponent <VisualEffect>(); vfxComponent.visualEffectAsset = graph.visualEffectResource.asset; VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; VFXViewController controller = VFXViewController.GetController(vfxComponent.visualEffectAsset.GetResource(), true); view.controller = controller; view.attachedComponent = vfxComponent; VFXBoundsRecorder boundsRecorder = new VFXBoundsRecorder(vfxComponent, view); boundsRecorder.ToggleRecording(); vfxComponent.Simulate(1.0f / 60.0f); const int maxFrameTimeout = 100; for (int i = 0; i < maxFrameTimeout; i++) { boundsRecorder.UpdateBounds(); if (boundsRecorder.bounds.Count > 0) { break; } yield return(null); //skip a frame. } boundsRecorder.ToggleRecording(); Bounds bounds = boundsRecorder.bounds.FirstOrDefault().Value; boundsRecorder.CleanUp(); Vector3 expectedCenter = Vector3.zero; Vector3 expectedExtent = new Vector3(2.0f, 2.0f, 2.0f); expectedExtent += 0.5f * m_ParticleSize * (space == VFXCoordinateSpace.Local ? Mathf.Sqrt(3.0f) : Mathf.Sqrt(1.0f / Mathf.Pow(m_Scale.x, 2) + 1.0f / Mathf.Pow(m_Scale.y, 2) + 1.0f / Mathf.Pow(m_Scale.z, 2))); Assert.AreEqual(expectedCenter.x, bounds.center.x, .002); Assert.AreEqual(expectedCenter.y, bounds.center.y, .002); Assert.AreEqual(expectedCenter.z, bounds.center.z, .002); Assert.AreEqual(expectedExtent.x, bounds.extents.x, .005); Assert.AreEqual(expectedExtent.y, bounds.extents.y, .005); Assert.AreEqual(expectedExtent.z, bounds.extents.z, .005); view.attachedComponent = null; window.Close(); yield return(null); }