Beispiel #1
0
        public static CableProperty Create(CableProperties.Direction dir)
        {
            CableProperty property = new CableProperty();

            property.Direction = dir;

            return(property);
        }
Beispiel #2
0
        public static CableProperty Create(CableProperties.Direction dir, Action <CableProperties.Direction> onValueChanged)
        {
            CableProperty property = new CableProperty();

            property.Direction      = dir;
            property.OnValueCanged += onValueChanged;

            return(property);
        }
Beispiel #3
0
        private void OnPropertyGUI(CableProperties.Direction dir, CableProperties properties, GUISkin skin)
        {
            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();

                    properties[dir].YoungsModulus = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Young's modulus"), properties[dir].YoungsModulus), 1.0E-6f, float.PositiveInfinity);
                    properties[dir].YieldPoint    = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Yield point"), properties[dir].YieldPoint), 0.0f, float.PositiveInfinity);
                    properties[dir].Damping       = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Spook damping"), properties[dir].Damping), 0.0f, float.PositiveInfinity);
                }
            }
        }
Beispiel #4
0
        private void OnPropertyValueUpdate(CableProperties.Direction dir)
        {
            if (Native != null)
            {
                Native.getCableProperties().setYoungsModulus(Convert.ToDouble(Properties[dir].YoungsModulus), CableProperties.ToNative(dir));
                Native.getCableProperties().setDamping(Convert.ToDouble(Properties[dir].Damping), CableProperties.ToNative(dir));
                Native.getCableProperties().setPoissonsRatio(Convert.ToDouble(Properties[dir].PoissonsRatio), CableProperties.ToNative(dir));

                var plasticityComponent = Native.getCablePlasticity();
                if (plasticityComponent != null)
                {
                    plasticityComponent.setYieldPoint(Convert.ToDouble(Properties[dir].YieldPoint), CableProperties.ToNative(dir));
                }
            }
        }
Beispiel #5
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);
        }