public void BindAttrs(XmlLayoutElement element, BoundAttributeCollection collection) { for (var i = 0; i < objectBuildActions.Count; i++) { objectBuildActions[i](element, collection); } }
public XmlLayoutElement CreateElement(Transform parent, BoundAttributeCollection binders, LayoutInflater inflater, Dictionary <string, string> outerAttrs) { var element = parentElement.CreateObject(parent, binders, inflater, outerAttrs); element.RectTransform.anchorMin = new Vector2(0, 1); // Top left element.RectTransform.anchorMax = new Vector2(0, 1); element.RectTransform.pivot = new Vector2(0, 1f); // Center element.gameObject.name = gameObjectName; return(element); }
protected override XmlLayoutElement CreateObject(Transform parent, BoundAttributeCollection binder, LayoutInflater inflater, Dictionary <string, string> outerAttrs) { var element = inflater.Inflate(parent, documentXml, null, outerAttrs); if (element.TryGetComponent <ComponentVariableBinder>(out var addedBinder)) { binder.AddChild(addedBinder); } return(element); }
public void SetBoundAttrs(BoundAttributeCollection attributes) { attributeCollection?.UnbindFromProvider(); attributeCollection = attributes; attributeCollection.ApplyConstants(); if (variableProvider != null) { attributeCollection?.BindToProvider(variableProvider); } }
protected override XmlLayoutElement CreateObject(Transform parent, BoundAttributeCollection binder, LayoutInflater inflater, Dictionary <string, string> outerAttrs) { var gameObject = new GameObject(); if (parent is RectTransform) { gameObject.AddComponent <RectTransform>(); } gameObject.transform.SetParent(parent, false); return(gameObject.AddComponent <XmlLayoutElement>()); }
public XmlLayoutElement CreateXmlInstance(Transform root, string xmlString, Dictionary <string, string> outerAttrs) { Init(); var rootNode = ParseXmlElements(xmlString, outerAttrs); var boundAttrs = new BoundAttributeCollection(); var newPrefab = CreateInstance(null, root, rootNode, boundAttrs); newPrefab.DeactivateHierarchy(); if (!boundAttrs.IsEmpty) { newPrefab.gameObject.AddComponent <ComponentVariableBinder>() .SetBoundAttrs(boundAttrs); } return(newPrefab); }
private XmlLayoutElement CreateInstance(XmlLayoutElement elementRoot, Transform root, ElementNode element, BoundAttributeCollection binders) { var instance = element.factory.CreateElement(root, binders, this, element.ownAttrs); var container = instance.Container; if (!elementRoot) { elementRoot = instance; } for (var i = 0; i < element.childNodes.Count; i++) { var node = element.childNodes[i]; switch (node.type) { case XmlUIUtils.AttrsChildRootName: elementRoot.Container = instance; break; default: var childInstance = CreateInstance(elementRoot, container.ChildParentTransform, node, binders); container.AddChild(childInstance); break; } } element.factory.BindAttrs(instance, binders); foreach (var c in element.components) { c.BindAttrs(instance, binders); } instance.OnCreatedFromXml(); return(instance); }
protected abstract XmlLayoutElement CreateObject(Transform parent, BoundAttributeCollection binder, LayoutInflater inflater, Dictionary <string, string> outerAttrs);
protected override XmlLayoutElement CreateObject(Transform parent, BoundAttributeCollection binder, LayoutInflater inflater, Dictionary <string, string> outerAttrs) { return(Object.Instantiate(prefabElement, parent, false)); }