Beispiel #1
0
 string GetVFXModelDesc(VFXModel model)
 {
     if (model == null)
     {
         return("null(VFXModel)");
     }
     return(string.Format("'{0}'({1})", model.name, model.GetType().Name));
 }
        NodeID CopyNode(ref Node node, VFXModel model, uint index)
        {
            // Copy node infos
            node.position = model.position;
            node.type     = model.GetType();
            node.flags    = 0;
            if (model.collapsed)
            {
                node.flags = Node.Flags.Collapsed;
            }
            if (model.superCollapsed)
            {
                node.flags = Node.Flags.SuperCollapsed;
            }

            uint id = 0;

            if (model is VFXOperator)
            {
                id = OperatorFlag;
            }
            else if (model is VFXContext)
            {
                id = ContextFlag;
            }

            id |= (uint)index;

            //Copy settings value
            CopyModelSettings(ref node.settings, model);

            var inputSlots = (model as IVFXSlotContainer).inputSlots;

            node.inputSlots = new Property[inputSlots.Count];
            for (int i = 0; i < inputSlots.Count; i++)
            {
                node.inputSlots[i].name = inputSlots[i].name;
                if (inputSlots[i].spaceable)
                {
                    node.inputSlots[i].space = inputSlots[i].space;
                }
                node.inputSlots[i].value = new VFXSerializableObject(inputSlots[i].property.type, inputSlots[i].value);
            }

            node.expandedInputs  = AllSlots(inputSlots).Where(t => !t.collapsed).Select(t => t.path).ToArray();
            node.expandedOutputs = AllSlots((model as IVFXSlotContainer).outputSlots).Where(t => !t.collapsed).Select(t => t.path).ToArray();

            return(id);
        }
Beispiel #3
0
        void CopyModelSettings(ref Property[] properties, VFXModel model)
        {
            // Copy all fields that are either VFXSettings or serialized by unity
            Type type = model.GetType();

            var fields = GetFields(type);

            properties = new Property[fields.Count()];

            for (int i = 0; i < properties.Length; ++i)
            {
                properties[i].name  = fields[i].Name;
                properties[i].value = new VFXSerializableObject(fields[i].FieldType, fields[i].GetValue(model));
            }
        }
Beispiel #4
0
        void PasteNode(VFXModel model, Vector2 center, Rect bounds, ref Node node)
        {
            var offset = node.position - bounds.min;

            model.position = center + offset;

            PasteModelSettings(model, node.settings, model.GetType());

            model.Invalidate(VFXModel.InvalidationCause.kSettingChanged);

            var slotContainer = model as IVFXSlotContainer;
            var inputSlots    = slotContainer.inputSlots;

            for (int i = 0; i < node.inputSlots.Length && i < inputSlots.Count; ++i)
            {
                if (inputSlots[i].name == node.inputSlots[i].name)
                {
                    inputSlots[i].value = node.inputSlots[i].value.Get();
                    if (inputSlots[i].spaceable)
                    {
                        inputSlots[i].space = node.inputSlots[i].space;
                    }
                }
            }

            if ((node.flags & Node.Flags.Collapsed) == Node.Flags.Collapsed)
            {
                model.collapsed = true;
            }

            if ((node.flags & Node.Flags.SuperCollapsed) == Node.Flags.SuperCollapsed)
            {
                model.superCollapsed = true;
            }

            foreach (var slot in AllSlots(slotContainer.inputSlots))
            {
                slot.collapsed = !node.expandedInputs.Contains(slot.path);
            }
            foreach (var slot in AllSlots(slotContainer.outputSlots))
            {
                slot.collapsed = !node.expandedOutputs.Contains(slot.path);
            }
        }
Beispiel #5
0
        void PasteNode(VFXModel model, ref Node node)
        {
            model.position = node.position + pasteOffset;

            PasteModelSettings(model, node.settings, model.GetType());

            model.Invalidate(VFXModel.InvalidationCause.kSettingChanged);

            var slotContainer = model as IVFXSlotContainer;
            var inputSlots    = slotContainer.inputSlots;

            for (int i = 0; i < node.inputSlots.Length; ++i)
            {
                if (inputSlots[i].name == node.inputSlots[i].name)
                {
                    inputSlots[i].value = node.inputSlots[i].value.Get();
                }
            }

            if ((node.flags & Node.Flags.Collapsed) == Node.Flags.Collapsed)
            {
                model.collapsed = true;
            }

            if ((node.flags & Node.Flags.SuperCollapsed) == Node.Flags.SuperCollapsed)
            {
                model.superCollapsed = true;
            }

            foreach (var slot in AllSlots(slotContainer.inputSlots))
            {
                slot.collapsed = !node.expandedInputs.Contains(slot.path);
            }
            foreach (var slot in AllSlots(slotContainer.outputSlots))
            {
                slot.collapsed = !node.expandedOutputs.Contains(slot.path);
            }
        }