示例#1
0
        void BuildValue(VFXSlot slot)
        {
            foreach (var field in slot.property.type.GetFields())
            {
                VFXSlot subSlot = slot.children.FirstOrDefault <VFXSlot>(t => t.name == field.Name);

                if (subSlot != null)
                {
                    object result = null;
                    if (subSlot.HasLink(true) && m_Controller.viewController.CanGetEvaluatedContent(subSlot) && (result = m_Controller.viewController.GetEvaluatedContent(subSlot)) != null)
                    {
                        m_ValueBuilder.Add(o => o.Add(m_Controller.viewController.GetEvaluatedContent(subSlot)));
                    }
                    else if (subSlot.HasLink(false) && VFXTypeUtility.GetComponentCount(subSlot) != 0) // replace by is VFXType
                    {
                        m_Indeterminate = true;
                        return;
                    }
                    else
                    {
                        m_ValueBuilder.Add(o => o.Add(subSlot.value));
                        BuildValue(subSlot);
                        if (m_Indeterminate)
                        {
                            return;
                        }
                    }
                    m_ValueBuilder.Add(o => field.SetValue(o[o.Count - 2], o[o.Count - 1]));
                    m_ValueBuilder.Add(o => o.RemoveAt(o.Count - 1));
                }
            }
        }
示例#2
0
        void BuildValue(VFXSlot slot)
        {
            foreach (var field in slot.property.type.GetFields())
            {
                VFXSlot subSlot = slot.children.FirstOrDefault <VFXSlot>(t => t.name == field.Name);

                if (subSlot != null)
                {
                    object result = null;
                    if (subSlot.HasLink(true) && m_Controller.viewController.CanGetEvaluatedContent(subSlot) && (result = m_Controller.viewController.GetEvaluatedContent(subSlot)) != null)
                    {
                        m_ValueBuilder.Add(o => o.Add(m_Controller.viewController.GetEvaluatedContent(subSlot)));
                    }
                    else if (subSlot.HasLink(false) && VFXTypeUtility.GetComponentCount(subSlot) != 0) // replace by is VFXType
                    {
                        m_Indeterminate = true;
                        return;
                    }
                    else
                    {
                        m_ValueBuilder.Add(o => o.Add(subSlot.value));
                        BuildValue(subSlot);
                        if (m_Indeterminate)
                        {
                            return;
                        }
                    }
                    m_ValueBuilder.Add(o =>
                    {
                        var newValue = o[o.Count - 1];
                        var target   = o[o.Count - 2];

                        if (newValue != null && field.FieldType != newValue.GetType())
                        {
                            object convertedValue;
                            if (!VFXConverter.TryConvertTo(newValue, field.FieldType, out convertedValue))
                            {
                                throw new InvalidOperationException(string.Format("VFXDataAnchorGizmo is failing to convert from {0} to {1}", newValue.GetType(), field.FieldType));
                            }
                            newValue = convertedValue;
                        }

                        field.SetValue(target, newValue);
                    });
                    m_ValueBuilder.Add(o => o.RemoveAt(o.Count - 1));
                }
            }
        }