示例#1
0
        public VFXSubParameterController[] ComputeSubControllers(Type type, IEnumerable <int> fieldPath, string memberPath)
        {
            var fields         = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
            var subControllers = new VFXSubParameterController[fields.Length];

            for (int i = 0; i < fields.Length; ++i)
            {
                string path = string.IsNullOrEmpty(memberPath) ? fields[i].Name : memberPath + VFXGizmoUtility.Context.separator + fields[i].Name;
                subControllers[i]      = new VFXSubParameterController(this, fieldPath.Concat(Enumerable.Repeat(i, 1)), path);
                m_ChildrenByPath[path] = subControllers[i];
            }
            return(subControllers);
        }
示例#2
0
        public void SetMemberValue(string memberPath, object value)
        {
            if (string.IsNullOrEmpty(memberPath))
            {
                this.value = value;
                return;
            }
            if (m_SubControllers == null)
            {
                m_SubControllers = ComputeSubControllers(portType, new List <int>(), "");
            }
            VFXSubParameterController subParameterController = null;

            if (m_ChildrenByPath.TryGetValue(memberPath, out subParameterController))
            {
                subParameterController.value = value;
            }
            else
            {
                string parentMemberPath = memberPath;

                List <string> members = new List <string>();

                while (true)
                {
                    int index = parentMemberPath.LastIndexOf(VFXGizmoUtility.Context.separator);
                    if (index == -1)
                    {
                        Debug.LogError("Coulnd't find SubParameter path " + memberPath);
                        return;
                    }

                    members.Add(parentMemberPath.Substring(index + 1));
                    parentMemberPath = parentMemberPath.Substring(0, index);
                    if (m_ChildrenByPath.TryGetValue(parentMemberPath, out subParameterController))
                    {
                        break;
                    }
                }

                foreach (var member in members)
                {
                    subParameterController = subParameterController.children.FirstOrDefault(t => t.name == member);
                    if (subParameterController == null)
                    {
                        Debug.LogError("Coulnd't find SubParameter path " + memberPath);
                        return;
                    }
                }
            }
        }