private MaterialPerInstanceProperties.IProperty DrawTextureProperty(MaterialPerInstanceProperties.IProperty property, int index, Rect nameRect, Rect sourceRect, Rect valueRect) { MaterialPerInstanceProperties.TextureProperty texureProperty = (MaterialPerInstanceProperties.TextureProperty)property; if (DrawPropertyIdDropdrop(nameRect, ref property)) { return(property); } texureProperty._source = (MaterialPerInstanceProperties.TextureProperty.ePropertySource)EditorGUI.EnumPopup(sourceRect, texureProperty._source); switch (texureProperty._source) { case MaterialPerInstanceProperties.TextureProperty.ePropertySource.Constant: texureProperty._value = (Texture)EditorGUI.ObjectField(valueRect, texureProperty._value, typeof(Texture), false); break; case MaterialPerInstanceProperties.TextureProperty.ePropertySource.RandomArray: //TO DO //texureProperty._valueCurve = EditorGUI.CurveField(valueRect, texureProperty._valueCurve); break; } return(texureProperty); }
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); }