/// <summary> /// Sets the texture offset for this material. If it doesn't exist as a material property object, create it. /// </summary> /// <param name="propertyName"></param> /// <param name="value"></param> public void SetTextureOffset(string propertyName, Vector2 value) { bool existsSavedProperty = false; foreach (WaterfallMaterialProperty p in matProperties) { if (p.propertyName == propertyName) { existsSavedProperty = true; } } if (!existsSavedProperty) { WaterfallMaterialTextureProperty newProp = new WaterfallMaterialTextureProperty(); newProp.propertyName = propertyName; newProp.textureScale = materials[0].GetTextureScale(propertyName); newProp.textureOffset = value; matProperties.Add(newProp); } else { foreach (WaterfallMaterialProperty p in matProperties) { if (p.propertyName == propertyName) { WaterfallMaterialTextureProperty t = (WaterfallMaterialTextureProperty)p; t.textureOffset = value; } } } foreach (Material mat in materials) { mat.SetTextureOffset(propertyName, value); } }
/// <summary> /// Sets the texture for this material. If it doesn't exist as a material property object, create it. /// </summary> /// <param name="propertyName"></param> /// <param name="value"></param> public void SetTexture(string propertyName, string value) { Utils.Log($"[WaterfallMaterial] Changing {propertyName} to {value}", LogType.Effects); bool existsSavedProperty = false; foreach (var p in matProperties) { if (p.propertyName == propertyName) { existsSavedProperty = true; } } if (!existsSavedProperty) { var newProp = new WaterfallMaterialTextureProperty(); newProp.propertyName = propertyName; newProp.texturePath = value; newProp.textureScale = materials[0].GetTextureScale(propertyName); newProp.textureOffset = materials[0].GetTextureOffset(propertyName); matProperties.Add(newProp); } else { foreach (var p in matProperties) { if (p.propertyName == propertyName) { var t = (WaterfallMaterialTextureProperty)p; t.texturePath = value; } } } foreach (var mat in materials) { Utils.Log($"[WaterfallMaterial] Changing {propertyName} to {value} on {mat}", LogType.Effects); mat.SetTexture(propertyName, GameDatabase.Instance.GetTexture(value, false)); } }