private MaterialPerInstanceProperties.IProperty DrawVectorProperty(MaterialPerInstanceProperties.IProperty property, int index, Rect nameRect, Rect sourceRect, Rect valueRect) { MaterialPerInstanceProperties.Vector4Property vectorProperty = (MaterialPerInstanceProperties.Vector4Property)property; if (DrawPropertyIdDropdrop(nameRect, ref property)) { return(property); } vectorProperty._source = (MaterialPerInstanceProperties.Vector4Property.ePropertySource)EditorGUI.EnumPopup(sourceRect, vectorProperty._source); switch (vectorProperty._source) { case MaterialPerInstanceProperties.Vector4Property.ePropertySource.Constant: vectorProperty._value = EditorGUI.Vector4Field(valueRect, "", vectorProperty._value); break; case MaterialPerInstanceProperties.Vector4Property.ePropertySource.RandomRange: { vectorProperty._xValueRange = FloatRangeDrawer.FloatRangeField(valueRect, vectorProperty._xValueRange); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._yValueRange = FloatRangeDrawer.FloatRangeField(valueRect, vectorProperty._yValueRange); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._zValueRange = FloatRangeDrawer.FloatRangeField(valueRect, vectorProperty._zValueRange); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._wValueRange = FloatRangeDrawer.FloatRangeField(valueRect, vectorProperty._wValueRange); } break; case MaterialPerInstanceProperties.Vector4Property.ePropertySource.RandomCurve: { vectorProperty._xValueCurve = EditorGUI.CurveField(valueRect, vectorProperty._xValueCurve); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._yValueCurve = EditorGUI.CurveField(valueRect, vectorProperty._yValueCurve); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._zValueCurve = EditorGUI.CurveField(valueRect, vectorProperty._zValueCurve); valueRect.position = new Vector2(valueRect.position.x, valueRect.position.y + EditorGUIUtility.singleLineHeight); vectorProperty._wValueCurve = EditorGUI.CurveField(valueRect, vectorProperty._wValueCurve); } break; } return(vectorProperty); }
private static MaterialPerInstanceProperties.IProperty GetPerInstanceProperty(MaterialProperty property) { MaterialPerInstanceProperties.IProperty perInstanceProperty = null; switch (property.type) { case MaterialProperty.PropType.Color: { perInstanceProperty = new MaterialPerInstanceProperties.ColorProperty() { _name = property.name, _value = property.colorValue, _valueGradient = new Gradient(), _source = MaterialPerInstanceProperties.ColorProperty.ePropertySource.Constant }; } break; case MaterialProperty.PropType.Vector: { perInstanceProperty = new MaterialPerInstanceProperties.Vector4Property() { _name = property.name, _value = property.vectorValue, _xValueCurve = new AnimationCurve(new Keyframe(0, property.vectorValue.x), new Keyframe(1, property.vectorValue.x)), _yValueCurve = new AnimationCurve(new Keyframe(0, property.vectorValue.y), new Keyframe(1, property.vectorValue.y)), _zValueCurve = new AnimationCurve(new Keyframe(0, property.vectorValue.w), new Keyframe(1, property.vectorValue.w)), _wValueCurve = new AnimationCurve(new Keyframe(0, property.vectorValue.z), new Keyframe(1, property.vectorValue.z)), _xValueRange = new FloatRange(property.vectorValue.x, property.vectorValue.x), _yValueRange = new FloatRange(property.vectorValue.y, property.vectorValue.y), _zValueRange = new FloatRange(property.vectorValue.w, property.vectorValue.w), _wValueRange = new FloatRange(property.vectorValue.z, property.vectorValue.z), _source = MaterialPerInstanceProperties.Vector4Property.ePropertySource.Constant }; } break; case MaterialProperty.PropType.Float: { perInstanceProperty = new MaterialPerInstanceProperties.FloatProperty() { _name = property.name, _value = property.floatValue, _valueCurve = new AnimationCurve(new Keyframe(0, property.floatValue), new Keyframe(1, property.floatValue)), _valueRange = new FloatRange(property.floatValue, property.floatValue), _source = MaterialPerInstanceProperties.FloatProperty.ePropertySource.Constant }; } break; case MaterialProperty.PropType.Texture: { perInstanceProperty = new MaterialPerInstanceProperties.TextureProperty() { _name = property.name, _value = property.textureValue, _valueArray = new Texture[] { property.textureValue }, _source = MaterialPerInstanceProperties.TextureProperty.ePropertySource.Constant }; } break; } return(perInstanceProperty); }