/// <summary> /// Populates the already instantiated container with children specified by component adapters /// </summary> /// <param name="thisComponent"></param> /// <param name="targetContainer"></param> /// <param name="componentAdapters"></param> /// <param name="assignToDescriptor"></param> /// <param name="muteEvents"></param> /// <param name="removeAllChildren"></param> public static void PopulateContainer(Component thisComponent, Group targetContainer, ComponentAdapter[] componentAdapters, bool assignToDescriptor, bool muteEvents, bool removeAllChildren) { #if DEBUG if (DebugMode) { Debug.Log(string.Format(@"PopulateContainer: {0}; Child adapters: {1}", targetContainer, DescribeAdapterList(new List<ComponentAdapter>(componentAdapters)))); } #endif if (null == targetContainer && null == thisComponent) return; var list = thisComponent as IContentChildList; // Group, Panel, Window etc. if (removeAllChildren) { if (null != targetContainer) targetContainer.RemoveAllContentChildren(); else { if (list != null) list.RemoveAllContentChildren(); } } foreach (ComponentAdapter adapter in componentAdapters) { if (null == adapter || !adapter.enabled || !adapter.gameObject.activeInHierarchy) // no descriptors on this node or descriptor disabled. skip continue; // 20130426 Component component = adapter.Produce(!adapter.FactoryMode, assignToDescriptor); if (null != component) { if (null != targetContainer) targetContainer.AddContentChild(component); else { if (list != null) list.AddContentChild(component); } } } }