private void CreateLayout() { if (componentLayout == null) { componentLayout = new ComponentLayout(); } }
protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container) { YAMLMappingNode node = base.ExportYAMLRoot(container); ComponentLayout layout = container.ExportLayout.Component; node.Add(layout.GameObjectName, GameObject.ExportYAML(container)); return(node); }
public override IEnumerable <PPtr <Object> > FetchDependencies(DependencyContext context) { foreach (PPtr <Object> asset in base.FetchDependencies(context)) { yield return(asset); } ComponentLayout layout = context.Layout.Component; yield return(context.FetchDependency(GameObject, layout.GameObjectName)); }
public void FindOutDisplacementFactorDepth() { List <GameObject> testGameObjects = new List <GameObject>(); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); Assert.AreEqual(ComponentLayout.FindOutDisplacementFactorDepth(testGameObjects), 1.1f); }
/// <summary> /// Setup default values for various configuration parameters. /// </summary> public ComponentLayoutConfig() { var layout = new ComponentLayout(); StyleItem = ComponentArrangementStyles.Rows; NoOverlapItem = (layout.Style & ComponentArrangementStyles.ModifierNoOverlap) != 0; FromSketchItem = (layout.Style & ComponentArrangementStyles.ModifierAsIs) != 0; YDimension size = layout.PreferredSize; UseScreenRatioItem = true; AspectRatioItem = size.Width / size.Height; ComponentSpacingItem = layout.ComponentSpacing; GridEnabledItem = layout.GridSpacing > 0; GridSpacingItem = layout.GridSpacing > 0 ? layout.GridSpacing : 20.0d; }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new ComponentLayout(); layout.ComponentArrangement = true; var style = StyleItem; if (NoOverlapItem) { style |= ComponentArrangementStyles.ModifierNoOverlap; } if (FromSketchItem) { style |= ComponentArrangementStyles.ModifierAsIs; } layout.Style = style; double w, h; if (graphControl != null && UseScreenRatioItem) { var canvasSize = graphControl.InnerSize; w = canvasSize.Width; h = canvasSize.Height; } else { w = AspectRatioItem; h = 1 / w; w *= 400; h *= 400; } layout.PreferredSize = new YDimension(w, h); layout.ComponentSpacing = ComponentSpacingItem; if (GridEnabledItem) { layout.GridSpacing = GridSpacingItem; } else { layout.GridSpacing = 0; } return(layout); }
public void CornerTest() { List <GameObject> testGameObjects = new List <GameObject>(); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); testGameObjects.Add(CreateTestGameObject()); ComponentLayout.Corner(testGameObjects); Assert.AreEqual(testGameObjects[0].transform.position, new Vector3(0.0f, 0.0f, 0.0f)); Assert.AreEqual(testGameObjects[1].transform.position, new Vector3(1.1f, 0.0f, 0.0f)); Assert.AreEqual(testGameObjects[2].transform.position, new Vector3(0.0f, 0.0f, -1.1f)); Assert.AreEqual(testGameObjects[3].transform.position, new Vector3(2.2f, 0.0f, 0.0f)); Assert.AreEqual(testGameObjects[4].transform.position, new Vector3(1.1f, 0.0f, -1.1f)); }
/// <summary> /// Creates and configures the <see cref="ComponentLayout"/> and the <see cref="ComponentLayoutData"/> /// such that node types are considered. /// </summary> private Sample CreateComponentSample() { // create a component layout with default settings var layout = new ComponentLayout(); // note that with the default component arrangement style the types of nodes have an influence // already - however, if in a row only components with nodes of the same type should be // allowed, this can be achieved by specifying the style as follows: // layout.Style = ComponentArrangementStyles.MultiRowsTypeSeparated // the node types are specified as delegate on the nodeTypes property of the layout data var layoutData = new ComponentLayoutData { NodeTypes = { Delegate = node => GetNodeType(node) } }; return(new Sample { Name = "Component", File = "component", Layout = layout, LayoutData = layoutData, IsDirected = false }); }
/// <summary> /// Method to traverse the object tree to building the city. /// </summary> /// <param name="treeObject"></param> /// <param name="packageLevel"></param> /// <returns></returns> private GameObject TraverseTree(TreeComponent treeObject, int packageLevel) { if (treeObject is DirComponent) { List <GameObject> childs = new List <GameObject>(); foreach (TreeComponent child in ((DirComponent)treeObject).components) { childs.Add(TraverseTree(child, packageLevel + 1)); } List <GameObject> childDocuments = ComponentFilter.FilterDocuments(childs); List <GameObject> childPackages = ComponentFilter.FilterPackages(childs); if (childPackages.Count > 0 && childDocuments.Count > 0) { //ComponentLayout.Helix(childDocuments); ComponentLayout.Corner(childDocuments); GameObject helper = componentProducer.GenerateHelper(); helperGameObjects.Add(helper); helper.transform.localScale = CalculatePackageSize(childDocuments, helper); SetPackageGameObjectAsParent(helper, childDocuments); childPackages.Add(helper); ComponentLayout.Helix(childPackages); } else { if (childDocuments.Count > 0 && childPackages.Count == 0) { ComponentLayout.Corner(childDocuments); } else { if (childDocuments.Count == 0 && childPackages.Count > 0) { ComponentLayout.Helix(childPackages); } } //ComponentLayout.Helix(childs); } GameObject packageGameObject = componentProducer.GeneratePackage(treeObject); packageGameObject.GetComponent <BaseInformation>().SetChilds(childs); packageGameObject.GetComponent <Renderer>().material.color = packageColorizer.PackageLevelColor(packageLevel); if (childPackages.Count > 0) { packageGameObject.transform.localScale = CalculatePackageSize(childPackages, packageGameObject); SetPackageGameObjectAsParent(packageGameObject, childPackages); } else { packageGameObject.transform.localScale = CalculatePackageSize(childs, packageGameObject); SetPackageGameObjectAsParent(packageGameObject, childs); } return(packageGameObject); } else { GameObject documentGameObject = componentProducer.GenerateDocument(treeObject, selectedMetrics, maxHeight); if (documentGameObject.GetComponentInChildren <Renderer>().bounds.size.y > maxDocumentHeight) { maxDocumentHeight = documentGameObject.GetComponentInChildren <Renderer>().bounds.size.y; } return(documentGameObject); } }