public void CopyPasteBlock() { var initContextDesc = VFXLibrary.GetContexts().Where(t => t.name == "Initialize").First(); var newContext = m_ViewController.AddVFXContext(new Vector2(100, 100), initContextDesc); m_ViewController.ApplyChanges(); Assert.AreEqual(m_ViewController.allChildren.Where(t => t is VFXContextController).Count(), 1); var contextController = m_ViewController.allChildren.OfType <VFXContextController>().First(); Assert.AreEqual(contextController.model, newContext); var flipBookBlockDesc = VFXLibrary.GetBlocks().First(t => t.name == "Set Tex Index "); contextController.AddBlock(0, flipBookBlockDesc.CreateInstance()); var newBlock = contextController.model.children.First(); m_ViewController.ApplyChanges(); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; view.controller = m_ViewController; view.ClearSelection(); foreach (var element in view.Query().OfType <VFXBlockUI>().ToList().OfType <ISelectable>()) { view.AddToSelection(element); } VFXBlock flipBookBlock = m_ViewController.contexts.First().blockControllers.First().model; VFXSlot minValueSlot = flipBookBlock.GetInputSlot(0); float originalMinValue = 123.456f; minValueSlot.value = originalMinValue; view.CopySelectionCallback(); minValueSlot.value = 789f; view.PasteCallback(); view.controller.ApplyChanges(); var elements = view.Query().OfType <VFXBlockUI>().ToList(); var copyBlock = elements.Select(t => t.controller).First(t => t.model != newBlock).model; var copyMinSlot = copyBlock.GetInputSlot(0); Assert.AreEqual((float)copyMinSlot.value, originalMinValue); }
public void CopyPasteContextWithBlock() { var initContextDesc = VFXLibrary.GetContexts().Where(t => t.name == "Initialize").First(); var newContext = m_ViewController.AddVFXContext(new Vector2(100, 100), initContextDesc); m_ViewController.ApplyChanges(); Assert.AreEqual(m_ViewController.allChildren.Where(t => t is VFXContextController).Count(), 1); var contextController = m_ViewController.allChildren.OfType <VFXContextController>().First(); Assert.AreEqual(contextController.model, newContext); var flipBookBlockDesc = VFXLibrary.GetBlocks().First(t => t.name == "Set Tex Index "); contextController.AddBlock(0, flipBookBlockDesc.CreateInstance()); m_ViewController.ApplyChanges(); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; view.controller = m_ViewController; view.ClearSelection(); foreach (var element in view.Query().OfType <GraphElement>().ToList().OfType <ISelectable>()) { view.AddToSelection(element); } VFXSlot boundsSlot = newContext.GetInputSlot(0); AABox originalBounds = new AABox() { center = Vector3.one, size = Vector3.one * 10 }; boundsSlot.value = originalBounds; VFXBlock flipBookBlock = m_ViewController.contexts.First().blockControllers.First().model; VFXSlot minValueSlot = flipBookBlock.GetInputSlot(0); float originalMinValue = 123.456f; minValueSlot.value = originalMinValue; view.CopySelectionCallback(); boundsSlot.value = new AABox() { center = Vector3.zero, size = Vector3.zero }; minValueSlot.value = 789f; view.PasteCallback(); var elements = view.Query().OfType <GraphElement>().ToList(); var contexts = elements.OfType <VFXContextUI>().ToArray(); var copyContext = elements.OfType <VFXContextUI>().Select(t => t.controller).First(t => t.model != newContext).model; var copyBoundsSlot = copyContext.GetInputSlot(0); var copyMinSlot = copyContext[0].GetInputSlot(0); Assert.AreEqual((AABox)copyBoundsSlot.value, originalBounds); Assert.AreEqual((float)copyMinSlot.value, originalMinValue); Assert.AreNotEqual(copyContext.position, newContext.position); view.PasteCallback(); elements = view.Query().OfType <GraphElement>().ToList(); contexts = elements.OfType <VFXContextUI>().ToArray(); var copy2Context = contexts.First(t => t.controller.model != newContext && t.controller.model != copyContext).controller.model; Assert.AreNotEqual(copy2Context.position, newContext.position); Assert.AreNotEqual(copy2Context.position, copyContext.position); }