wpf游戏引擎的script实现

1.script.cs

using System.IO;

using System.Runtime.Serialization;

using System.Text;

namespace PrimalEditor.Components

{

DataContract

class Script : Component

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

public override IMSComponent GetMultiselectionComponent(MSEntity msEntity) => new MSScript(msEntity);

public override void WriteToBinary(BinaryWriter bw)

{

var nameBytes = Encoding.UTF8.GetBytes(Name);

bw.Write(nameBytes.Length);

bw.Write(nameBytes);

}

public Script(GameEntity owner) : base(owner)

{

}

}

sealed class MSScript : MSComponent<Script>

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

protected override bool UpdateComponents(string propertyName)

{

if (propertyName == nameof(Name))

{

SelectedComponents.ForEach(c => c.Name = _name);

return true;

}

return false;

}

protected override bool UpdateMSComponent()

{

Name = MSEntity.GetMixedValue(SelectedComponents, new Func<Script, string>(x => x.Name));

return true;

}

public MSScript(MSEntity msEntity) : base(msEntity)

{

Refresh();

}

}

}

相关推荐
harrain15 小时前
拟合模型与虚幻引擎
游戏引擎·数字孪生·虚幻
bugcome_com20 小时前
WPF 命令 ICommand 从原理到实战
后端·wpf·icommand
DaLiangChen1 天前
Unity 精准 Mesh 点击检测:穿透遮挡 + 单击双击识别
unity·游戏引擎
迪普阳光开朗很健康1 天前
Unity中new() 和实例化有什么区别?
unity·游戏引擎
mxwin1 天前
Unity Shader 极坐标特效 从数学原理到实战案例
unity·游戏引擎·shader·uv
武藤一雄2 天前
WPF处理耗时操作的7种方法
microsoft·c#·.net·wpf
Venom842 天前
我的 WPF Powermill 工具
wpf
魔士于安2 天前
unity 圆盘式 太空飞船
游戏·unity·游戏引擎·贴图·模型
陈言必行2 天前
Unity 之 Addressables 加载失败:路径变量未替换导致的 404 错误分析与解决
unity·游戏引擎
qq_170264752 天前
unity出安卓年龄分级的arr包问题
android·unity·游戏引擎