要在我的Twig模板中显示图像,我
<img src="{{ asset('images/mylogo.png'}}" />
如果我手动设置我的图片并且#m;在&#39;网络&#39;我的申请目录。但我认为这不是一个好方法。我应该使用命令资产:安装网络&#39;
问题在于我使用命令资产:安装网络&#39;修改了我的图像名称(例如,名称将为fce32_mylogo_2.png)。 。 。我认为修改我的图像名称是有用的。
但是当我用来显示该图像时,我的Twig模板找不到我的图像。
我把我的形象和#m;手动在我的网络文件夹?我不确定。 。 。
编辑:我知道我可以使用这个synthax:
{% image 'bundles/myBundle/img/mylogo.png' %}
<img src="{{ asset_url }}" class="img-responsive" alt="">
{% endimage %}
但是这不允许传递twig变量。我想这样做:
{% image 'bundles/myBundle/img/'~someVar.logoUrl %}
<img src="{{ asset_url }}" class="img-responsive" alt="">
{% endimage %}
答案 0 :(得分:0)
清除资产转储并尝试:
public void save()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath + "/" + saveFilename);
//initialize and give some data
SaveData data = new SaveData(autoMove, hideControls, playMusic, joystickSize);
bf.Serialize(file, data);
file.Close();
}
public void load()
{
if (File.Exists(Application.persistentDataPath + "/" + saveFilename))
{
try
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/" + saveFilename, FileMode.Open);
SaveData data = bf.Deserialize(file) as SaveData;
//get data here
autoMove = data.autoMove;
hideControls = data.hideControls;
playMusic = data.playMusic;
joystickSize = data.joystickSize;
file.Close();
}
catch(Exception e)
{
//could debug here
}
}
}
//default values
[HideInInspector] public bool autoMove = false;
[HideInInspector] public bool hideControls = false;
[HideInInspector] public bool playMusic = true;
[HideInInspector] public int joystickSize = 1;
[Serializable]
public class SaveData
{
//put in data here
public bool autoMove;
public bool hideControls;
public bool playMusic;
public int joystickSize;
public SaveData(bool autoMove, bool hideControls, bool playMusic, int joystickSize)
{
this.autoMove = autoMove;
this.hideControls = hideControls;
this.playMusic = playMusic;
this.joystickSize = joystickSize;
}
}