コード例 #1
0
        private Tuple <PropertyWrapper, CableProperties.Direction, object> OnPropertyGUI(CableProperties.Direction dir,
                                                                                         CableProperties properties,
                                                                                         GUISkin skin)
        {
            Tuple <PropertyWrapper, CableProperties.Direction, object> changed = null;
            var data = EditorData.Instance.GetData(properties, "CableProperty" + dir.ToString());

            if (GUI.Foldout(data, GUI.MakeLabel(dir.ToString()), skin))
            {
                using (new GUI.Indent(12)) {
                    GUI.Separator();

                    var wrappers = PropertyWrapper.FindProperties <CableProperty>(System.Reflection.BindingFlags.Instance |
                                                                                  System.Reflection.BindingFlags.Public);
                    foreach (var wrapper in wrappers)
                    {
                        if (wrapper.GetContainingType() == typeof(float) && InspectorEditor.ShouldBeShownInInspector(wrapper.Member))
                        {
                            var value = EditorGUILayout.FloatField(InspectorGUI.MakeLabel(wrapper.Member),
                                                                   wrapper.Get <float>(properties[dir]));
                            if (UnityEngine.GUI.changed)
                            {
                                changed = new Tuple <PropertyWrapper, CableProperties.Direction, object>(wrapper, dir, value);
                                UnityEngine.GUI.changed = false;
                            }
                        }
                    }
                }
            }
            return(changed);
        }
コード例 #2
0
        private static PropertyWrapper[] GetOrFindProperties(Type type)
        {
            if (s_propertyWrapperCache.TryGetValue(type, out var cachedProperties))
            {
                return(cachedProperties);
            }
            Func <PropertyWrapper, int> propertyPriority = wrapper =>
            {
                var containingType = wrapper.GetContainingType();
                return(typeof(AGXUnity.IO.URDF.Element).IsAssignableFrom(containingType) ||
                       containingType.IsArray ?
                       -1 :
                       wrapper.Member.Name == "Name" ?
                       1 :
                       wrapper.Priority);
            };
            var properties = PropertyWrapper.FindProperties(type).OrderByDescending(propertyPriority).ToArray();

            s_propertyWrapperCache.Add(type, properties);
            return(properties);
        }