C# 我应该在XNA中重用模型实例吗?
在XNA中,我实例化了如下模型:C# 我应该在XNA中重用模型实例吗?,c#,model,xna,C#,Model,Xna,在XNA中,我实例化了如下模型: protected override void LoadContent() { this.model = this.Game.Content.Load<Model>("Units/Vehicles/Palladium"); base.LoadContent(); } protected override void LoadContent() { this.model=this.Game.Content.Load(“单位/车辆/钯”
protected override void LoadContent()
{
this.model = this.Game.Content.Load<Model>("Units/Vehicles/Palladium");
base.LoadContent();
}
protected override void LoadContent()
{
this.model=this.Game.Content.Load(“单位/车辆/钯”);
base.LoadContent();
}
我在像Tank这样的课堂上做这个。这里我要问的是,我应该为每个Tank实例实例化该模型实例(加载它),还是应该执行一次并将其分配给该Tank类的静态属性
我不确定tanks实例是否需要它们自己的所有实例,但我也不确定实例化新模型的成本是否很高
谢谢你的帮助 来自:
返回值
加载的资产。多次致电
加载相同的资源将返回
相同的对象实例
因此,从您的角度来看,本质上,答案是“只加载一次模型并跨实例重用”,而类会为您处理这一问题