private void CreateElementEditor(MemberInfo memberInfo, Type type)
        {
            if (!m_editorsMap.IsPropertyEditorEnabled(type))
            {
                return;
            }
            GameObject editorPrefab = m_editorsMap.GetPropertyEditor(type);

            if (editorPrefab == null)
            {
                return;
            }
            PropertyEditor editor = Instantiate(editorPrefab).GetComponent <PropertyEditor>();

            if (editor == null)
            {
                return;
            }

            List <CustomTypeFieldAccessor> accessorsList = new List <CustomTypeFieldAccessor>();
            int targetsCount = Targets.Length;

            if (ChildDescriptors == null)
            {
                for (int i = 0; i < targetsCount; ++i)
                {
                    accessorsList.Add(new CustomTypeFieldAccessor(this, i, memberInfo, memberInfo.Name));
                }
            }
            else
            {
                PropertyDescriptor childPropertyDescriptor;
                if (ChildDescriptors.TryGetValue(memberInfo, out childPropertyDescriptor))
                {
                    for (int i = 0; i < targetsCount; ++i)
                    {
                        accessorsList.Add(new CustomTypeFieldAccessor(
                                              this, i, childPropertyDescriptor.MemberInfo, childPropertyDescriptor.Label));
                    }
                }
            }

            if (accessorsList.Count > 0)
            {
                CustomTypeFieldAccessor[] accessors = accessorsList.ToArray();

                editor.transform.SetParent(Panel, false);
                editor.Init(accessors, accessors, accessors[0].GetType().GetProperty("Value"), null, accessors[0].Name, OnValueChanging, OnValueChanged, null, false);
            }
        }
Exemple #2
0
        private void CreateElementEditor(MemberInfo memberInfo, Type type)
        {
            if (!m_editorsMap.IsPropertyEditorEnabled(type))
            {
                return;
            }
            GameObject editorPrefab = m_editorsMap.GetPropertyEditor(type);

            if (editorPrefab == null)
            {
                return;
            }
            PropertyEditor editor = Instantiate(editorPrefab).GetComponent <PropertyEditor>();

            if (editor == null)
            {
                return;
            }

            CustomTypeFieldAccessor accessor = null;

            if (ChildDescriptors == null)
            {
                accessor = new CustomTypeFieldAccessor(this, memberInfo, memberInfo.Name);
            }
            else
            {
                PropertyDescriptor childPropertyDescriptor;
                if (ChildDescriptors.TryGetValue(memberInfo, out childPropertyDescriptor))
                {
                    accessor = new CustomTypeFieldAccessor(
                        this,
                        childPropertyDescriptor.MemberInfo, childPropertyDescriptor.Label);
                }
            }
            if (accessor != null)
            {
                editor.transform.SetParent(Panel, false);
                editor.Init(accessor, accessor, accessor.GetType().GetProperty("Value"), null, accessor.Name, OnValueChanging, OnValueChanged, null, false);
            }
        }