示例#1
0
        public AssetCompositeHierarchyData <UIElementDesign, UIElement> CreateElementInstance(UIAssetBase targetContainer, [NotNull] string targetLocation, Guid elementId, out Guid instanceId)
        {
            // TODO: make a common base method in AssetCompositeHierarchy - the beginning of the method is similar to CreatePrefabInstance
            var idRemapping = new Dictionary <Guid, Guid>();
            var instance    = (UILibraryAsset)CreateDerivedAsset(targetLocation, out idRemapping);

            var rootElementId = idRemapping[elementId];

            if (instance.Hierarchy.RootParts.All(x => x.Id != rootElementId))
            {
                throw new ArgumentException(@"The given id cannot be found in the root parts of this library.", nameof(elementId));
            }

            instanceId = instance.Hierarchy.Parts.Values.FirstOrDefault()?.Base?.InstanceId ?? Guid.NewGuid();

            var result = new AssetCompositeHierarchyData <UIElementDesign, UIElement>();

            result.RootParts.Add(instance.Hierarchy.Parts[rootElementId].UIElement);
            result.Parts.Add(instance.Hierarchy.Parts[rootElementId]);
            foreach (var element in this.EnumerateChildPartDesigns(instance.Hierarchy.Parts[rootElementId], instance.Hierarchy, true))
            {
                result.Parts.Add(element);
            }
            return(result);
        }
示例#2
0
        public AssetCompositeHierarchyData <UIElementDesign, UIElement> CreateElementInstance(UIAssetBase targetContainer, [NotNull] string targetLocation, Guid elementId)
        {
            Guid unused;

            return(CreateElementInstance(targetContainer, targetLocation, elementId, out unused));
        }