示例#1
0
        private void PasteGroupNodes(ref SerializableGraph serializableGraph, Vector2 center, VFXUI ui)
        {
            if (serializableGraph.groupNodes != null && serializableGraph.groupNodes.Length > 0)
            {
                if (ui.groupInfos == null)
                {
                    ui.groupInfos = new VFXUI.GroupInfo[0];
                }
                firstCopiedGroup = ui.groupInfos.Length;

                List <VFXUI.GroupInfo> newGroupInfos = new List <VFXUI.GroupInfo>();
                foreach (var groupInfos in serializableGraph.groupNodes)
                {
                    var newGroupInfo = new VFXUI.GroupInfo();
                    var offset       = groupInfos.infos.position.min - serializableGraph.bounds.min;
                    newGroupInfo.position = new Rect(center + offset, groupInfos.infos.position.size);
                    newGroupInfo.title    = groupInfos.infos.title;
                    newGroupInfos.Add(newGroupInfo);
                    newGroupInfo.contents = groupInfos.contents.Take(groupInfos.contents.Length - groupInfos.stickNodeCount).Select(t => { VFXNodeController node = null; newControllers.TryGetValue(t, out node); return(node); }).Where(t => t != null).Select(node => new VFXNodeID(node.model, node.id))
                                            .Concat(groupInfos.contents.Skip(groupInfos.contents.Length - groupInfos.stickNodeCount).Select(t => new VFXNodeID((int)t + firstCopiedStickyNote)))
                                            .ToArray();
                }
                ui.groupInfos = ui.groupInfos.Concat(newGroupInfos).ToArray();
            }
        }
示例#2
0
        static VFXUI CopyGroupNodesAndStickyNotes(IEnumerable <Controller> elements, VFXContext[] copiedContexts, VFXModel[] copiedSlotContainers)
        {
            VFXGroupNodeController[]  groupNodes  = elements.OfType <VFXGroupNodeController>().ToArray();
            VFXStickyNoteController[] stickyNotes = elements.OfType <VFXStickyNoteController>().ToArray();

            VFXUI copiedGroupUI = null;

            if (groupNodes.Length > 0 || stickyNotes.Length > 0)
            {
                copiedGroupUI = ScriptableObject.CreateInstance <VFXUI>();

                var stickyNodeIndexToCopiedIndex = new Dictionary <int, int>();

                if (stickyNotes.Length > 0)
                {
                    copiedGroupUI.stickyNoteInfos = new VFXUI.StickyNoteInfo[stickyNotes.Length];

                    for (int i = 0; i < stickyNotes.Length; ++i)
                    {
                        VFXStickyNoteController stickyNote = stickyNotes[i];
                        stickyNodeIndexToCopiedIndex[stickyNote.index] = i;
                        VFXUI.StickyNoteInfo info = stickyNote.model.stickyNoteInfos[stickyNote.index];
                        copiedGroupUI.stickyNoteInfos[i] = new VFXUI.StickyNoteInfo(info);
                    }
                }

                if (groupNodes.Length > 0)
                {
                    copiedGroupUI.groupInfos = new VFXUI.GroupInfo[groupNodes.Length];

                    for (int i = 0; i < groupNodes.Length; ++i)
                    {
                        VFXGroupNodeController groupNode = groupNodes[i];
                        VFXUI.GroupInfo        info      = groupNode.model.groupInfos[groupNode.index];
                        copiedGroupUI.groupInfos[i] = new VFXUI.GroupInfo(info);

                        // only keep nodes and sticky notes that are copied because a element can not be in two groups at the same time.
                        if (info.contents != null)
                        {
                            var groupInfo = copiedGroupUI.groupInfos[i];
                            groupInfo.contents = info.contents.Where(t => copiedContexts.Contains(t.model) || copiedSlotContainers.Contains(t.model) || (t.isStickyNote && stickyNodeIndexToCopiedIndex.ContainsKey(t.id))).ToArray();

                            for (int j = 0; j < groupInfo.contents.Length; ++j)
                            {
                                if (groupInfo.contents[j].isStickyNote)
                                {
                                    groupInfo.contents[j].id = stickyNodeIndexToCopiedIndex[groupInfo.contents[j].id];
                                }
                            }
                        }
                    }
                }
            }
            return(copiedGroupUI);
        }
示例#3
0
        void CopyGroupNodesAndStickyNotes(ref SerializableGraph serializableGraph, IEnumerable <Controller> elements)
        {
            VFXGroupNodeController[]  groupNodes  = elements.OfType <VFXGroupNodeController>().ToArray();
            VFXStickyNoteController[] stickyNotes = elements.OfType <VFXStickyNoteController>().ToArray();

            if (groupNodes.Length > 0 || stickyNotes.Length > 0)
            {
                var stickyNodeIndexToCopiedIndex = new Dictionary <int, int>();

                if (stickyNotes.Length > 0)
                {
                    serializableGraph.stickyNotes = new VFXUI.StickyNoteInfo[stickyNotes.Length];

                    for (int i = 0; i < stickyNotes.Length; ++i)
                    {
                        VFXStickyNoteController stickyNote = stickyNotes[i];
                        stickyNodeIndexToCopiedIndex[stickyNote.index] = i;
                        VFXUI.StickyNoteInfo info = stickyNote.model.stickyNoteInfos[stickyNote.index];
                        serializableGraph.stickyNotes[i] = new VFXUI.StickyNoteInfo(info);
                    }
                }

                if (groupNodes.Length > 0)
                {
                    serializableGraph.groupNodes = new GroupNode[groupNodes.Length];
                    for (int i = 0; i < groupNodes.Length; ++i)
                    {
                        VFXGroupNodeController groupNode = groupNodes[i];
                        VFXUI.GroupInfo        info      = groupNode.model.groupInfos[groupNode.index];

                        serializableGraph.groupNodes[i] = new GroupNode {
                            infos = new VFXUI.UIInfo(info)
                        };

                        // only keep nodes and sticky notes that are copied because a element can not be in two groups at the same time.
                        if (info.contents != null)
                        {
                            var nodeIndices      = groupNode.nodes.OfType <VFXNodeController>().Where(t => contexts.Contains(t) || operators.Contains(t) || parameters.Contains(t)).Select(t => modelIndices[t]);
                            var stickNoteIndices = info.contents.Where(t => t.isStickyNote && stickyNodeIndexToCopiedIndex.ContainsKey(t.id)).Select(t => (uint)stickyNodeIndexToCopiedIndex[t.id]);

                            serializableGraph.groupNodes[i].contents       = nodeIndices.Concat(stickNoteIndices).ToArray();
                            serializableGraph.groupNodes[i].stickNodeCount = stickNoteIndices.Count();
                        }
                    }
                }
            }
        }